From 349b4ae7179173f9261d9a432094cb55dc433820 Mon Sep 17 00:00:00 2001 From: "adheli.tavares" Date: Fri, 21 Jul 2023 09:41:01 +0100 Subject: Java 17 Upgrade Issue-ID: POLICY-4668 Change-Id: If4e79224de61d66d7514f3abbd7b8bee1c3d5681 Signed-off-by: adheli.tavares --- capabilities/pom.xml | 4 +- .../onap/policy/common/capabilities/Startable.java | 15 +- common-logging/pom.xml | 44 +----- .../policy/common/logging/OnapLoggingUtils.java | 5 +- common-parameters/pom.xml | 29 +--- .../validation/ParameterGroupConstraint.java | 6 +- .../validation/ParameterGroupValidator.java | 6 +- gson/pom.xml | 51 +------ .../policy/common/gson/GsonMessageBodyHandler.java | 15 +- .../common/gson/GsonMessageBodyHandlerTest.java | 3 +- .../policy/common/gson/JacksonHandlerTest.java | 3 +- integrity-audit/pom.xml | 55 ++------ .../java/org/onap/policy/common/ia/DbAudit.java | 7 +- .../main/java/org/onap/policy/common/ia/DbDao.java | 19 +-- .../policy/common/ia/IntegrityAuditProperties.java | 9 +- .../policy/common/ia/jpa/IntegrityAuditEntity.java | 27 ++-- .../src/main/resources/META-INF/persistence.xml | 3 +- .../org/onap/policy/common/ia/DbAuditTest.java | 7 +- .../java/org/onap/policy/common/ia/DbDaoTest.java | 15 +- .../policy/common/ia/IntegrityAuditTestBase.java | 8 +- .../onap/policy/common/ia/jpa/IaTestEntity.java | 26 ++-- integrity-monitor/pom.xml | 45 +----- .../onap/policy/common/im/IntegrityMonitor.java | 14 +- .../common/im/IntegrityMonitorProperties.java | 9 +- .../org/onap/policy/common/im/StateManagement.java | 13 +- .../org/onap/policy/common/im/jpa/DateEntity.java | 15 +- .../common/im/jpa/ForwardProgressEntity.java | 25 ++-- .../onap/policy/common/im/jpa/ImTestEntity.java | 26 ++-- .../common/im/jpa/ResourceRegistrationEntity.java | 26 ++-- .../common/im/jpa/StateManagementEntity.java | 26 ++-- .../policy/common/im/IntegrityMonitorTest.java | 6 +- .../policy/common/im/IntegrityMonitorTestBase.java | 6 +- .../common/im/StateManagementEntityTest.java | 5 +- .../onap/policy/common/im/StateManagementTest.java | 17 +-- policy-endpoints/pom.xml | 156 +++++++++------------ .../common/endpoints/http/client/HttpClient.java | 13 +- .../http/client/HttpClientConfigException.java | 4 + .../http/client/IndexedHttpClientFactory.java | 3 +- .../http/client/internal/JerseyClient.java | 33 +++-- .../endpoints/http/server/AuthorizationFilter.java | 17 +-- .../endpoints/http/server/JsonExceptionMapper.java | 13 +- .../common/endpoints/http/server/RestServer.java | 4 +- .../endpoints/http/server/YamlExceptionMapper.java | 11 +- .../endpoints/http/server/YamlJacksonHandler.java | 9 +- .../http/server/YamlMessageBodyHandler.java | 15 +- .../endpoints/http/server/aaf/AafAuthFilter.java | 3 +- .../http/server/aaf/AafGranularAuthFilter.java | 3 +- .../http/server/internal/JettyJerseyServer.java | 20 ++- .../http/server/internal/JettyServletServer.java | 14 +- .../endpoints/http/server/test/HttpClientTest.java | 16 +-- .../endpoints/http/server/test/HttpServerTest.java | 13 +- .../http/server/test/JsonExceptionMapperTest.java | 3 +- .../endpoints/http/server/test/MyGsonProvider.java | 5 +- .../endpoints/http/server/test/MyYamlProvider.java | 5 +- .../http/server/test/RestEchoService.java | 39 +++--- .../endpoints/http/server/test/RestEndpoints.java | 9 +- .../http/server/test/RestMockHealthCheck.java | 15 +- .../endpoints/http/server/test/RestServerTest.java | 26 ++-- .../http/server/test/TestAafAuthFilter.java | 3 +- .../server/test/TestAafGranularAuthFilter.java | 3 +- .../http/server/test/TestAuthorizationFilter.java | 3 +- .../endpoints/http/server/test/TestFilter.java | 11 +- .../http/server/test/YamlExceptionMapperTest.java | 3 +- .../http/server/test/YamlJacksonHandlerTest.java | 6 +- .../server/test/YamlMessageBodyHandlerTest.java | 3 +- .../common/endpoints/utils/PropertyUtilsTest.java | 12 +- pom.xml | 116 +++++++++++++-- spring-utils/pom.xml | 10 +- .../spring/utils/CustomImplicitNamingStrategy.java | 5 +- utils-test/pom.xml | 52 ++----- .../policy/common/utils/gson/GsonTestUtils.java | 8 +- .../common/utils/security/SelfSignedKeyStore.java | 4 +- .../common/utils/gson/GsonTestUtilsTest.java | 1 + utils/pom.xml | 63 +-------- .../utils/cmd/CommandLineArgumentsHandler.java | 4 +- .../common/utils/cmd/CommandLineException.java | 3 + .../policy/common/utils/jpa/EntityMgrCloser.java | 3 +- .../common/utils/jpa/EntityMgrFactoryCloser.java | 3 +- .../policy/common/utils/jpa/EntityTransCloser.java | 3 +- .../policy/common/utils/security/CryptoUtils.java | 3 +- .../common/utils/services/ServiceManager.java | 2 +- .../common/utils/cmd/TestCommandLineArguments.java | 4 +- .../common/utils/jpa/EntityMgrCloserTest.java | 3 +- .../utils/jpa/EntityMgrFactoryCloserTest.java | 3 +- .../common/utils/jpa/EntityTransCloserTest.java | 3 +- .../common/utils/resources/ResourceUtilsTest.java | 14 +- version.properties | 2 +- 87 files changed, 629 insertions(+), 763 deletions(-) diff --git a/capabilities/pom.xml b/capabilities/pom.xml index 3d26c6fd..e270dbd9 100644 --- a/capabilities/pom.xml +++ b/capabilities/pom.xml @@ -25,7 +25,7 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT capabilities @@ -33,7 +33,7 @@ jar - + true diff --git a/capabilities/src/main/java/org/onap/policy/common/capabilities/Startable.java b/capabilities/src/main/java/org/onap/policy/common/capabilities/Startable.java index 49af75f8..0ce4da54 100644 --- a/capabilities/src/main/java/org/onap/policy/common/capabilities/Startable.java +++ b/capabilities/src/main/java/org/onap/policy/common/capabilities/Startable.java @@ -3,6 +3,7 @@ * policy-core * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,33 +30,33 @@ public interface Startable { * Start operation. This operation starts the entity. * * @return boolean. true if the start operation was successful, otherwise false. - * @throws IllegalStateException. if the element is in a state that conflicts with the start + * @throws IllegalStateException if the element is in a state that conflicts with the start * operation. */ - public boolean start(); + boolean start(); /** * Stop operation. The entity can be restarted again by invoking the start operation. * * @return boolean. true if the stop operation was successful, otherwise false. - * @throws IllegalStateException. if the element is in a state that conflicts with the stop + * @throws IllegalStateException if the element is in a state that conflicts with the stop * operation. */ - public boolean stop(); + boolean stop(); /** * shutdown operation. The terminate operation yields the entity unusuable. It cannot be * (re)started. * - * @throws IllegalStateException. if the element is in a state that conflicts with the stop + * @throws IllegalStateException if the element is in a state that conflicts with the stop * operation. */ - public void shutdown(); + void shutdown(); /** * Checks if the entity is alive. * * @return boolean. true if alive, otherwise false */ - public boolean isAlive(); + boolean isAlive(); } diff --git a/common-logging/pom.xml b/common-logging/pom.xml index 5b3acf84..ff7be885 100644 --- a/common-logging/pom.xml +++ b/common-logging/pom.xml @@ -25,7 +25,7 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT ONAP-Logging @@ -33,24 +33,6 @@ jar - - org.projectlombok - lombok - provided - - - com.google.re2j - re2j - - - javax.servlet - javax.servlet-api - compile - - - org.slf4j - slf4j-api - com.att.eelf eelf-core @@ -62,30 +44,6 @@ - - org.apache.commons - commons-lang3 - - - org.assertj - assertj-core - test - - - org.mockito - mockito-core - test - - - org.springframework - spring-test - test - - - junit - junit - test - diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java index 842b4772..91133d1a 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java @@ -3,6 +3,7 @@ * ONAP-Logging * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +22,7 @@ package org.onap.policy.common.logging; import com.google.re2j.Pattern; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -39,7 +40,7 @@ public final class OnapLoggingUtils { * @return the ONAPLoggingContext */ public static OnapLoggingContext getLoggingContextForRequest(HttpServletRequest request, - OnapLoggingContext baseContext) { + OnapLoggingContext baseContext) { var requestContext = new OnapLoggingContext(baseContext); if (request.getLocalAddr() != null) { // may be null in junit tests requestContext.setServerIpAddress(request.getLocalAddr()); diff --git a/common-parameters/pom.xml b/common-parameters/pom.xml index 2112385c..3c371e21 100644 --- a/common-parameters/pom.xml +++ b/common-parameters/pom.xml @@ -2,6 +2,7 @@ ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,7 +24,7 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT common-parameters @@ -31,14 +32,6 @@ [${project.parent.artifactId}] module provides common property and parameter handling the ONAP Policy Framework - - com.google.re2j - re2j - - - org.apache.commons - commons-lang3 - org.slf4j slf4j-api @@ -53,23 +46,5 @@ org.projectlombok lombok - - org.assertj - assertj-core - test - - - junit - junit - test - - - com.google.code.gson - gson - - - jakarta.validation - jakarta.validation-api - diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/validation/ParameterGroupConstraint.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/validation/ParameterGroupConstraint.java index f6ad817c..c73d135a 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/validation/ParameterGroupConstraint.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/validation/ParameterGroupConstraint.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,13 @@ package org.onap.policy.common.parameters.validation; +import jakarta.validation.Constraint; +import jakarta.validation.Payload; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.validation.Constraint; -import javax.validation.Payload; @Documented @Constraint(validatedBy = ParameterGroupValidator.class) diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/validation/ParameterGroupValidator.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/validation/ParameterGroupValidator.java index a50543ce..024ca139 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/validation/ParameterGroupValidator.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/validation/ParameterGroupValidator.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ package org.onap.policy.common.parameters.validation; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ParameterGroup; diff --git a/gson/pom.xml b/gson/pom.xml index 63e65d9c..07d16782 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -3,7 +3,7 @@ ONAP Policy Engine - Common Modules ================================================================================ Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. - Modifications Copyright (C) 2019,2023 Nordix Foundation. + Modifications Copyright (C) 2019, 2023 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -27,57 +27,16 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT gson Common Utilities jar + - com.google.re2j - re2j - - - org.slf4j - slf4j-api - provided - - - org.glassfish.jersey.core - jersey-server - - - com.google.code.gson - gson - - - javax.ws.rs - javax.ws.rs-api - - - org.projectlombok - lombok - provided - - - org.assertj - assertj-core - test - - - org.mockito - mockito-core - test - - - org.springframework - spring-test - test - - - junit - junit - test + jakarta.ws.rs + jakarta.ws.rs-api diff --git a/gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java b/gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java index a8017d22..a693b7f4 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java +++ b/gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,13 @@ package org.onap.policy.common.gson; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyReader; +import jakarta.ws.rs.ext.MessageBodyWriter; +import jakarta.ws.rs.ext.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -37,13 +45,6 @@ import java.time.OffsetDateTime; import java.time.OffsetTime; import java.time.ZoneOffset; import java.time.ZonedDateTime; -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.MessageBodyWriter; -import javax.ws.rs.ext.Provider; import lombok.AccessLevel; import lombok.Getter; import org.slf4j.Logger; diff --git a/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java b/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java index eee0c149..fc101430 100644 --- a/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java +++ b/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +26,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import jakarta.ws.rs.core.MediaType; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -36,7 +38,6 @@ import java.time.ZonedDateTime; import java.util.HashMap; import java.util.Map; import java.util.UUID; -import javax.ws.rs.core.MediaType; import lombok.ToString; import org.junit.Before; import org.junit.Test; diff --git a/gson/src/test/java/org/onap/policy/common/gson/JacksonHandlerTest.java b/gson/src/test/java/org/onap/policy/common/gson/JacksonHandlerTest.java index 891c4d31..7131817d 100644 --- a/gson/src/test/java/org/onap/policy/common/gson/JacksonHandlerTest.java +++ b/gson/src/test/java/org/onap/policy/common/gson/JacksonHandlerTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,13 +27,13 @@ import static org.junit.Assert.assertTrue; import com.google.gson.Gson; import com.google.gson.JsonObject; +import jakarta.ws.rs.core.MediaType; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.StringReader; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; -import javax.ws.rs.core.MediaType; import lombok.ToString; import org.junit.Test; import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter; diff --git a/integrity-audit/pom.xml b/integrity-audit/pom.xml index b031634e..9a2447a2 100644 --- a/integrity-audit/pom.xml +++ b/integrity-audit/pom.xml @@ -30,30 +30,31 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT Integrity Audit - org.projectlombok - lombok + org.onap.policy.common + utils + ${project.version} - junit - junit + org.onap.policy.common + utils-test + ${project.version} test - org.mockito - mockito-core - test + org.onap.policy.common + ONAP-Logging + ${project.version} - org.springframework - spring-test - test + org.projectlombok + lombok org.slf4j @@ -63,39 +64,7 @@ com.h2database h2 - - - org.hibernate.javax.persistence - hibernate-jpa-2.1-api - - - org.hibernate - hibernate-entitymanager - - - org.onap.policy.common - utils - ${project.version} - - - org.onap.policy.common - utils-test - ${project.version} test - - org.assertj - assertj-core - test - - - org.onap.policy.common - ONAP-Logging - ${project.version} - - - org.apache.commons - commons-lang3 - diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java index d20ed80c..7dd66542 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java @@ -3,6 +3,7 @@ * Integrity Audit * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,7 @@ package org.onap.policy.common.ia; +import jakarta.persistence.Table; import java.io.Serializable; import java.util.Arrays; import java.util.HashMap; @@ -29,7 +31,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; -import javax.persistence.Table; import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.builder.RecursiveToStringStyle; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; @@ -459,13 +460,13 @@ public class DbAudit { String tableName = entityClass.getAnnotation(Table.class).name(); String msg = "\nDB Audit Error: " + "\n Table Name: " + tableName + "\n Entry 1 (short prefix style): " + resourceName1 + ": " - + new ReflectionToStringBuilder(entry1, ToStringStyle.SHORT_PREFIX_STYLE).toString() + + new ReflectionToStringBuilder(entry1, ToStringStyle.SHORT_PREFIX_STYLE) + "\n Entry 2 (short prefix style): " + resourceName2 + ": " + (entry2 != null ? new ReflectionToStringBuilder(entry2, ToStringStyle.SHORT_PREFIX_STYLE).toString() : "null") + "\n Entry 1 (recursive style): " + resourceName1 + ": " - + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()).toString() + + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()) + "\n Entry 2 (recursive style): " + resourceName2 + ": " + (entry2 != null ? new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString() diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java index e83bbca8..de383868 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbDao.java @@ -3,6 +3,7 @@ * Integrity Audit * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,15 @@ package org.onap.policy.common.ia; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.Persistence; +import jakarta.persistence.Query; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.metamodel.ManagedType; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -27,15 +37,6 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.function.BiConsumer; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.Persistence; -import javax.persistence.Query; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; -import javax.persistence.metamodel.ManagedType; import org.onap.policy.common.ia.jpa.IntegrityAuditEntity; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java index 9122b721..cd80f56f 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java @@ -3,6 +3,7 @@ * Integrity Audit * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,10 +29,10 @@ public class IntegrityAuditProperties { public static final int DEFAULT_AUDIT_PERIOD_SECONDS = -1; // Audit does not run - public static final String DB_DRIVER = "javax.persistence.jdbc.driver"; - public static final String DB_URL = "javax.persistence.jdbc.url"; - public static final String DB_USER = "javax.persistence.jdbc.user"; - public static final String DB_PWD = "javax.persistence.jdbc.password"; //NOSONAR + public static final String DB_DRIVER = "jakarta.persistence.jdbc.driver"; + public static final String DB_URL = "jakarta.persistence.jdbc.url"; + public static final String DB_USER = "jakarta.persistence.jdbc.user"; + public static final String DB_PWD = "jakarta.persistence.jdbc.password"; //NOSONAR public static final String AUDIT_PERIOD_SECONDS = "integrity_audit_period_seconds"; diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java index 07b85579..ec9c2a4d 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java @@ -21,29 +21,26 @@ package org.onap.policy.common.ia.jpa; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.PrePersist; -import javax.persistence.PreUpdate; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -/* - * The Entity class to for management of IntegrityAudits - */ import org.onap.policy.common.ia.AuditorTime; @Entity diff --git a/integrity-audit/src/main/resources/META-INF/persistence.xml b/integrity-audit/src/main/resources/META-INF/persistence.xml index b648cd63..3a7fdd7f 100644 --- a/integrity-audit/src/main/resources/META-INF/persistence.xml +++ b/integrity-audit/src/main/resources/META-INF/persistence.xml @@ -25,11 +25,12 @@ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> + org.hibernate.jpa.HibernatePersistenceProvider org.onap.policy.common.ia.jpa.IntegrityAuditEntity org.onap.policy.common.ia.jpa.IaTestEntity NONE - + diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java index 08db0136..c48ec0e3 100644 --- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java +++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbAuditTest.java @@ -3,6 +3,7 @@ * Integrity Audit * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,11 +26,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import com.google.re2j.Pattern; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; import java.util.List; import java.util.Properties; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java index 79dfeb18..9f2103d7 100644 --- a/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java +++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DbDaoTest.java @@ -3,6 +3,7 @@ * Integrity Audit * ================================================================================ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,18 +26,18 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import jakarta.persistence.PersistenceUnitUtil; +import jakarta.persistence.Query; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; -import javax.persistence.PersistenceUnitUtil; -import javax.persistence.Query; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -57,7 +58,7 @@ public class DbDaoTest extends IntegrityAuditTestBase { private static final String SITE_B = "SiteB"; private static final String ENTITY_CLASS_NAME = "org.onap.policy.common.ia.jpa.IntegrityAuditEntity"; - private static String resourceName = "pdp0"; + private static final String resourceName = "pdp0"; private DbDao dbDao; diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java index 28ca9c01..f5a32777 100644 --- a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java +++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java @@ -26,6 +26,10 @@ import static org.junit.Assert.fail; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.Persistence; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -37,10 +41,6 @@ import java.util.Properties; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.Persistence; import org.onap.policy.common.utils.jpa.EntityMgrCloser; import org.onap.policy.common.utils.jpa.EntityMgrFactoryCloser; import org.onap.policy.common.utils.jpa.EntityTransCloser; diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java index 89876f24..8a34909a 100644 --- a/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java +++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/jpa/IaTestEntity.java @@ -3,7 +3,7 @@ * Integrity Audit * ================================================================================ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,20 +21,20 @@ package org.onap.policy.common.ia.jpa; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; import java.io.Serializable; import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.PrePersist; -import javax.persistence.PreUpdate; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; @Entity @Table(name = "IaTestEntity") diff --git a/integrity-monitor/pom.xml b/integrity-monitor/pom.xml index 119b7024..58cb45f2 100644 --- a/integrity-monitor/pom.xml +++ b/integrity-monitor/pom.xml @@ -31,44 +31,12 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT Integrity Monitor - - org.mockito - mockito-core - test - - - org.springframework - spring-test - test - - - junit - junit - test - - - com.h2database - h2 - - - org.hibernate.javax.persistence - hibernate-jpa-2.1-api - - - org.hibernate - hibernate-entitymanager - - - org.projectlombok - lombok - provided - org.onap.policy.common utils @@ -80,11 +48,6 @@ ${project.version} test - - org.assertj - assertj-core - test - org.onap.policy.common ONAP-Logging @@ -93,7 +56,11 @@ commons-logging commons-logging - 1.2 + test + + + com.h2database + h2 test diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java index d0b320fc..e7cb4ab4 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java @@ -22,6 +22,13 @@ package org.onap.policy.common.im; import com.google.re2j.Pattern; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.FlushModeType; +import jakarta.persistence.LockModeType; +import jakarta.persistence.Persistence; +import jakarta.persistence.TypedQuery; import java.net.InetAddress; import java.util.ArrayList; import java.util.Arrays; @@ -38,13 +45,6 @@ import java.util.function.LongConsumer; import java.util.function.Supplier; import javax.management.JMX; import javax.management.MBeanServerConnection; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.FlushModeType; -import javax.persistence.LockModeType; -import javax.persistence.Persistence; -import javax.persistence.TypedQuery; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java index 75aed5b3..6af7a557 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java @@ -3,6 +3,7 @@ * Integrity Monitor * ================================================================================ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +27,10 @@ import lombok.NoArgsConstructor; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class IntegrityMonitorProperties { - public static final String DB_DRIVER = "javax.persistence.jdbc.driver"; - public static final String DB_URL = "javax.persistence.jdbc.url"; - public static final String DB_USER = "javax.persistence.jdbc.user"; - public static final String DB_PWD = "javax.persistence.jdbc.password"; //NOSONAR + public static final String DB_DRIVER = "jakarta.persistence.jdbc.driver"; + public static final String DB_URL = "jakarta.persistence.jdbc.url"; + public static final String DB_USER = "jakarta.persistence.jdbc.user"; + public static final String DB_PWD = "jakarta.persistence.jdbc.password"; //NOSONAR // intervals specified are in seconds public static final int DEFAULT_MONITOR_INTERVAL = 30; diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java index b68373ba..eace6037 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java @@ -3,6 +3,7 @@ * Integrity Monitor * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,16 +21,16 @@ package org.onap.policy.common.im; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.FlushModeType; +import jakarta.persistence.LockModeType; +import jakarta.persistence.TypedQuery; import java.util.Collection; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.FlushModeType; -import javax.persistence.LockModeType; -import javax.persistence.TypedQuery; import org.onap.policy.common.im.exceptions.EntityRetrievalException; import org.onap.policy.common.im.jpa.StateManagementEntity; import org.onap.policy.common.utils.jpa.EntityMgrCloser; @@ -377,7 +378,7 @@ public class StateManagement { notFound.run(); } } catch (final Exception ex) { - logger.error("StateManagement: {} exception: {}", methodName, ex.toString(), ex); + logger.error("StateManagement: {} exception: {}", methodName, ex.getMessage(), ex); } } diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/DateEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/DateEntity.java index 769aa9d9..5213baef 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/DateEntity.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/DateEntity.java @@ -3,6 +3,7 @@ * Integrity Monitor * ================================================================================ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +21,15 @@ package org.onap.policy.common.im.jpa; +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.io.Serial; import java.io.Serializable; import java.util.Date; -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; -import javax.persistence.PrePersist; -import javax.persistence.PreUpdate; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -41,6 +43,7 @@ import org.onap.policy.common.im.MonitorTime; @Setter @NoArgsConstructor public class DateEntity implements Serializable { + @Serial private static final long serialVersionUID = 1L; @Temporal(TemporalType.TIMESTAMP) diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java index f4c3f4f0..7c9698b3 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java @@ -21,15 +21,15 @@ package org.onap.policy.common.im.jpa; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.PrePersist; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.PrePersist; +import jakarta.persistence.Table; +import java.io.Serial; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -37,14 +37,13 @@ import lombok.Setter; @Entity @Table(name = "ForwardProgressEntity") -@NamedQueries({ - @NamedQuery(name = " ForwardProgressEntity.findAll", query = "SELECT e FROM ForwardProgressEntity e "), - @NamedQuery(name = "ForwardProgressEntity.deleteAll", query = "DELETE FROM ForwardProgressEntity WHERE 1=1") -}) +@NamedQuery(name = " ForwardProgressEntity.findAll", query = "SELECT e FROM ForwardProgressEntity e ") +@NamedQuery(name = "ForwardProgressEntity.deleteAll", query = "DELETE FROM ForwardProgressEntity WHERE 1=1") @Getter @Setter @NoArgsConstructor public class ForwardProgressEntity extends DateEntity { + @Serial private static final long serialVersionUID = 1L; @Id diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java index 96a23908..420bdcf3 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java @@ -21,20 +21,21 @@ package org.onap.policy.common.im.jpa; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.io.Serial; import java.io.Serializable; import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.PrePersist; -import javax.persistence.PreUpdate; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -52,6 +53,7 @@ import org.onap.policy.common.im.MonitorTime; @Setter @NoArgsConstructor public class ImTestEntity implements Serializable { + @Serial private static final long serialVersionUID = 1L; @Id diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java index 7457f733..a771ba09 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java @@ -21,14 +21,15 @@ package org.onap.policy.common.im.jpa; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQueries; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.Table; +import java.io.Serial; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -39,16 +40,13 @@ import lombok.Setter; @Entity @Table(name = "ResourceRegistrationEntity") -@NamedQueries({ - @NamedQuery(name = " ResourceRegistrationEntity.findAll", query = "SELECT e FROM ResourceRegistrationEntity e "), - @NamedQuery( - name = "ResourceRegistrationEntity.deleteAll", - query = "DELETE FROM ResourceRegistrationEntity WHERE 1=1") -}) +@NamedQuery(name = " ResourceRegistrationEntity.findAll", query = "SELECT e FROM ResourceRegistrationEntity e ") +@NamedQuery(name = "ResourceRegistrationEntity.deleteAll", query = "DELETE FROM ResourceRegistrationEntity WHERE 1=1") @Getter @Setter @NoArgsConstructor public class ResourceRegistrationEntity extends DateEntity { + @Serial private static final long serialVersionUID = 1L; @Id diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java index 44c4e9b7..b03ec71b 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java @@ -3,6 +3,7 @@ * Integrity Monitor * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,19 +21,20 @@ package org.onap.policy.common.im.jpa; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.NamedQuery; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import java.io.Serial; import java.io.Serializable; import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.NamedQuery; -import javax.persistence.PrePersist; -import javax.persistence.PreUpdate; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -42,11 +44,11 @@ import org.onap.policy.common.im.MonitorTime; @Entity @Table(name = "StateManagementEntity") @NamedQuery(name = "StateManagementEntity.findAll", query = "SELECT e FROM StateManagementEntity e") - @Getter @Setter @NoArgsConstructor public class StateManagementEntity implements Serializable { + @Serial private static final long serialVersionUID = 1L; @Id diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java index 451a384c..35e7a037 100644 --- a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java +++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java @@ -25,14 +25,14 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.Query; +import jakarta.persistence.TemporalType; import java.util.Date; import java.util.List; import java.util.Properties; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import javax.persistence.EntityTransaction; -import javax.persistence.Query; -import javax.persistence.TemporalType; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java index 684ac749..1433c20d 100644 --- a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java +++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java @@ -23,14 +23,14 @@ package org.onap.policy.common.im; import static org.junit.Assert.assertTrue; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; import org.onap.policy.common.utils.jpa.EntityTransCloser; import org.onap.policy.common.utils.test.log.logback.ExtractAppender; import org.onap.policy.common.utils.time.CurrentTime; diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java index 10ab9f3c..34ff25a7 100644 --- a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java +++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java @@ -3,6 +3,7 @@ * Integrity Monitor * ================================================================================ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +23,8 @@ package org.onap.policy.common.im; import static org.junit.Assert.assertEquals; +import jakarta.persistence.Query; import java.util.List; -import javax.persistence.Query; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -35,7 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class StateManagementEntityTest extends IntegrityMonitorTestBase { - private static Logger logger = LoggerFactory.getLogger(StateManagementEntityTest.class); + private static final Logger logger = LoggerFactory.getLogger(StateManagementEntityTest.class); /** * Set up for the test class. diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java index b1d7d5b4..443bcdd3 100644 --- a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java +++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,12 +30,12 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.PersistenceException; -import javax.persistence.QueryTimeoutException; -import javax.persistence.TypedQuery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.QueryTimeoutException; +import jakarta.persistence.TypedQuery; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -57,7 +58,7 @@ public class StateManagementTest extends IntegrityMonitorTestBase { private static final String UNLOCKED_ENABLED_NULL_PROVIDINGSERVICE = "unlocked,enabled,null,providingservice"; private static final String TEST_RESOURCE_NAME = "test_resource1"; - private static Logger logger = LoggerFactory.getLogger(StateManagementTest.class); + private static final Logger logger = LoggerFactory.getLogger(StateManagementTest.class); // @BeforeClass @@ -244,7 +245,7 @@ public class StateManagementTest extends IntegrityMonitorTestBase { @Test(expected = StateManagementException.class) @SuppressWarnings("unchecked") - public void test_StateManagementInitialization_ThrowStateManagementException_ifEntityManagerthrowsAnyException() + public void test_StateManagementInitialization_ThrowStateManagementException_ifEntityManagerThrowsAnyException() throws Exception { final EntityManager mockedEm = getMockedEntityManager(); final EntityManagerFactory mockedEmf = getMockedEntityManagerFactory(mockedEm); diff --git a/policy-endpoints/pom.xml b/policy-endpoints/pom.xml index 79db23e8..da0ad38b 100644 --- a/policy-endpoints/pom.xml +++ b/policy-endpoints/pom.xml @@ -29,14 +29,29 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT + policy-endpoints policy-endpoints Endpoints + 1.2.1-oss + + + + + org.glassfish.jersey + jersey-bom + ${version.jersey} + pom + import + + + + org.onap.policy.common @@ -58,6 +73,12 @@ common-parameters ${project.version} + + org.onap.policy.common + utils-test + ${project.version} + test + com.att.nsa cambriaClient @@ -68,151 +89,100 @@ - - com.fasterxml.jackson.core - jackson-core + com.google.guava + guava + 32.1.1-jre com.fasterxml.jackson.core jackson-databind + ${version.jackson} com.fasterxml.jackson.core jackson-annotations + ${version.jackson} com.fasterxml.jackson.module jackson-module-jaxb-annotations + ${version.jackson} com.fasterxml.jackson.dataformat jackson-dataformat-yaml + ${version.jackson} - org.onap.dmaap.messagerouter.dmaapclient - dmaapClient - - - org.onap.aaf.authz - aaf-cadi-aaf - - - org.eclipse.jetty - jetty-server + org.glassfish.jaxb + jaxb-runtime + 4.0.2 + compile - org.eclipse.jetty - jetty-servlet + org.glassfish.jersey.containers + jersey-container-servlet - org.eclipse.jetty - jetty-servlets + org.glassfish.jersey.media + jersey-media-json-jackson + ${version.jersey} + compile org.glassfish.jersey.core jersey-server + ${version.jersey} - org.glassfish.jersey.containers - jersey-container-servlet-core + org.glassfish.jersey.inject + jersey-hk2 + ${version.jersey} - org.glassfish.jersey.containers - jersey-container-jetty-http + org.apache.httpcomponents.client5 + httpclient5 - org.glassfish.jersey.core - jersey-client + org.apache.httpcomponents.core5 + httpcore5 - org.glassfish.jersey.core - jersey-common + jakarta.activation + jakarta.activation-api - com.google.code.gson - gson + jakarta.inject + jakarta.inject-api - org.apache.httpcomponents - httpclient + org.onap.dmaap.messagerouter.dmaapclient + dmaapClient - org.apache.httpcomponents - httpcore + org.onap.aaf.authz + aaf-cadi-aaf - io.swagger - swagger-jersey2-jaxrs - - - org.junit.jupiter - junit-jupiter - - - org.junit.jupiter - junit-jupiter-api - - + org.eclipse.jetty + jetty-servlet - io.prometheus - simpleclient_hotspot + org.eclipse.jetty + jetty-security - io.prometheus - simpleclient_servlet + org.apache.kafka + kafka-clients org.apache.commons commons-collections4 - ch.qos.logback - logback-classic - - - org.onap.policy.common - utils-test - ${project.version} - test - - - junit - junit - test - - - org.mockito - mockito-core - test - - - org.springframework - spring-test - test - - - org.assertj - assertj-core - test - - - org.glassfish.jersey.inject - jersey-hk2 - - - com.openpojo - openpojo - - - org.projectlombok - lombok - provided - - - org.apache.kafka - kafka-clients + io.swagger.core.v3 + swagger-annotations diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java index 8a133155..01deaa2d 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +21,12 @@ package org.onap.policy.common.endpoints.http.client; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.InvocationCallback; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.Response; import java.util.Map; import java.util.concurrent.Future; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.InvocationCallback; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Response; import org.onap.policy.common.capabilities.Startable; /** @@ -193,9 +194,9 @@ public interface HttpClient extends Startable { String getBasePath(); /** - * Get the user name. + * Get the username. * - * @return the user name + * @return the username */ String getUserName(); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java index 98ec576f..bb871fa0 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +21,13 @@ package org.onap.policy.common.endpoints.http.client; +import java.io.Serial; + /** * Exception generated by HttpClient builder. */ public class HttpClientConfigException extends Exception { + @Serial private static final long serialVersionUID = 1L; public HttpClientConfigException() { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java index 25fce5cd..5f0b1d6e 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +45,7 @@ class IndexedHttpClientFactory implements HttpClientFactory { /** * Logger. */ - private static Logger logger = LoggerFactory.getLogger(IndexedHttpClientFactory.class); + private static final Logger logger = LoggerFactory.getLogger(IndexedHttpClientFactory.class); protected HashMap clients = new HashMap<>(); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java index 753994a6..130b6c15 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,13 @@ package org.onap.policy.common.endpoints.http.client.internal; import com.google.re2j.Pattern; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.client.InvocationCallback; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.Response; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; @@ -31,13 +38,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.Future; import javax.net.ssl.SSLContext; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation.Builder; -import javax.ws.rs.client.InvocationCallback; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.Response; import lombok.Getter; import lombok.ToString; import org.apache.commons.lang3.StringUtils; @@ -60,7 +60,7 @@ public class JerseyClient implements HttpClient { /** * Logger. */ - private static Logger logger = LoggerFactory.getLogger(JerseyClient.class); + private static final Logger logger = LoggerFactory.getLogger(JerseyClient.class); protected static final String JERSEY_DEFAULT_SERIALIZATION_PROVIDER = "org.onap.policy.common.gson.GsonMessageBodyHandler"; @@ -82,9 +82,14 @@ public class JerseyClient implements HttpClient { /** * Constructor. * - *

name the name https is it https or not selfSignedCerts are there self signed certs - * hostname the hostname port port being used basePath base context userName user - * password password + *

name - the name + * https - is it https or not + * selfSignedCerts - are there self-signed certs + * hostname - the hostname + * port - port being used + * basePath - base context + * userName - user credentials + * password - password credentials * * @param busTopicParams Input parameters object * @throws KeyManagementException key exception @@ -136,9 +141,9 @@ public class JerseyClient implements HttpClient { if (this.selfSignedCerts) { sslContext.init(null, NetworkUtil.getAlwaysTrustingManager(), new SecureRandom()); - // This falls under self signed certs which is used for non-production testing environments where + // This falls under self-signed certs which is used for non-production testing environments where // the hostname in the cert is unlikely to be crafted properly. We always return true for the - // hostname verifier. This causes a sonar vuln but we ignore it as it could cause problems in some + // hostname verifier. This causes a sonar vuln, but we ignore it as it could cause problems in some // testing environments. clientBuilder = ClientBuilder.newBuilder().sslContext(sslContext).hostnameVerifier( diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/AuthorizationFilter.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/AuthorizationFilter.java index d884b869..b58cde7c 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/AuthorizationFilter.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/AuthorizationFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,20 +21,20 @@ package org.onap.policy.common.endpoints.http.server; +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 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.slf4j.Logger; import org.slf4j.LoggerFactory; public abstract class AuthorizationFilter implements Filter { - private static Logger logger = LoggerFactory.getLogger(AuthorizationFilter.class); + private static final Logger logger = LoggerFactory.getLogger(AuthorizationFilter.class); @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/JsonExceptionMapper.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/JsonExceptionMapper.java index d0df156f..0030c121 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/JsonExceptionMapper.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/JsonExceptionMapper.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +22,11 @@ package org.onap.policy.common.endpoints.http.server; import com.google.gson.JsonSyntaxException; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; import lombok.AllArgsConstructor; import lombok.Getter; import org.slf4j.Logger; @@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory; @Provider @Produces(MediaType.APPLICATION_JSON) public class JsonExceptionMapper implements ExceptionMapper { - private static Logger logger = LoggerFactory.getLogger(JsonExceptionMapper.class); + private static final Logger logger = LoggerFactory.getLogger(JsonExceptionMapper.class); @Override public Response toResponse(JsonSyntaxException exception) { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java index 3301aece..e7924771 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java @@ -22,12 +22,12 @@ package org.onap.policy.common.endpoints.http.server; +import jakarta.servlet.Filter; import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.Properties; import java.util.stream.Collectors; -import javax.servlet.Filter; import lombok.ToString; import org.onap.policy.common.endpoints.http.server.aaf.AafAuthFilter; import org.onap.policy.common.endpoints.parameters.RestServerParameters; @@ -150,7 +150,7 @@ public class RestServer extends ServiceManagerContainer { * @return the provider class names */ private String getProviderClassNames(List> jaxrsProviders) { - return String.join(",", jaxrsProviders.stream().map(Class::getName).collect(Collectors.toList())); + return jaxrsProviders.stream().map(Class::getName).collect(Collectors.joining(",")); } private String getValue(final String value) { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlExceptionMapper.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlExceptionMapper.java index 15a584fb..c30c2072 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlExceptionMapper.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlExceptionMapper.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +21,10 @@ package org.onap.policy.common.endpoints.http.server; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.ext.ExceptionMapper; +import jakarta.ws.rs.ext.Provider; import lombok.AllArgsConstructor; import lombok.Getter; import org.slf4j.Logger; @@ -37,7 +38,7 @@ import org.yaml.snakeyaml.error.YAMLException; @Provider @Produces(YamlMessageBodyHandler.APPLICATION_YAML) public class YamlExceptionMapper implements ExceptionMapper { - private static Logger logger = LoggerFactory.getLogger(YamlExceptionMapper.class); + private static final Logger logger = LoggerFactory.getLogger(YamlExceptionMapper.class); @Override public Response toResponse(YAMLException exception) { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlJacksonHandler.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlJacksonHandler.java index f71aa90f..4639e6a2 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlJacksonHandler.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlJacksonHandler.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +22,10 @@ package org.onap.policy.common.endpoints.http.server; import com.google.gson.GsonBuilder; -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.ext.Provider; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.ext.Provider; import org.onap.policy.common.gson.JacksonHandler; import org.onap.policy.common.utils.coder.YamlJsonTranslator; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlMessageBodyHandler.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlMessageBodyHandler.java index 644e6e2d..6de6b754 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlMessageBodyHandler.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlMessageBodyHandler.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,13 @@ package org.onap.policy.common.endpoints.http.server; import com.google.gson.GsonBuilder; import com.google.gson.JsonSyntaxException; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.ext.MessageBodyReader; +import jakarta.ws.rs.ext.MessageBodyWriter; +import jakarta.ws.rs.ext.Provider; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -30,13 +38,6 @@ import java.io.OutputStreamWriter; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; -import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyReader; -import javax.ws.rs.ext.MessageBodyWriter; -import javax.ws.rs.ext.Provider; import org.onap.policy.common.gson.GsonMessageBodyHandler; import org.onap.policy.common.utils.coder.YamlJsonTranslator; import org.slf4j.Logger; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/aaf/AafAuthFilter.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/aaf/AafAuthFilter.java index df1f6044..084d2fb9 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/aaf/AafAuthFilter.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/aaf/AafAuthFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.endpoints.http.server.aaf; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.onap.policy.common.endpoints.http.server.AuthorizationFilter; /** diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/aaf/AafGranularAuthFilter.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/aaf/AafGranularAuthFilter.java index 27b15a9c..39524e87 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/aaf/AafGranularAuthFilter.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/aaf/AafGranularAuthFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.endpoints.http.server.aaf; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.onap.policy.common.utils.network.NetworkUtil; /** diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java index 42ef1c9e..d4c392b9 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyJerseyServer.java @@ -22,10 +22,11 @@ package org.onap.policy.common.endpoints.http.server.internal; -import io.swagger.jersey.config.JerseyJaxrsConfig; import org.apache.commons.lang3.StringUtils; +import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.glassfish.jersey.server.ServerProperties; +import org.glassfish.jersey.servlet.ServletContainer; import org.onap.policy.common.endpoints.http.server.JsonExceptionMapper; import org.onap.policy.common.gson.GsonMessageBodyHandler; import org.onap.policy.common.utils.network.NetworkUtil; @@ -37,7 +38,7 @@ import org.slf4j.LoggerFactory; * *

Note: the serialization provider will always be added to the server's class providers, as will the swagger * providers (assuming swagger has been enabled). This happens whether {@link #addServletClass(String, String)} is used - * or {@link #addServletPackage(String, String)} is used. Thus it's possible to have both the server's class provider + * or {@link #addServletPackage(String, String)} is used. Thus, it's possible to have both the server's class provider * property and the server's package provider property populated. */ public class JettyJerseyServer extends JettyServletServer { @@ -68,12 +69,6 @@ public class JettyJerseyServer extends JettyServletServer { protected static final String JERSEY_GSON_INIT_CLASSNAMES_PARAM_VALUE = String.join(",", GsonMessageBodyHandler.class.getName(), JsonExceptionMapper.class.getName()); - /** - * Jersey Swagger Classes Init Param Value. - */ - protected static final String SWAGGER_INIT_CLASSNAMES_PARAM_VALUE = - "io.swagger.jaxrs.listing.ApiListingResource," + "io.swagger.jaxrs.listing.SwaggerSerializers"; - /** * Logger. */ @@ -116,7 +111,10 @@ public class JettyJerseyServer extends JettyServletServer { */ protected void attachSwaggerServlet(boolean https) { - ServletHolder swaggerServlet = getServlet(JerseyJaxrsConfig.class, "/"); + ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); + handler.setContextPath("/"); + + ServletHolder swaggerServlet = handler.addServlet(ServletContainer.class, "/*"); String hostname = this.connector.getHost(); if (StringUtils.isBlank(hostname) || hostname.equals(NetworkUtil.IPV4_WILDCARD_ADDRESS)) { @@ -226,8 +224,8 @@ public class JettyJerseyServer extends JettyServletServer { initClasses = classProvider; if (this.swaggerId != null) { - initClasses += "," + SWAGGER_INIT_CLASSNAMES_PARAM_VALUE; - + jerseyServlet.setInitParameter("jersey.config.server.provider.packages", + "io.swagger.v3.jaxrs2.integration.resources,io.swagger.sample.resource"); jerseyServlet.setInitParameter(SWAGGER_CONTEXT_ID, swaggerId); jerseyServlet.setInitParameter(SWAGGER_SCANNER_ID, swaggerId); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java index 2f7bdc7f..4e1eda9f 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java @@ -22,13 +22,12 @@ package org.onap.policy.common.endpoints.http.server.internal; -import io.prometheus.client.exporter.MetricsServlet; import io.prometheus.client.hotspot.DefaultExports; +import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet; +import jakarta.servlet.Servlet; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; -import javax.servlet.DispatcherType; -import javax.servlet.Servlet; import lombok.Getter; import lombok.NonNull; import lombok.ToString; @@ -72,7 +71,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable /** * Logger. */ - private static Logger logger = LoggerFactory.getLogger(JettyServletServer.class); + private static final Logger logger = LoggerFactory.getLogger(JettyServletServer.class); private static final String NOT_SUPPORTED = " is not supported on this type of jetty server"; @@ -101,7 +100,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable protected boolean sniHostCheck; /** - * Server auth user name. + * Server auth username. */ @Getter protected String user; @@ -146,7 +145,7 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable * Start condition. */ @ToString.Exclude - protected Object startCondition = new Object(); + protected final Object startCondition = new Object(); /** * Constructor. @@ -227,7 +226,8 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable tempFilterPath = "/*"; } - context.addFilter(filterClass, tempFilterPath, EnumSet.of(DispatcherType.INCLUDE, DispatcherType.REQUEST)); + context.addFilter(filterClass, tempFilterPath, + EnumSet.of(jakarta.servlet.DispatcherType.INCLUDE, jakarta.servlet.DispatcherType.REQUEST)); } protected ServletHolder getServlet(@NonNull Class servlet, @NonNull String servletPath) { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java index da8ea7ae..27e7dc5f 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java @@ -28,7 +28,11 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import io.prometheus.client.exporter.MetricsServlet; +import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.InvocationCallback; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -36,10 +40,6 @@ import java.util.Properties; import java.util.TreeMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.InvocationCallback; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import lombok.Getter; import org.junit.AfterClass; import org.junit.Before; @@ -490,7 +490,7 @@ public class HttpClientTest { response = clientPdp.get("metrics"); assertEquals(200, response.getStatus()); - response = clientPdp.get("swagger.json"); + response = clientPdp.get("openapi.json"); assertEquals(200, response.getStatus()); assertFalse(MyGsonProvider.hasWrittenSome()); @@ -534,7 +534,7 @@ public class HttpClientTest { } - class MyEntity { + static class MyEntity { private String myParameter; @@ -552,7 +552,7 @@ public class HttpClientTest { } - class MyCallback implements InvocationCallback { + static class MyCallback implements InvocationCallback { @Getter private Response response; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java index dcb3906d..48cacaf9 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java @@ -32,7 +32,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import com.google.gson.Gson; -import io.prometheus.client.exporter.MetricsServlet; +import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; @@ -64,7 +64,7 @@ public class HttpServerTest { private static final String LOCALHOST = "localhost"; private static final String JSON_MEDIA = "application/json"; private static final String YAML_MEDIA = YamlMessageBodyHandler.APPLICATION_YAML; - private static final String SWAGGER_JSON = "/swagger.json"; + private static final String SWAGGER_JSON = "/openapi.json"; private static final String JUNIT_ECHO_HELLO = "/junit/echo/hello"; private static final String JUNIT_ECHO_FULL_REQUEST = "/junit/echo/full/request"; private static final String SOME_TEXT = "some text"; @@ -73,7 +73,7 @@ public class HttpServerTest { /** * Logger. */ - private static Logger logger = LoggerFactory.getLogger(HttpServerTest.class); + private static final Logger logger = LoggerFactory.getLogger(HttpServerTest.class); private static final String LOCALHOST_PREFIX = "http://localhost:"; @@ -286,7 +286,7 @@ public class HttpServerTest { assertEquals(reqText, response); response = http(portUrl + SWAGGER_JSON); - assertThat(response).contains("Swagger Server"); + assertThat(response).contains("openapi"); } @Test @@ -410,11 +410,6 @@ public class HttpServerTest { assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAlive()); assertEquals(1, HttpServletServerFactoryInstance.getServerFactory().inventory().size()); - System.setProperty("cadi_longitude", "0.0"); - System.setProperty("cadi_latitude", "0.0"); - server.setAafAuthentication("/*"); - assertTrue(HttpServletServerFactoryInstance.getServerFactory().get(port).isAaf()); - HttpServletServerFactoryInstance.getServerFactory().destroy(port); assertEquals(0, HttpServletServerFactoryInstance.getServerFactory().inventory().size()); } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/JsonExceptionMapperTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/JsonExceptionMapperTest.java index 59ce0c1c..27e98670 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/JsonExceptionMapperTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/JsonExceptionMapperTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +24,7 @@ package org.onap.policy.common.endpoints.http.server.test; import static org.junit.Assert.assertEquals; import com.google.gson.JsonSyntaxException; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.http.server.JsonExceptionMapper; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyGsonProvider.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyGsonProvider.java index 8343d02d..78c41cc2 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyGsonProvider.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyGsonProvider.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +21,13 @@ package org.onap.policy.common.endpoints.http.server.test; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; import lombok.AccessLevel; import lombok.Setter; import org.onap.policy.common.gson.GsonMessageBodyHandler; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyYamlProvider.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyYamlProvider.java index 098ecb44..624d7686 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyYamlProvider.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/MyYamlProvider.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +21,13 @@ package org.onap.policy.common.endpoints.http.server.test; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; import lombok.AccessLevel; import lombok.Setter; import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoService.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoService.java index 373950b2..b4a652aa 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoService.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEchoService.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,29 +21,30 @@ package org.onap.policy.common.endpoints.http.server.test; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.PUT; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler; -@Api(value = "echo") @Path("/junit/echo") public class RestEchoService { @GET @Path("{word}") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "echoes back whatever received") + @Operation(summary = "echoes back whatever received") public String echo(@PathParam("word") String word) { return word; } @@ -50,7 +52,7 @@ public class RestEchoService { @PUT @Path("{word}") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "echoes back whatever received") + @Operation(summary = "echoes back whatever received") public String echoPut(@PathParam("word") String word, Object entity) { return "PUT:" + word + ":" + entity.toString(); } @@ -58,7 +60,8 @@ public class RestEchoService { @POST @Path("/full/request") @Produces({MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML}) - @ApiOperation(value = "echoes back the request structure", response = RestEchoReqResp.class) + @Operation(summary = "echoes back the request structure") + @ApiResponse(content = {@Content(schema = @Schema(implementation = RestEchoReqResp.class))}) public Response echoFullyPost(RestEchoReqResp reqResp) { return Response.status(Status.OK).entity(reqResp).build(); } @@ -66,7 +69,7 @@ public class RestEchoService { @POST @Path("{word}") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "echoes back whatever received") + @Operation(summary = "echoes back whatever received") public String echoPost(@PathParam("word") String word, Object entity) { return "POST:" + word + ":" + entity.toString(); } @@ -74,7 +77,7 @@ public class RestEchoService { @DELETE @Path("{word}") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "echoes back whatever received") + @Operation(summary = "echoes back whatever received") public String echoDelete(@PathParam("word") String word) { return "DELETE:" + word; } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java index cafab42f..cbcf4c9a 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestEndpoints.java @@ -3,6 +3,7 @@ * policy-endpoints * ================================================================================ * Copyright (C) 2017, 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +21,11 @@ package org.onap.policy.common.endpoints.http.server.test; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import java.util.List; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestMockHealthCheck.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestMockHealthCheck.java index f0d68c0c..f476dbaf 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestMockHealthCheck.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestMockHealthCheck.java @@ -3,6 +3,7 @@ * policy-endpoints * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +21,12 @@ package org.onap.policy.common.endpoints.http.server.test; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; @Path("/") public class RestMockHealthCheck { @@ -40,7 +41,7 @@ public class RestMockHealthCheck { @GET @Path("pdp/test") @Produces(MediaType.APPLICATION_JSON) - public Response pdpHealthCheck() { + public Response pdpHealthCheck() { return Response.status(Status.INTERNAL_SERVER_ERROR).entity("At least some Dead").build(); } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java index c025d425..216c4fd9 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java @@ -33,7 +33,18 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import io.prometheus.client.exporter.MetricsServlet; +import io.prometheus.client.servlet.jakarta.exporter.MetricsServlet; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import java.io.IOException; import java.io.PrintWriter; import java.net.HttpURLConnection; @@ -43,17 +54,6 @@ import java.util.Arrays; import java.util.Base64; import java.util.List; import java.util.Properties; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import lombok.Getter; import org.apache.commons.io.IOUtils; import org.junit.AfterClass; @@ -384,7 +384,7 @@ public class RestServerTest { } } - private static class Filter2 implements javax.servlet.Filter { + private static class Filter2 implements jakarta.servlet.Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java index 27d45c8d..a9a19424 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafAuthFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.endpoints.http.server.test; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.onap.policy.common.endpoints.http.server.aaf.AafAuthFilter; public class TestAafAuthFilter extends AafAuthFilter { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java index 183e5ae7..bccff70f 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAafGranularAuthFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.endpoints.http.server.test; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter; import org.onap.policy.common.utils.network.NetworkUtil; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAuthorizationFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAuthorizationFilter.java index f3cd7424..59ec6f13 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAuthorizationFilter.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestAuthorizationFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.endpoints.http.server.test; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.onap.policy.common.endpoints.http.server.AuthorizationFilter; public class TestAuthorizationFilter extends AuthorizationFilter { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java index 44b37656..155e12bb 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/TestFilter.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +21,12 @@ package org.onap.policy.common.endpoints.http.server.test; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; import java.io.IOException; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; public class TestFilter implements Filter { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlExceptionMapperTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlExceptionMapperTest.java index 96c23ed3..5317eadb 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlExceptionMapperTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlExceptionMapperTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +23,7 @@ package org.onap.policy.common.endpoints.http.server.test; import static org.junit.Assert.assertEquals; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.http.server.YamlExceptionMapper; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java index 8d65bbd6..b2b81c26 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlJacksonHandlerTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,12 +26,13 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import com.google.gson.JsonObject; +import jakarta.ws.rs.core.MediaType; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; -import javax.ws.rs.core.MediaType; import lombok.ToString; import org.junit.Test; import org.onap.policy.common.endpoints.http.server.YamlJacksonHandler; @@ -66,7 +68,7 @@ public class YamlJacksonHandlerTest { ByteArrayOutputStream outstr = new ByteArrayOutputStream(); hdlr.writeTo(data, Data.class, Data.class, null, null, null, outstr); - assertEquals("abc: def\nhello: world\nmyId: 100\nvalue: a value\n", outstr.toString("UTF-8")); + assertEquals("abc: def\nhello: world\nmyId: 100\nvalue: a value\n", outstr.toString(StandardCharsets.UTF_8)); /* * Ensure everything deserializes as expected. diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java index c0927aa9..962c09db 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/YamlMessageBodyHandlerTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +26,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import jakarta.ws.rs.core.MediaType; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -32,7 +34,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; -import javax.ws.rs.core.MediaType; import lombok.ToString; import org.junit.Before; import org.junit.Test; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java index 048a3902..f8665a90 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ package org.onap.policy.common.endpoints.utils; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -76,11 +78,11 @@ public class PropertyUtilsTest { @Test public void testGetBoolean() { - assertEquals(true, utils.getBoolean(".my-bool", false)); - assertEquals(false, utils.getBoolean(".my-bool2", true)); - assertEquals(true, utils.getBoolean(".empty-bool", true)); - assertEquals(false, utils.getBoolean(".invalid-bool", true)); - assertEquals(true, utils.getBoolean(".missing-bool", true)); + assertTrue(utils.getBoolean(".my-bool", false)); + assertFalse(utils.getBoolean(".my-bool2", true)); + assertTrue(utils.getBoolean(".empty-bool", true)); + assertFalse(utils.getBoolean(".invalid-bool", true)); + assertTrue(utils.getBoolean(".missing-bool", true)); assertNull(invalidName); assertNull(invalidValue); diff --git a/pom.xml b/pom.xml index 03b95d42..91214db0 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ ONAP policy ================================================================================ Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. - Modifications Copyright (C) 2019-2020, 2022 Nordix Foundation. + Modifications Copyright (C) 2019-2020, 2022-2023 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -25,13 +25,13 @@ org.onap.policy.parent integration - 4.0.0-SNAPSHOT + 4.0.1-SNAPSHOT org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT pom @@ -39,8 +39,6 @@ Common Modules for Policy-Engine in both XACML and Drools flavor - - https://nexus.onap.org /content/sites/site/${project.groupId}/${project.artifactId}/${project.version} @@ -62,11 +60,112 @@ spring-utils + + + org.yaml + snakeyaml + + + org.slf4j + slf4j-api + + + com.google.code.gson + gson + + + org.apache.commons + commons-lang3 + + + com.fasterxml.jackson.core + jackson-core + + + + + io.prometheus + simpleclient + + + io.prometheus + simpleclient_hotspot + + + io.prometheus + simpleclient_servlet_jakarta + + + io.prometheus + simpleclient_logback + + + com.google.re2j + re2j + + + org.projectlombok + lombok + provided + + + jakarta.xml.bind + jakarta.xml.bind-api + + + jakarta.servlet + jakarta.servlet-api + + + jakarta.validation + jakarta.validation-api + + + io.swagger.core.v3 + swagger-jaxrs2-jakarta + + + io.swagger.core.v3 + swagger-jaxrs2-servlet-initializer-v2-jakarta + + + org.hibernate.orm + hibernate-core + + + org.hibernate + hibernate-core-jakarta + + + + + org.springframework + spring-test + test + + + junit + junit + test + + + org.assertj + assertj-core + test + + + org.mockito + mockito-core + test + + + org.apache.maven.plugins maven-deploy-plugin + 3.1.1 @@ -74,11 +173,12 @@ org.apache.maven.plugins maven-site-plugin + 4.0.0-M9 org.apache.maven.wagon wagon-webdav-jackrabbit - 2.10 + 3.5.3 @@ -89,14 +189,14 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.4 + 3.5.0 false org.umlgraph.doclet.UmlGraphDoc org.umlgraph umlgraph - 5.6 + 5.6.6 -views true diff --git a/spring-utils/pom.xml b/spring-utils/pom.xml index 37b73e19..f162629f 100644 --- a/spring-utils/pom.xml +++ b/spring-utils/pom.xml @@ -3,6 +3,7 @@ ONAP policy ================================================================================ Copyright (C) 2022 Bell Canada. All rights reserved. + Modifications Copyright (C) 2023 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -26,12 +27,12 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT spring-utils spring-utils - This artifact contains the common spring related utilitiy classes to be used by multiple policy framework components. + This artifact contains the common spring related utility classes to be used by multiple policy framework components. @@ -44,11 +45,6 @@ org.springframework spring-web - - - org.hibernate - hibernate-core - \ No newline at end of file diff --git a/spring-utils/src/main/java/org/onap/policy/common/spring/utils/CustomImplicitNamingStrategy.java b/spring-utils/src/main/java/org/onap/policy/common/spring/utils/CustomImplicitNamingStrategy.java index 1a747a3c..d9a7e97c 100644 --- a/spring-utils/src/main/java/org/onap/policy/common/spring/utils/CustomImplicitNamingStrategy.java +++ b/spring-utils/src/main/java/org/onap/policy/common/spring/utils/CustomImplicitNamingStrategy.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022 Bell Canada. All rights reserved. + * Copyright (C) 2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +21,14 @@ package org.onap.policy.common.spring.utils; +import java.io.Serial; import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.naming.ImplicitJoinColumnNameSource; import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl; public class CustomImplicitNamingStrategy extends ImplicitNamingStrategyJpaCompliantImpl { + @Serial private static final long serialVersionUID = 8666774028328486896L; @Override diff --git a/utils-test/pom.xml b/utils-test/pom.xml index 8cdcf1cd..acca1d7f 100644 --- a/utils-test/pom.xml +++ b/utils-test/pom.xml @@ -25,7 +25,7 @@ org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT utils-test @@ -34,8 +34,7 @@ 2.0.4 - - + true @@ -43,56 +42,20 @@ org.bouncycastle bcpkix-fips - 1.0.5 - - - com.google.re2j - re2j + 1.0.7 org.apache.commons commons-jexl3 3.1 - - org.projectlombok - lombok - provided - - - junit - junit - provided - - - org.assertj - assertj-core - test - - - ch.qos.logback - logback-classic - org.onap.policy.common utils ${project.version} - - org.onap.policy.common - gson - ${project.version} - - - org.mockito - mockito-core - test - - - org.springframework - spring-test - test - + + org.awaitility awaitility @@ -103,5 +66,10 @@ openpojo compile + + junit + junit + compile + diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java index 161e7c5c..4aedf872 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java @@ -31,10 +31,8 @@ import com.google.re2j.Pattern; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map.Entry; import lombok.AccessLevel; @@ -100,7 +98,6 @@ public class GsonTestUtils { * * @param object the object to be encoded * @param expected the expected value - * @throws Exception if the file cannot be read */ public void compareGson(Object object, Class expected) { compareGson(object, new File(expected.getSimpleName() + ".json")); @@ -113,7 +110,6 @@ public class GsonTestUtils { * * @param object the object to be encoded * @param expected the expected value - * @throws Exception if the file cannot be read */ public void compareGson(Object object, File expected) { // file is not required to have a full path - find it via getResource() @@ -173,7 +169,7 @@ public class GsonTestUtils { * @throws IOException if an error occurs */ protected String readFile(File file) throws IOException { - return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); + return Files.readString(file.toPath()); } @@ -269,7 +265,7 @@ public class GsonTestUtils { // sort the keys before copying to the new object List> sortedSet = new ArrayList<>(jsonObj.entrySet()); - Collections.sort(sortedSet, (left, right) -> left.getKey().compareTo(right.getKey())); + sortedSet.sort(Entry.comparingByKey()); for (Entry ent : sortedSet) { JsonElement val = ent.getValue(); diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java b/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java index 647ff1ba..0787872c 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java @@ -56,6 +56,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils; * Keystore, containing a self-signed certificate, valid for one day (see the argument to * the "-valid" flag below). For use in junit tests. */ +@Getter public class SelfSignedKeyStore { public static final String KEYSTORE_PASSWORD = "Pol1cy_0nap"; public static final String PRIVATE_KEY_PASSWORD = KEYSTORE_PASSWORD; @@ -67,7 +68,6 @@ public class SelfSignedKeyStore { */ private static final String KEYSTORE_SAN = "keystore_san.txt"; - @Getter private final String keystoreName; @@ -115,7 +115,7 @@ public class SelfSignedKeyStore { var sanArray = sanString.replace("DNS:", "").replace("\r", "").split("\n"); GeneralName[] nameArray = Arrays.stream(sanArray).map(name -> new GeneralName(GeneralName.dNSName, name)) - .collect(Collectors.toList()).toArray(new GeneralName[0]); + .toList().toArray(new GeneralName[0]); final var names = new GeneralNames(nameArray); try (var ostr = new FileOutputStream(keystoreFile)) { diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java index 907b7789..9de586d6 100644 --- a/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java +++ b/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java @@ -34,6 +34,7 @@ import com.google.gson.JsonParseException; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import lombok.Getter; import lombok.ToString; import org.apache.commons.jexl3.JexlException; import org.junit.Before; diff --git a/utils/pom.xml b/utils/pom.xml index 85f0b53f..510b1094 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -20,13 +20,13 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.onap.policy.common common-modules - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT utils @@ -34,18 +34,6 @@ jar - - javax.xml.bind - jaxb-api - - - org.yaml - snakeyaml - - - com.google.code.gson - gson - org.onap.policy.common capabilities @@ -56,60 +44,21 @@ gson ${project.version} - - org.apache.commons - commons-lang3 - - - commons-net - commons-net - 3.6 - - - com.google.guava - guava - - - com.google.re2j - re2j - - - junit - junit - test - - - ch.qos.logback - logback-classic - - - org.hibernate.javax.persistence - hibernate-jpa-2.1-api - com.worldturner.medeia medeia-validator-gson - org.projectlombok - lombok - provided + commons-net + commons-net + + org.slf4j slf4j-api provided - - org.mockito - mockito-core - test - - - org.assertj - assertj-core - test - commons-cli commons-cli diff --git a/utils/src/main/java/org/onap/policy/common/utils/cmd/CommandLineArgumentsHandler.java b/utils/src/main/java/org/onap/policy/common/utils/cmd/CommandLineArgumentsHandler.java index b9ba3fdd..970cebfe 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/cmd/CommandLineArgumentsHandler.java +++ b/utils/src/main/java/org/onap/policy/common/utils/cmd/CommandLineArgumentsHandler.java @@ -100,7 +100,7 @@ public class CommandLineArgumentsHandler { */ public CommandLineArgumentsHandler(String helpClassName, String component, Option... customOptions) { this(helpClassName, component); - if (customOptions != null && customOptions.length > 0) { + if (customOptions != null) { for (Option option : customOptions) { options.addOption(option); } @@ -108,7 +108,7 @@ public class CommandLineArgumentsHandler { } /** - * Construct the options with brand new options for the CLI editor. + * Construct the options with brand-new options for the CLI editor. */ public CommandLineArgumentsHandler(String helpClassName, String component, Options options) { this.options = options; diff --git a/utils/src/main/java/org/onap/policy/common/utils/cmd/CommandLineException.java b/utils/src/main/java/org/onap/policy/common/utils/cmd/CommandLineException.java index 95870f75..9cdf3d37 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/cmd/CommandLineException.java +++ b/utils/src/main/java/org/onap/policy/common/utils/cmd/CommandLineException.java @@ -20,6 +20,8 @@ package org.onap.policy.common.utils.cmd; +import java.io.Serial; + /** * Exception used for CommandLineArguments class. * @@ -31,6 +33,7 @@ public class CommandLineException extends Exception { /** * Generated serialVersionUID. */ + @Serial private static final long serialVersionUID = -1200607308084606425L; /** diff --git a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrCloser.java b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrCloser.java index f975422e..f1798516 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrCloser.java +++ b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrCloser.java @@ -3,6 +3,7 @@ * Common Utils * ================================================================================ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.utils.jpa; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloser.java b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloser.java index 8901277f..5f3a6ea8 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloser.java +++ b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloser.java @@ -3,6 +3,7 @@ * Common Utils * ================================================================================ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.utils.jpa; -import javax.persistence.EntityManagerFactory; +import jakarta.persistence.EntityManagerFactory; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java index bc5623b0..131e87a4 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java +++ b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java @@ -3,6 +3,7 @@ * Common Utils * ================================================================================ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.utils.jpa; -import javax.persistence.EntityTransaction; +import jakarta.persistence.EntityTransaction; import lombok.Getter; /** diff --git a/utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java b/utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java index 3de6df39..a974f1e5 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/security/CryptoUtils.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +21,12 @@ package org.onap.policy.common.utils.security; +import jakarta.xml.bind.DatatypeConverter; import java.nio.charset.StandardCharsets; import java.util.Random; import javax.crypto.Cipher; import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.SecretKeySpec; -import javax.xml.bind.DatatypeConverter; import org.apache.commons.lang3.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/utils/src/main/java/org/onap/policy/common/utils/services/ServiceManager.java b/utils/src/main/java/org/onap/policy/common/utils/services/ServiceManager.java index 67a588fe..08994912 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/services/ServiceManager.java +++ b/utils/src/main/java/org/onap/policy/common/utils/services/ServiceManager.java @@ -213,7 +213,7 @@ public class ServiceManager implements Startable { /* * Cannot use a plain Runnable, because it can't throw exceptions. Could use a - * Callable, instead, but then all of the lambda expressions become rather messy, thus + * Callable, instead, but then all the lambda expressions become rather messy, thus * we'll stick with RunnableWithEx, and just disable the sonar warning. */ @FunctionalInterface diff --git a/utils/src/test/java/org/onap/policy/common/utils/cmd/TestCommandLineArguments.java b/utils/src/test/java/org/onap/policy/common/utils/cmd/TestCommandLineArguments.java index 1501e769..b45f107d 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/cmd/TestCommandLineArguments.java +++ b/utils/src/test/java/org/onap/policy/common/utils/cmd/TestCommandLineArguments.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public class TestCommandLineArguments { @Test public void testParse_ShouldThrowExceptionWhenFileNameNull() { String[] nullArgs = {"-c", null}; - assertThatThrownBy(() -> testCmd.parse(nullArgs)).hasMessage(ERR_MSG_INVALID_ARGS).hasRootCauseMessage(null); + assertThatThrownBy(() -> testCmd.parse(nullArgs)).hasMessage(ERR_MSG_INVALID_ARGS); } @Test diff --git a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrCloserTest.java b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrCloserTest.java index b8730a65..17d7f7ff 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrCloserTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrCloserTest.java @@ -3,6 +3,7 @@ * Common Utils * ================================================================================ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.junit.Before; import org.junit.Test; diff --git a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloserTest.java b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloserTest.java index 3981e2af..0e8edca2 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloserTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloserTest.java @@ -3,6 +3,7 @@ * Common Utils * ================================================================================ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import javax.persistence.EntityManagerFactory; +import jakarta.persistence.EntityManagerFactory; import org.junit.Before; import org.junit.Test; diff --git a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java index 18b39d26..dc63c673 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java @@ -3,6 +3,7 @@ * Common Utils * ================================================================================ * Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +28,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import javax.persistence.EntityTransaction; +import jakarta.persistence.EntityTransaction; import org.junit.Before; import org.junit.Test; diff --git a/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java b/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java index 54e17209..a39b4fc2 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2020-2021 Nordix Foundation. + * Modifications Copyright (C) 2020-2021, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,12 +77,12 @@ public class ResourceUtilsTest { } /** - * Cleandown resource utils test. + * Clean resource utils test. */ @After - public void cleandownResourceUtilsTest() { - tmpEmptyFile.delete(); - tmpUsedFile.delete(); + public void cleanDownResourceUtilsTest() { + assertTrue(tmpEmptyFile.delete()); + assertTrue(tmpUsedFile.delete()); } /** @@ -312,8 +312,8 @@ public class ResourceUtilsTest { normalizePath(resultD2.iterator().next())); Set resultJ0 = ResourceUtils.getDirectoryContents("com"); - assertTrue(resultJ0.contains("com/google/gson/")); - assertEquals("com/google/", normalizePath(resultJ0.iterator().next())); + assertTrue(resultJ0.contains("com/worldturner/medeia/")); + assertEquals("com/worldturner/", normalizePath(resultJ0.iterator().next())); Set resultJ1 = ResourceUtils.getDirectoryContents("com/google/gson"); assertTrue(resultJ1.size() > 1); diff --git a/version.properties b/version.properties index 20aa7408..07282725 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ minor=2 minor=0 -patch=0 +patch=1 base_version=${major}.${minor}.${patch} -- cgit 1.2.3-korg