Java 17 / Spring 6 / Spring Boot 3 Upgrade 07/136007/1
authoradheli.tavares <adheli.tavares@est.tech>
Wed, 2 Aug 2023 13:49:33 +0000 (14:49 +0100)
committeradheli.tavares <adheli.tavares@est.tech>
Fri, 22 Sep 2023 14:46:33 +0000 (15:46 +0100)
Issue-ID: POLICY-4670
Change-Id: Ie25d0501e5b936621e41f0d3c637320784d56627
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
47 files changed:
main/pom.xml
main/src/main/java/org/onap/policy/api/main/config/PolicyApiAafConfig.java
main/src/main/java/org/onap/policy/api/main/config/PolicyPreloadConfig.java
main/src/main/java/org/onap/policy/api/main/config/SecurityConfig.java
main/src/main/java/org/onap/policy/api/main/config/WebConfig.java
main/src/main/java/org/onap/policy/api/main/exception/PolicyApiException.java
main/src/main/java/org/onap/policy/api/main/exception/PolicyApiRuntimeException.java
main/src/main/java/org/onap/policy/api/main/exception/ServiceExceptionHandler.java
main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
main/src/main/java/org/onap/policy/api/main/rest/CommonRestController.java
main/src/main/java/org/onap/policy/api/main/rest/stub/ApiRestControllerStub.java
main/src/main/java/org/onap/policy/api/main/rest/stub/NodeTemplateControllerStub.java
main/src/main/java/org/onap/policy/api/main/rest/stub/StubUtils.java
main/src/main/java/org/onap/policy/api/main/service/NodeTemplateService.java
main/src/main/java/org/onap/policy/api/main/service/PdpGroupService.java
main/src/main/java/org/onap/policy/api/main/service/ToscaServiceTemplateService.java
main/src/main/java/org/onap/policy/api/main/startstop/ApiDatabaseInitializer.java
main/src/main/resources/META-INF/persistence.xml
main/src/main/resources/application.yaml
main/src/main/resources/openapi/openapi.yaml
main/src/test/java/org/onap/policy/api/contract/ApiContractTest.java
main/src/test/java/org/onap/policy/api/main/exception/TestPolicyApiException.java
main/src/test/java/org/onap/policy/api/main/exception/TestPolicyApiRuntimeException.java
main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
main/src/test/java/org/onap/policy/api/main/rest/TestCommonRestController.java
main/src/test/java/org/onap/policy/api/main/rest/TestNodeTemplateController.java
main/src/test/java/org/onap/policy/api/main/rest/aaf/TestAafApiFilter.java
main/src/test/java/org/onap/policy/api/main/rest/utils/CommonTestRestController.java
main/src/test/java/org/onap/policy/api/main/service/TestCommonToscaServiceTemplateService.java
main/src/test/java/org/onap/policy/api/main/service/TestNodeTemplateService.java
main/src/test/java/org/onap/policy/api/main/service/TestPdpGroupService.java
main/src/test/java/org/onap/policy/api/main/service/TestPolicyService.java
main/src/test/java/org/onap/policy/api/main/service/TestPolicyTypeService.java
main/src/test/java/org/onap/policy/api/main/service/TestToscaServiceTemplateForNodeTemplate.java
main/src/test/java/org/onap/policy/api/main/service/TestToscaServiceTemplateServiceForPolicyCrud.java
main/src/test/java/org/onap/policy/api/main/service/TestToscaServiceTemplateServiceForPolicyTypeCrud.java
main/src/test/java/org/onap/policy/api/main/startstop/ApiDatabaseInitializerTest.java
main/src/test/resources/META-INF/persistence.xml
packages/policy-api-docker/pom.xml
packages/policy-api-docker/src/main/docker/Dockerfile
packages/policy-api-tarball/pom.xml
packages/pom.xml
pom.xml
testsuites/performance/pom.xml
testsuites/pom.xml
testsuites/stability/pom.xml
version.properties

index 893cec0..5f88ee5 100644 (file)
     <parent>
         <groupId>org.onap.policy.api</groupId>
         <artifactId>policy-api</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
+        <version>3.0.1-SNAPSHOT</version>
     </parent>
     <artifactId>api-main</artifactId>
     <name>${project.artifactId}</name>
     <description>The main module of Policy Api that handles startup, lifecycle management, and parameters.</description>
+
     <dependencies>
         <dependency>
             <groupId>org.onap.policy.models</groupId>
             <artifactId>spring-utils</artifactId>
             <version>${policy.common.version}</version>
         </dependency>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.assertj</groupId>
-            <artifactId>assertj-core</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.onap.policy.common</groupId>
             <artifactId>utils-test</artifactId>
             <version>${policy.common.version}</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.junit.vintage</groupId>
-            <artifactId>junit-vintage-engine</artifactId>
-            <scope>test</scope>
-        </dependency>
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-            <!-- Exclude the default Jackson dependency -->
-            <exclusions>
-                <exclusion>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-starter-json</artifactId>
-                </exclusion>
-            </exclusions>
+            <artifactId>spring-boot-starter-tomcat</artifactId>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
         </dependency>
         <dependency>
             <groupId>org.springdoc</groupId>
-            <artifactId>springdoc-openapi-ui</artifactId>
+            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
         </dependency>
         <dependency>
             <groupId>io.micrometer</groupId>
             <artifactId>micrometer-registry-prometheus</artifactId>
-            <version>${version.io.micrometer}</version>
             <scope>runtime</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-junit-jupiter</artifactId>
+        </dependency>
     </dependencies>
     <build>
         <resources>
                             </importMappings>
                             <configOptions>
                                 <sourceFolder>src/gen/java</sourceFolder>
-                                <dateLibrary>java11</dateLibrary>
+                                <dateLibrary>java17</dateLibrary>
                                 <interfaceOnly>true</interfaceOnly>
                                 <useTags>true</useTags>
+                                <jakarta>true</jakarta>
                             </configOptions>
                         </configuration>
                     </execution>
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${version.springboot}</version>
                 <executions>
                     <execution>
                         <goals>
index bd55344..2d0a228 100644 (file)
@@ -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,7 +21,7 @@
 
 package org.onap.policy.api.main.config;
 
-import javax.servlet.Filter;
+import jakarta.servlet.Filter;
 import org.onap.policy.api.main.rest.aaf.AafApiFilter;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
@@ -34,4 +35,4 @@ public class PolicyApiAafConfig {
     public Filter aafFilter() {
         return new AafApiFilter();
     }
-}
\ No newline at end of file
+}
index c2c40ff..802d37c 100644 (file)
@@ -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.
@@ -26,15 +27,14 @@ import lombok.Setter;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;
 
+@Getter
 @Component
 @ConfigurationProperties("policy-preload")
 public class PolicyPreloadConfig {
 
-    @Getter
     @Setter
     List<String> policyTypes;
 
-    @Getter
     @Setter
     List<String> policies;
-}
\ No newline at end of file
+}
index 231456d..074675b 100644 (file)
@@ -23,7 +23,9 @@ package org.onap.policy.api.main.config;
 
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.Customizer;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
 import org.springframework.security.web.SecurityFilterChain;
 
 /**
@@ -31,6 +33,7 @@ import org.springframework.security.web.SecurityFilterChain;
  */
 @Configuration
 public class SecurityConfig {
+
     /**
      * Return the configuration of how access to this module's REST end points is secured.
      *
@@ -40,11 +43,9 @@ public class SecurityConfig {
     @Bean
     public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
         http
-            .httpBasic()
-            .and()
-            .authorizeHttpRequests().anyRequest().authenticated()
-            .and()
-            .csrf().disable();
+            .httpBasic(Customizer.withDefaults())
+            .authorizeHttpRequests(authorize -> authorize.anyRequest().authenticated())
+            .csrf(AbstractHttpConfigurer::disable);
         return http.build();
     }
-}
\ No newline at end of file
+}
index ffc0edf..42e07d6 100644 (file)
@@ -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,7 +21,6 @@
 
 package org.onap.policy.api.main.config;
 
-import java.util.Arrays;
 import java.util.List;
 import org.onap.policy.api.main.config.converter.StringToEnumConverter;
 import org.onap.policy.common.spring.utils.YamlHttpMessageConverter;
@@ -43,7 +43,7 @@ public class WebConfig implements WebMvcConfigurer {
     @Override
     public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
         var yamlConverter = new YamlHttpMessageConverter();
-        yamlConverter.setSupportedMediaTypes(Arrays.asList(MediaType.parseMediaType("application/yaml")));
+        yamlConverter.setSupportedMediaTypes(List.of(MediaType.parseMediaType("application/yaml")));
         converters.add(yamlConverter);
     }
 }
index 580ba33..b536439 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. 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.
 
 package org.onap.policy.api.main.exception;
 
+import java.io.Serial;
+
 /**
  * This exception will be called if an error occurs in policy api external service.
  */
 public class PolicyApiException extends Exception {
+    @Serial
     private static final long serialVersionUID = -8507246953751956974L;
 
     /**
@@ -48,7 +52,7 @@ public class PolicyApiException extends Exception {
      * Instantiates a new policy api exception with a message and a caused by exception.
      *
      * @param message the message
-     * @param exp the exception that caused this exception to be thrown
+     * @param exp     the exception that caused this exception to be thrown
      */
     public PolicyApiException(final String message, final Exception exp) {
         super(message, exp);
index 19bf5e1..d4140d4 100644 (file)
@@ -1,7 +1,8 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- *  Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications 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.
@@ -21,6 +22,7 @@
 
 package org.onap.policy.api.main.exception;
 
+import java.io.Serial;
 import java.util.UUID;
 import lombok.Getter;
 import org.onap.policy.models.errors.concepts.ErrorResponse;
@@ -28,13 +30,13 @@ import org.onap.policy.models.errors.concepts.ErrorResponse;
 /**
  * This runtime exception will be called if a runtime error occurs when using policy api.
  */
+@Getter
 public class PolicyApiRuntimeException extends RuntimeException {
 
+    @Serial
     private static final long serialVersionUID = -8507246953751956974L;
 
-    @Getter
     private final UUID requestId;
-    @Getter
     private final ErrorResponse errorResponse;
 
     /**
index 93240df..4b60143 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2023 Bell Canada. All rights reserved.
+ * Copyright (C) 2022-2023 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,7 +21,7 @@
 
 package org.onap.policy.api.main.exception;
 
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.AfterThrowing;
 import org.aspectj.lang.annotation.Aspect;
index a1e6db2..b44e60f 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================\r
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.\r
  * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.\r
- * Modifications Copyright (C) 2020-2022 Nordix Foundation.\r
+ * Modifications Copyright (C) 2020-2023 Nordix Foundation.\r
  * Modifications Copyright (C) 2020-2023 Bell Canada. All rights reserved.\r
  * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
@@ -25,9 +25,9 @@
 \r
 package org.onap.policy.api.main.rest;\r
 \r
+import jakarta.ws.rs.core.Response.Status;\r
 import java.util.List;\r
 import java.util.UUID;\r
-import javax.ws.rs.core.Response.Status;\r
 import lombok.RequiredArgsConstructor;\r
 import org.onap.policy.api.main.exception.PolicyApiRuntimeException;\r
 import org.onap.policy.api.main.rest.genapi.PolicyDesignApi;\r
@@ -41,8 +41,6 @@ import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.base.PfModelRuntimeException;\r
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;\r
 import org.springframework.context.annotation.Profile;\r
-import org.springframework.http.HttpMethod;\r
-import org.springframework.http.HttpStatus;\r
 import org.springframework.http.ResponseEntity;\r
 import org.springframework.web.bind.annotation.RestController;\r
 \r
@@ -56,12 +54,6 @@ import org.springframework.web.bind.annotation.RestController;
 @Profile("default")\r
 public class ApiRestController extends CommonRestController implements PolicyDesignApi {\r
 \r
-    private enum Target {\r
-        POLICY,\r
-        POLICY_TYPE,\r
-        OTHER\r
-    }\r
-\r
     private final ToscaServiceTemplateService toscaServiceTemplateService;\r
     private final HealthCheckProvider healthCheckProvider;\r
 \r
@@ -96,13 +88,12 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Retrieves all versions of a particular policy type.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicyType(\r
-            String policyTypeId,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, null);\r
             return makeOkResponse(requestId, serviceTemplate);\r
@@ -116,15 +107,14 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Retrieves specified version of a particular policy type.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
-     * @param versionId the version of specified policy type\r
-     *\r
+     * @param versionId    the version of specified policy type\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicyType(\r
-            String policyTypeId,\r
-            String versionId,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        String versionId,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, versionId);\r
@@ -139,13 +129,12 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Retrieves latest version of a particular policy type.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicyType(\r
-            String policyTypeId,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchLatestPolicyTypes(policyTypeId);\r
             return makeOkResponse(requestId, serviceTemplate);\r
@@ -159,13 +148,12 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Creates a new policy type.\r
      *\r
      * @param body the body of policy type following TOSCA definition\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> createPolicyType(\r
-            ToscaServiceTemplate body,\r
-            UUID requestId) {\r
+        ToscaServiceTemplate body,\r
+        UUID requestId) {\r
         if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
             NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));\r
         }\r
@@ -182,15 +170,14 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Deletes specified version of a particular policy type.\r
      *\r
      * @param policyTypeId the ID of specified policy type\r
-     * @param versionId the version of specified policy type\r
-     *\r
+     * @param versionId    the version of specified policy type\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> deleteSpecificVersionOfPolicyType(\r
-            String policyTypeId,\r
-            String versionId,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        String versionId,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.deletePolicyType(policyTypeId, versionId);\r
@@ -204,17 +191,16 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves all versions of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getAllPolicies(\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, null, null, mode);\r
@@ -228,19 +214,18 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves all versions of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param policyId the ID of specified policy\r
-     *\r
+     * @param policyId          the ID of specified policy\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getAllVersionsOfPolicy(\r
-            String policyId,\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyId,\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null, mode);\r
@@ -255,21 +240,20 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves the specified version of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param policyId the ID of specified policy\r
-     * @param policyVersion the version of specified policy\r
-     *\r
+     * @param policyId          the ID of specified policy\r
+     * @param policyVersion     the version of specified policy\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getSpecificVersionOfPolicy(\r
-            String policyId,\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            String policyVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyId,\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        String policyVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService\r
                 .fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);\r
@@ -284,19 +268,18 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves the latest version of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param policyId the ID of specified policy\r
-     *\r
+     * @param policyId          the ID of specified policy\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getLatestVersionOfPolicy(\r
-            String policyId,\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyId,\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId, mode);\r
@@ -311,18 +294,17 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Creates a new policy for a particular policy type and version.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param body the body of policy following TOSCA definition\r
-     *\r
+     * @param body              the body of policy following TOSCA definition\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> createPolicy(\r
-            String policyTypeId,\r
-            String policyTypeVersion,\r
-            ToscaServiceTemplate body,\r
-            UUID requestId) {\r
+        String policyTypeId,\r
+        String policyTypeVersion,\r
+        ToscaServiceTemplate body,\r
+        UUID requestId) {\r
         if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {\r
             NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,\r
                 "/policytypes/" + policyTypeId + "/versions/" + policyTypeVersion + "/policies", toJson(body));\r
@@ -340,11 +322,10 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Deletes the specified version of a particular policy.\r
      *\r
-     * @param policyTypeId the ID of specified policy type\r
+     * @param policyTypeId      the ID of specified policy type\r
      * @param policyTypeVersion the version of specified policy type\r
-     * @param policyId the ID of specified policy\r
-     * @param policyVersion the version of specified policy\r
-     *\r
+     * @param policyId          the ID of specified policy\r
+     * @param policyVersion     the version of specified policy\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
@@ -372,8 +353,8 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getPolicies(\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicies(null, null, null, null, mode);\r
@@ -391,17 +372,16 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Retrieves the specified version of a particular policy.\r
      *\r
-     * @param policyId the Name of specified policy\r
+     * @param policyId      the Name of specified policy\r
      * @param policyVersion the version of specified policy\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
     public ResponseEntity<ToscaServiceTemplate> getSpecificPolicy(\r
-            String policyId,\r
-            String policyVersion,\r
-            PolicyFetchMode mode,\r
-            UUID requestId) {\r
+        String policyId,\r
+        String policyVersion,\r
+        PolicyFetchMode mode,\r
+        UUID requestId) {\r
         try {\r
             ToscaServiceTemplate serviceTemplate =\r
                 toscaServiceTemplateService.fetchPolicies(null, null, policyId, policyVersion, mode);\r
@@ -416,7 +396,6 @@ public class ApiRestController extends CommonRestController implements PolicyDes
      * Creates one or more new policies in one call.\r
      *\r
      * @param body the body of policy following TOSCA definition\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
@@ -438,9 +417,8 @@ public class ApiRestController extends CommonRestController implements PolicyDes
     /**\r
      * Deletes the specified version of a particular policy.\r
      *\r
-     * @param policyId the ID of specified policy\r
+     * @param policyId      the ID of specified policy\r
      * @param policyVersion the version of specified policy\r
-     *\r
      * @return the Response object containing the results of the API operation\r
      */\r
     @Override\r
index ef288e4..eadd8d3 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================\r
  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.\r
  * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.\r
- * Modifications Copyright (C) 2022 Nordix Foundation.\r
+ * Modifications Copyright (C) 2022-2023 Nordix Foundation.\r
  * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -24,6 +24,7 @@
 \r
 package org.onap.policy.api.main.rest;\r
 \r
+import java.util.Objects;\r
 import java.util.UUID;\r
 import org.onap.policy.api.main.exception.PolicyApiRuntimeException;\r
 import org.onap.policy.common.utils.coder.Coder;\r
@@ -107,12 +108,10 @@ public class CommonRestController {
      * @return the response builder, with version logging\r
      */\r
     public static ResponseEntity.BodyBuilder addLoggingHeaders(ResponseEntity.BodyBuilder respBuilder, UUID requestId) {\r
-        if (requestId == null) {\r
-            // Generate a random uuid if client does not embed requestId in rest request\r
-            return respBuilder.header(REQUEST_ID_NAME, UUID.randomUUID().toString());\r
-        }\r
+        // Generate a random uuid if client does not embed requestId in rest request\r
+        return respBuilder.header(REQUEST_ID_NAME,\r
+            Objects.requireNonNullElseGet(requestId, UUID::randomUUID).toString());\r
 \r
-        return respBuilder.header(REQUEST_ID_NAME, requestId.toString());\r
     }\r
 \r
     /**\r
index 38fe003..49c9bf4 100644 (file)
@@ -21,8 +21,8 @@
 
 package org.onap.policy.api.main.rest.stub;
 
+import jakarta.validation.Valid;
 import java.util.UUID;
-import javax.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import org.onap.policy.api.main.rest.CommonRestController;
 import org.onap.policy.api.main.rest.PolicyFetchMode;
@@ -42,7 +42,7 @@ public class ApiRestControllerStub extends CommonRestController implements Polic
 
     @Override
     public ResponseEntity<ToscaServiceTemplate> createPolicies(
-            @Valid ToscaServiceTemplate body, UUID requestID) {
+        @Valid ToscaServiceTemplate body, UUID requestID) {
         return stubUtils.getStubbedResponse(ToscaServiceTemplate.class);
     }
 
@@ -57,15 +57,15 @@ public class ApiRestControllerStub extends CommonRestController implements Polic
 
     @Override
     public ResponseEntity<ToscaServiceTemplate> createPolicyType(
-            @Valid ToscaServiceTemplate body, UUID requestID) {
+        @Valid ToscaServiceTemplate body, UUID requestID) {
         return stubUtils.getStubbedResponse(ToscaServiceTemplate.class);
     }
 
     @Override
     public ResponseEntity<ToscaServiceTemplate> deleteSpecificPolicy(
-            String policyId,
-            String policyVersion,
-            UUID requestID) {
+        String policyId,
+        String policyVersion,
+        UUID requestID) {
         return stubUtils.getStubbedResponse(ToscaServiceTemplate.class);
     }
 
index 2e9f4a2..5045eb6 100644 (file)
@@ -20,9 +20,9 @@
 
 package org.onap.policy.api.main.rest.stub;
 
+import jakarta.validation.Valid;
 import java.util.List;
 import java.util.UUID;
-import javax.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import org.onap.policy.api.main.rest.CommonRestController;
 import org.onap.policy.api.main.rest.genapi.ToscaNodeTemplateDesignApi;
index 562ce56..62f091c 100644 (file)
 package org.onap.policy.api.main.rest.stub;
 
 import com.google.gson.Gson;
+import jakarta.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
 import java.util.List;
-import javax.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,7 +67,7 @@ class StubUtils {
             final var resource = new ClassPathResource(TOSCA_NODE_TEMPLATE_RESOURCE);
             try (var inputStream = resource.getInputStream()) {
                 final var string = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
-                var targetObject = Arrays.asList(JSON_TRANSLATOR.fromJson(string, clazz));
+                var targetObject = List.of(JSON_TRANSLATOR.fromJson(string, clazz));
                 return new ResponseEntity<>(targetObject, HttpStatus.OK);
             } catch (IOException e) {
                 log.error("Couldn't serialize response for content type application/json", e);
index b4eec37..620248d 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation. All rights reserved.
+ *  Copyright (C) 2022-2023 Nordix Foundation. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
 
 package org.onap.policy.api.main.service;
 
+import jakarta.ws.rs.core.Response;
 import java.util.Optional;
-import javax.ws.rs.core.Response;
 import lombok.NonNull;
 import lombok.RequiredArgsConstructor;
 import org.onap.policy.api.main.repository.NodeTemplateRepository;
index 0bac872..e9d84be 100644 (file)
@@ -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,9 +21,9 @@
 
 package org.onap.policy.api.main.service;
 
+import jakarta.ws.rs.core.Response;
 import java.util.List;
 import java.util.stream.Collectors;
-import javax.ws.rs.core.Response;
 import lombok.RequiredArgsConstructor;
 import org.onap.policy.api.main.repository.PdpGroupRepository;
 import org.onap.policy.models.base.PfModelRuntimeException;
index 2e8fc9e..9ec28d1 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2022 Bell Canada. All rights reserved.
- *  Modifications Copyright (C) 2022 Nordix Foundation.
+ *  Modifications Copyright (C) 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.
 
 package org.onap.policy.api.main.service;
 
+import jakarta.ws.rs.core.Response;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
-import javax.annotation.Nonnull;
-import javax.ws.rs.core.Response;
 import lombok.NonNull;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
@@ -119,12 +118,9 @@ public class ToscaServiceTemplateService {
         // append the incoming fragment to the DB TOSCA service template
         var dbServiceTemplateOpt = getDefaultJpaToscaServiceTemplateOpt();
         JpaToscaServiceTemplate serviceTemplateToWrite;
-        if (dbServiceTemplateOpt.isEmpty()) {
-            serviceTemplateToWrite = incomingServiceTemplate;
-        } else {
-            serviceTemplateToWrite =
-                ToscaServiceTemplateUtils.addFragment(dbServiceTemplateOpt.get(), incomingServiceTemplate);
-        }
+        serviceTemplateToWrite = dbServiceTemplateOpt.map(
+            jpaToscaServiceTemplate -> ToscaServiceTemplateUtils.addFragment(jpaToscaServiceTemplate,
+                incomingServiceTemplate)).orElse(incomingServiceTemplate);
 
         final var result = serviceTemplateToWrite.validate("service template");
         if (!result.isValid()) {
@@ -265,12 +261,9 @@ public class ToscaServiceTemplateService {
         // append the incoming fragment to the DB TOSCA service template
         var dbServiceTemplateOpt = getDefaultJpaToscaServiceTemplateOpt();
         JpaToscaServiceTemplate serviceTemplateToWrite;
-        if (dbServiceTemplateOpt.isEmpty()) {
-            serviceTemplateToWrite = incomingServiceTemplate;
-        } else {
-            serviceTemplateToWrite =
-                ToscaServiceTemplateUtils.addFragment(dbServiceTemplateOpt.get(), incomingServiceTemplate);
-        }
+        serviceTemplateToWrite = dbServiceTemplateOpt.map(
+            jpaToscaServiceTemplate -> ToscaServiceTemplateUtils.addFragment(jpaToscaServiceTemplate,
+                incomingServiceTemplate)).orElse(incomingServiceTemplate);
 
         final var result = serviceTemplateToWrite.validate("Policies CRUD service template.");
         if (!result.isValid()) {
@@ -501,7 +494,7 @@ public class ToscaServiceTemplateService {
      * @return the TOSCA service template containing the node template that were deleted
      * @throws PfModelException on errors deleting node templates
      */
-    public ToscaServiceTemplate deleteToscaNodeTemplate(@NonNull final String name, @Nonnull final String version)
+    public ToscaServiceTemplate deleteToscaNodeTemplate(@NonNull final String name, @NonNull final String version)
         throws PfModelException {
         LOGGER.debug("->deleteToscaNodeTemplate: name={}, version={}", name, version);
 
index 55f49b1..edff300 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP Policy API
  * ================================================================================
  * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
  * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
 package org.onap.policy.api.main.startstop;
 
 import com.google.common.collect.Sets;
+import jakarta.annotation.PostConstruct;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import javax.annotation.PostConstruct;
 import lombok.RequiredArgsConstructor;
 import org.onap.policy.api.main.config.PolicyPreloadConfig;
 import org.onap.policy.api.main.exception.PolicyApiException;
index 43024ee..8adb850 100644 (file)
@@ -1,9 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
   ============LICENSE_START=======================================================
-   Copyright (C) 2019-2020 Nordix Foundation.
+   Copyright (C) 2019-2020, 2022-2023 Nordix Foundation.
    Modifications Copyright (C) 2021 AT&T Intellectual Property.
-   Modification Copyright 2022 Nordix Foundation.
    Modifications Copyright (C) 2023 Bell Canada. All rights reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -62,7 +61,7 @@
         <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
 
         <properties>
-            <property name="javax.persistence.schema-generation.database.action" value="none" />
+            <property name="jakarta.persistence.schema-generation.database.action" value="none" />
             <property name="eclipselink.ddl-generation" value="none" />
             <property name="eclipselink.logging.level" value="WARNING" />
         </properties>
index 305af94..42e0025 100644 (file)
@@ -72,4 +72,6 @@ management:
       base-path: /
       exposure:
         include: health,metrics,prometheus
-      path-mapping.prometheus: metrics
+      path-mapping:
+        -metrics: plain-metrics
+        -prometheus: metrics
index c8f44e5..6303b43 100644 (file)
@@ -1,7 +1,7 @@
 openapi: 3.0.1
 info:
   title: Policy Framework Lifecycle API
-  description: The Policy Fraemwork API allows the lifecycle of policy types and policyes to be managed
+  description: The Policy Framework API allows the lifecycle of policy types and policies to be managed
   contact:
     name: ONAP Support
     url: https://lists.onap.org/g/onap-discuss
index 3b90a10..08cb7f1 100644 (file)
@@ -23,11 +23,10 @@ package org.onap.policy.api.contract;
 
 import static org.junit.Assert.assertEquals;
 
+import jakarta.ws.rs.core.Response;
 import java.io.IOException;
-import javax.ws.rs.core.Response;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.policy.api.main.PolicyApiApplication;
 import org.onap.policy.api.main.rest.utils.CommonTestRestController;
 import org.onap.policy.common.utils.security.SelfSignedKeyStore;
@@ -38,25 +37,22 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.DynamicPropertyRegistry;
 import org.springframework.test.context.DynamicPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
 
-@RunWith(SpringRunner.class)
 @SpringBootTest(classes = PolicyApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles({ "test", "stub" })
+@ActiveProfiles({"test", "stub"})
 @DirtiesContext(classMode = ClassMode.AFTER_CLASS)
-public class ApiContractTest extends CommonTestRestController {
+class ApiContractTest extends CommonTestRestController {
     protected static final String APP_JSON = "application/json";
     protected static final String APP_YAML = "application/yaml";
     private static final String TOSCA_NODE_TEMPLATE_RESOURCE =
-            "nodetemplates/nodetemplates.metadatasets.input.tosca.json";
+        "nodetemplates/nodetemplates.metadatasets.input.tosca.json";
 
     @LocalServerPort
     private int apiPort;
 
     private static SelfSignedKeyStore keystore;
 
-
-    @BeforeClass
+    @BeforeAll
     public static void setupParameters() throws IOException, InterruptedException {
         keystore = new SelfSignedKeyStore();
     }
@@ -72,20 +68,20 @@ public class ApiContractTest extends CommonTestRestController {
     }
 
     @Test
-    public void testStubPolicyDesign() throws Exception {
+    void testStubPolicyDesign() throws Exception {
         checkStubJsonGet("policies");
         checkStubJsonGet("policies/policyname/versions/1.0.2");
         checkStubJsonGet("policytypes");
         checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16");
         checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/latest");
-        checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/");
+        checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0");
         checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies");
         checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies/"
             + "9c65fa1f-2833-4076-a64d-5b62e35cd09b");
         checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies/"
-                + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/latest");
+            + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/latest");
         checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies/"
-                + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/1.2.3");
+            + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/1.2.3");
         checkStubJsonGet("healthcheck");
 
         checkStubJsonPost("policies");
@@ -95,11 +91,11 @@ public class ApiContractTest extends CommonTestRestController {
         checkStubJsonDelete("policies/policyname/versions/1.0.2");
         checkStubJsonDelete("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0");
         checkStubJsonDelete("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies/"
-                + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/1.2.3");
+            + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/1.2.3");
     }
 
     @Test
-    public void testStubNodeTemplateDesign() throws Exception {
+    void testStubNodeTemplateDesign() throws Exception {
         checkStubJsonGet("nodetemplates");
         checkStubJsonGet("nodetemplates/k8stemplate/versions/1.0.0");
 
@@ -111,7 +107,7 @@ public class ApiContractTest extends CommonTestRestController {
     }
 
     @Test
-    public void testErrors() throws Exception {
+    void testErrors() throws Exception {
         var responseYaml = super.readResource("policies", APP_YAML, apiPort);
         assertEquals(Response.Status.NOT_IMPLEMENTED.getStatusCode(), responseYaml.getStatus());
 
index 1212517..47ca230 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP Policy API
  * ================================================================================
  * 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.
 
 package org.onap.policy.api.main.exception;
 
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 import org.onap.policy.common.utils.test.ExceptionsTester;
 
-public class TestPolicyApiException {
+class TestPolicyApiException {
 
     @Test
-    public void test() {
-        assertEquals(3, new ExceptionsTester().test(PolicyApiException.class));
+    void test() {
+        Assertions.assertEquals(3, new ExceptionsTester().test(PolicyApiException.class));
     }
 }
index 3e78ab2..9fa735b 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP Policy API
  * ================================================================================
  * 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.
 
 package org.onap.policy.api.main.exception;
 
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 import org.onap.policy.common.utils.test.ExceptionsTester;
 
-public class TestPolicyApiRuntimeException {
+class TestPolicyApiRuntimeException {
 
     @Test
-    public void test() {
-        assertEquals(2, new ExceptionsTester().test(PolicyApiRuntimeException.class));
+    void test() {
+        Assertions.assertEquals(2, new ExceptionsTester().test(PolicyApiRuntimeException.class));
     }
 }
index 7442a8c..4bcd86c 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
  *  Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- *  Modifications Copyright (C) 2019-2020,2022-2023 Nordix Foundation.
+ *  Modifications Copyright (C) 2019-2020, 2022-2023 Nordix Foundation.
  *  Modifications Copyright (C) 2020-2023 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
 package org.onap.policy.api.main.rest;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import jakarta.ws.rs.client.Invocation;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
 import java.io.File;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.policy.api.main.PolicyApiApplication;
 import org.onap.policy.api.main.rest.utils.CommonTestRestController;
 import org.onap.policy.common.endpoints.report.HealthCheckReport;
@@ -56,18 +55,16 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.DynamicPropertyRegistry;
 import org.springframework.test.context.DynamicPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
 
 /**
  * Class to perform unit test of {@link ApiRestController}.
  *
  * @author Chenfei Gao (cgao@research.att.com)
  */
-@RunWith(SpringRunner.class)
 @SpringBootTest(classes = PolicyApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @ActiveProfiles({ "test", "default" })
 @DirtiesContext(classMode = ClassMode.AFTER_CLASS)
-public class TestApiRestServer extends CommonTestRestController {
+class TestApiRestServer extends CommonTestRestController {
 
     private static final String ALIVE = "alive";
     private static final String SELF = NetworkUtil.getHostname();
@@ -161,8 +158,8 @@ public class TestApiRestServer extends CommonTestRestController {
      * @throws IOException on I/O exceptions
      * @throws InterruptedException if interrupted
      */
-    @BeforeClass
-    public static void setupParameters() throws IOException, InterruptedException {
+    @BeforeAll
+    static void setupParameters() throws IOException, InterruptedException {
         keystore = new SelfSignedKeyStore();
     }
 
@@ -177,12 +174,12 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testSwagger() throws Exception {
+    void testSwagger() throws Exception {
         super.testSwagger(apiPort);
     }
 
     @Test
-    public void testCreatePolicyTypes() throws Exception {
+    void testCreatePolicyTypes() throws Exception {
         for (String resrcName : TOSCA_POLICYTYPE_RESOURCE_NAMES) {
             Response rawResponse = createResource(POLICYTYPES, resrcName, apiPort);
             assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
@@ -204,7 +201,7 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testCreatePolicies() throws Exception {
+    void testCreatePolicies() throws Exception {
         for (String resrcName : TOSCA_POLICY_RESOURCE_NAMES) {
             Response rawResponse = createResource(POLICYTYPES_TCA_POLICIES, resrcName, apiPort);
             assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
@@ -229,7 +226,7 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testSimpleCreatePolicies() throws Exception {
+    void testSimpleCreatePolicies() throws Exception {
         for (String resrcName : TOSCA_POLICIES_RESOURCE_NAMES) {
             Response rawResponse = createResource(POLICIES, resrcName, apiPort);
             assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
@@ -255,7 +252,7 @@ public class TestApiRestServer extends CommonTestRestController {
 
     @SuppressWarnings("unchecked")
     @Test
-    public void testToscaCompliantOpDroolsPolicies() throws Exception {
+    void testToscaCompliantOpDroolsPolicies() throws Exception {
         Response rawResponse = createResource(POLICYTYPES, TOSCA_POLICYTYPE_OP_RESOURCE, apiPort);
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
 
@@ -306,29 +303,29 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testHealthCheckSuccessJson() throws Exception {
+    void testHealthCheckSuccessJson() throws Exception {
         testHealthCheckSuccess(APP_JSON);
     }
 
     @Test
-    public void testHealthCheckSuccessYaml() throws Exception {
+    void testHealthCheckSuccessYaml() throws Exception {
         testHealthCheckSuccess(APP_YAML);
     }
 
     private void testHealthCheckSuccess(String mediaType) throws Exception {
         final Invocation.Builder invocationBuilder = sendHttpsRequest(
-                CONTEXT_PATH, HEALTHCHECK_ENDPOINT, mediaType, apiPort);
+                HEALTHCHECK_ENDPOINT, mediaType, apiPort);
         final HealthCheckReport report = invocationBuilder.get(HealthCheckReport.class);
         validateHealthCheckReport(NAME, SELF, true, 200, ALIVE, report);
     }
 
     @Test
-    public void testReadPolicyTypesJson() throws Exception {
+    void testReadPolicyTypesJson() throws Exception {
         testReadPolicyTypes(APP_JSON);
     }
 
     @Test
-    public void testReadPolicyTypesYaml() throws Exception {
+    void testReadPolicyTypesYaml() throws Exception {
         testReadPolicyTypes(APP_YAML);
     }
 
@@ -379,12 +376,12 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testDeletePolicyTypeJson() throws Exception {
+    void testDeletePolicyTypeJson() throws Exception {
         testDeletePolicyType(APP_JSON);
     }
 
     @Test
-    public void testDeletePolicyTypeYaml() throws Exception {
+    void testDeletePolicyTypeYaml() throws Exception {
         testDeletePolicyType(APP_YAML);
     }
 
@@ -410,12 +407,12 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testReadPoliciesJson() throws Exception {
+    void testReadPoliciesJson() throws Exception {
         testReadPolicies(APP_JSON);
     }
 
     @Test
-    public void testReadPoliciesYaml() throws Exception {
+    void testReadPoliciesYaml() throws Exception {
         testReadPolicies(APP_YAML);
     }
 
@@ -443,7 +440,7 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testNamingPolicyGet() throws Exception {
+    void testNamingPolicyGet() throws Exception {
 
         Response rawResponse = readResource("policytypes/onap.policies.Naming/versions/1.0.0/"
                 + "policies/SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP/versions/1.0.0", APP_JSON, apiPort);
@@ -507,12 +504,12 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testDeletePoliciesJson() throws Exception {
+    void testDeletePoliciesJson() throws Exception {
         testDeletePolicies(APP_JSON);
     }
 
     @Test
-    public void testDeletePoliciesYaml() throws Exception {
+    void testDeletePoliciesYaml() throws Exception {
         testDeletePolicies(APP_YAML);
     }
 
@@ -524,12 +521,12 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testDeletePolicyVersionJson() throws Exception {
+    void testDeletePolicyVersionJson() throws Exception {
         testDeletePolicyVersion(APP_JSON);
     }
 
     @Test
-    public void testDeletePolicyVersionYaml() throws Exception {
+    void testDeletePolicyVersionYaml() throws Exception {
         testDeletePolicyVersion(APP_YAML);
     }
 
@@ -565,12 +562,12 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testGetAllVersionOfPolicyJson() throws Exception {
+    void testGetAllVersionOfPolicyJson() throws Exception {
         testGetAllVersionOfPolicy(APP_JSON);
     }
 
     @Test
-    public void testGetAllVersionOfPolicyYaml() throws Exception {
+    void testGetAllVersionOfPolicyYaml() throws Exception {
         testGetAllVersionOfPolicy(APP_YAML);
     }
 
@@ -591,12 +588,12 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testGetPoliciesJson() throws Exception {
+    void testGetPoliciesJson() throws Exception {
         getPolicies(APP_JSON);
     }
 
     @Test
-    public void testGetPoliciesYaml() throws Exception {
+    void testGetPoliciesYaml() throws Exception {
         getPolicies(APP_YAML);
     }
 
@@ -619,12 +616,12 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testGetSpecificPolicyJson() throws Exception {
+    void testGetSpecificPolicyJson() throws Exception {
         getSpecificPolicy(APP_JSON);
     }
 
     @Test
-    public void testGetSpecificPolicyYaml() throws Exception {
+    void testGetSpecificPolicyYaml() throws Exception {
         getSpecificPolicy(APP_YAML);
     }
 
@@ -647,7 +644,7 @@ public class TestApiRestServer extends CommonTestRestController {
     }
 
     @Test
-    public void testDeleteSpecificPolicy() throws Exception {
+    void testDeleteSpecificPolicy() throws Exception {
         Response rawResponse;
         for (String resrcName : TOSCA_POLICYTYPE_RESOURCE_NAMES) {
             rawResponse = createResource(POLICYTYPES, resrcName, apiPort);
index 2213bbf..bf1d49b 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP Policy API
  * ================================================================================
  * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2023 Nordix Foundation.
  * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
 
 package org.onap.policy.api.main.rest;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
 import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 import org.springframework.http.ResponseEntity;
 
 /**
  * Class to perform unit testing of CommonRestController.
  */
-public class TestCommonRestController {
-    private CommonRestController crc = new CommonRestController();
+class TestCommonRestController {
+    private final CommonRestController crc = new CommonRestController();
 
     @Test
-    public void testAddLoggingHeaders() {
+    void testAddLoggingHeaders() {
         UUID requestId = UUID.randomUUID();
         ResponseEntity<Void> rb = crc.makeOkResponse(requestId, null);
-        assertEquals(requestId.toString(), rb.getHeaders().getFirst("X-ONAP-RequestID"));
+        Assertions.assertEquals(requestId.toString(), rb.getHeaders().getFirst("X-ONAP-RequestID"));
     }
 
     /*
      * Tests null response for null object
      */
     @Test
-    public void testToJsonNull() {
-        assertNull(crc.toJson(null));
+    void testToJsonNull() {
+        Assertions.assertNull(crc.toJson(null));
     }
 }
\ No newline at end of file
index c36fea1..8dd0d73 100644 (file)
 package org.onap.policy.api.main.rest;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.core.Response;
 import java.io.IOException;
 import java.util.List;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.Response;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.policy.api.main.PolicyApiApplication;
 import org.onap.policy.api.main.rest.utils.CommonTestRestController;
 import org.onap.policy.api.main.service.ToscaServiceTemplateService;
@@ -49,13 +48,11 @@ import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.DynamicPropertyRegistry;
 import org.springframework.test.context.DynamicPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
 
 /**
  * Class to perform unit test of {@link NodeTemplateController}.
  *
  */
-@RunWith(SpringRunner.class)
 @SpringBootTest(classes = PolicyApiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @ActiveProfiles({ "test", "default" })
 @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@@ -92,7 +89,7 @@ public class TestNodeTemplateController extends CommonTestRestController {
      * @throws IOException on I/O exceptions
      * @throws InterruptedException if interrupted
      */
-    @BeforeClass
+    @BeforeAll
     public static void setupParameters() throws IOException, InterruptedException {
         keystore = new SelfSignedKeyStore();
     }
@@ -101,7 +98,7 @@ public class TestNodeTemplateController extends CommonTestRestController {
      * Clean up the database.
      *
      */
-    @After
+    @AfterEach
     public void clearDb() {
         for (String name : nodeTemplateKeys) {
             try {
@@ -124,7 +121,7 @@ public class TestNodeTemplateController extends CommonTestRestController {
 
 
     @Test
-    public void testCreateToscaNodeTemplates() throws Exception {
+    void testCreateToscaNodeTemplates() throws Exception {
         Response rawResponse = createResource(NODE_TEMPLATES, TOSCA_NODE_TEMPLATE_RESOURCE, apiPort);
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
         ToscaServiceTemplate response = rawResponse.readEntity(ToscaServiceTemplate.class);
@@ -147,7 +144,7 @@ public class TestNodeTemplateController extends CommonTestRestController {
 
 
     @Test
-    public void testReadNodeTemplates() throws Exception {
+    void testReadNodeTemplates() throws Exception {
         Response rawResponse = readResource(NODE_TEMPLATES, APP_JSON, apiPort);
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
         List<?> nodeTemplates = rawResponse.readEntity(List.class);
@@ -172,7 +169,7 @@ public class TestNodeTemplateController extends CommonTestRestController {
     }
 
     @Test
-    public void testUpdateNodeTemplates() throws Exception {
+    void testUpdateNodeTemplates() throws Exception {
         createResource(NODE_TEMPLATES, TOSCA_NODE_TEMPLATE_RESOURCE, apiPort);
         Response rawResponse = updateResource(NODE_TEMPLATES, TOSCA_UPDATE_NODE_TEMPLATES, APP_JSON, apiPort);
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
@@ -197,7 +194,7 @@ public class TestNodeTemplateController extends CommonTestRestController {
     }
 
     @Test
-    public void testDeleteNodeTemplates() throws Exception {
+    void testDeleteNodeTemplates() throws Exception {
         createResource(NODE_TEMPLATES, TOSCA_NODE_TEMPLATE_RESOURCE, apiPort);
         Response rawResponse = deleteResource(SPECIFIC_NODE_TEMPLATE, APP_JSON, apiPort);
         assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
index 1852697..7246cdd 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP Policy API
  * ================================================================================
  * 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.
 
 package org.onap.policy.api.main.rest.aaf;
 
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
-import org.junit.Test;
-
-public class TestAafApiFilter {
-    private AafApiFilter aafApiFilter = new AafApiFilter();
+class TestAafApiFilter {
+    private final AafApiFilter aafApiFilter = new AafApiFilter();
 
     @Test
-    public void testGetPermissionTypeRoot() {
-        assertEquals("org.onap.policy.policy-api", aafApiFilter.getPermissionTypeRoot());
+    void testGetPermissionTypeRoot() {
+        Assertions.assertEquals("org.onap.policy.policy-api", aafApiFilter.getPermissionTypeRoot());
     }
 }
index 947ed6a..8e9bf70 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy API
  * ================================================================================
- * Copyright (C) 2022 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2022-2023 Nordix Foundation. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.policy.api.main.rest.utils;
 
-import static org.junit.Assert.assertTrue;
-
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.client.Invocation;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
 import java.security.SecureRandom;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManager;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
 import org.glassfish.jersey.client.ClientProperties;
 import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.junit.jupiter.api.Assertions;
 import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
 import org.onap.policy.common.gson.GsonMessageBodyHandler;
 import org.onap.policy.common.utils.coder.CoderException;
@@ -46,7 +45,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
 /**
  * Util class to perform REST unit tests.
- *
  */
 public class CommonTestRestController {
 
@@ -60,9 +58,10 @@ public class CommonTestRestController {
     protected static final String CONTEXT_PATH = "/policy/api/v1/";
 
     protected void testSwagger(final int apiPort) throws Exception {
-        final Invocation.Builder invocationBuilder = sendHttpsRequest(CONTEXT_PATH, "v3/api-docs", APP_JSON, apiPort);
+        final Invocation.Builder invocationBuilder = sendHttpsRequest("v3/api-docs", APP_JSON, apiPort);
         final String resp = invocationBuilder.get(String.class);
-        assertTrue((resp).contains("{\"openapi\":\"3.0.1\",\"info\":{\"title\":\"Policy Framework Lifecycle API\""));
+        Assertions.assertTrue(
+            (resp).contains("{\"openapi\":\"3.0.1\",\"info\":{\"title\":\"Policy Framework Lifecycle API\""));
     }
 
     protected Response createResource(String endpoint, String resourceName, int apiPort)
@@ -70,10 +69,10 @@ public class CommonTestRestController {
 
         ToscaServiceTemplate rawServiceTemplate = getRawServiceTemplate(resourceName);
         String mediaType = getMediaType(resourceName);
-        mediaType = mediaType == null ?  APP_JSON : mediaType;
+        mediaType = mediaType == null ? APP_JSON : mediaType;
 
         final Invocation.Builder invocationBuilder;
-        invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
+        invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
         Entity<ToscaServiceTemplate> entity = Entity.entity(rawServiceTemplate, mediaType);
         return invocationBuilder.post(entity);
     }
@@ -81,14 +80,14 @@ public class CommonTestRestController {
     protected Response readResource(String endpoint, String mediaType, int apiPort) throws Exception {
 
         final Invocation.Builder invocationBuilder;
-        invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
+        invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
         return invocationBuilder.get();
     }
 
     protected Response deleteResource(String endpoint, String mediaType, int apiPort) throws Exception {
 
         final Invocation.Builder invocationBuilder;
-        invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
+        invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
         return invocationBuilder.delete();
     }
 
@@ -98,7 +97,7 @@ public class CommonTestRestController {
         ToscaServiceTemplate rawServiceTemplate = getRawServiceTemplate(resourceName);
 
         final Invocation.Builder invocationBuilder;
-        invocationBuilder = sendHttpsRequest(CONTEXT_PATH, endpoint, mediaType, apiPort);
+        invocationBuilder = sendHttpsRequest(endpoint, mediaType, apiPort);
         Entity<ToscaServiceTemplate> entity = Entity.entity(rawServiceTemplate, mediaType);
         return invocationBuilder.put(entity);
     }
@@ -112,7 +111,7 @@ public class CommonTestRestController {
     }
 
     protected Invocation.Builder sendHttpsRequest(
-            final String context, final String endpoint, String mediaType, int apiPort) throws Exception {
+        final String endpoint, String mediaType, int apiPort) throws Exception {
 
         final TrustManager[] noopTrustManager = NetworkUtil.getAlwaysTrustingManager();
 
@@ -131,7 +130,7 @@ public class CommonTestRestController {
             client.register(YamlMessageBodyHandler.class);
         }
 
-        final WebTarget webTarget = client.target(HTTPS_PREFIX + apiPort + context + endpoint);
+        final WebTarget webTarget = client.target(HTTPS_PREFIX + apiPort + CONTEXT_PATH + endpoint);
 
         final Invocation.Builder invocationBuilder = webTarget.request(mediaType);
 
@@ -148,7 +147,7 @@ public class CommonTestRestController {
         } else if (APP_YAML.equals(getMediaType(resourceName))) {
             rawServiceTemplate = decodeYaml(resourceName);
         }
-        return  rawServiceTemplate;
+        return rawServiceTemplate;
     }
 
     private String getMediaType(String resourceName) {
index 4af3093..5c92bad 100644 (file)
@@ -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.
 package org.onap.policy.api.main.service;
 
 import java.util.Optional;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
 import org.mockito.Mock;
 import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
 import org.onap.policy.api.main.repository.ToscaServiceTemplateRepository;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -50,17 +53,20 @@ public class TestCommonToscaServiceTemplateService {
     @Mock
     protected NodeTemplateService nodeTemplateService;
 
+    AutoCloseable autoCloseable;
+
     /**
-     * Setup the DB TOSCA service template object post create, and delete request.
-     * @param dbSvcTemplate ToscaServiceTemplate object to update
+     * Set up the DB TOSCA service template object post create, and delete request.
+     *
+     * @param dbSvcTemplate       ToscaServiceTemplate object to update
      * @param svcTemplateFragment the CRUD operation response ToscaServiceTemplate object
-     * @param operation the CRUD operation performed
+     * @param operation           the CRUD operation performed
      */
     protected void mockDbServiceTemplate(ToscaServiceTemplate dbSvcTemplate, ToscaServiceTemplate svcTemplateFragment,
-        TestToscaServiceTemplateServiceForPolicyCrud.Operation operation) {
+                                         TestToscaServiceTemplateServiceForPolicyCrud.Operation operation) {
         if (operation != null) {
             switch (operation) {
-                case CREATE_POLICY_TYPE:
+                case CREATE_POLICY_TYPE -> {
                     dbSvcTemplate.getPolicyTypes().putAll(svcTemplateFragment.getPolicyTypes());
                     if (svcTemplateFragment.getDataTypes() != null) {
                         if (dbSvcTemplate.getDataTypes() == null) {
@@ -69,18 +75,14 @@ public class TestCommonToscaServiceTemplateService {
                             dbSvcTemplate.getDataTypes().putAll(svcTemplateFragment.getDataTypes());
                         }
                     }
-                    break;
-                case DELETE_POLICY_TYPE:
+                }
+                case DELETE_POLICY_TYPE ->
                     dbSvcTemplate.getPolicyTypes().keySet().removeAll(svcTemplateFragment.getPolicyTypes().keySet());
-                    break;
-                case CREATE_POLICY:
+                case CREATE_POLICY ->
                     dbSvcTemplate.setToscaTopologyTemplate(svcTemplateFragment.getToscaTopologyTemplate());
-                    break;
-                case DELETE_POLICY:
-                    dbSvcTemplate.getToscaTopologyTemplate().setPolicies(null);
-                    break;
-                default:
-                    break;
+                case DELETE_POLICY -> dbSvcTemplate.getToscaTopologyTemplate().setPolicies(null);
+                default -> {
+                }
             }
         }
         Mockito.when(toscaServiceTemplateRepository.findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME,
@@ -91,9 +93,15 @@ public class TestCommonToscaServiceTemplateService {
     /**
      * Setup to return empty DB service template.
      */
-    @Before
+    @BeforeEach
     public void setUp() {
+        autoCloseable = MockitoAnnotations.openMocks(this);
         Mockito.when(toscaServiceTemplateRepository.findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME,
             JpaToscaServiceTemplate.DEFAULT_VERSION))).thenReturn(Optional.of(new JpaToscaServiceTemplate()));
     }
+
+    @AfterEach
+    public void tearDown() throws Exception {
+        autoCloseable.close();
+    }
 }
\ No newline at end of file
index 7d85eef..265f527 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy API
  * ================================================================================
- * Copyright (C) 2022 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2022-2023 Nordix Foundation. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,13 +27,13 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 
 import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
 import org.onap.policy.api.main.repository.NodeTemplateRepository;
 import org.onap.policy.api.main.repository.NodeTypeRepository;
 import org.onap.policy.common.utils.coder.CoderException;
@@ -41,14 +41,12 @@ import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.coder.YamlJsonTranslator;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
 import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeType;
 import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
 
-@RunWith(MockitoJUnitRunner.class)
-public class TestNodeTemplateService {
+class TestNodeTemplateService {
 
     @Mock
     private NodeTemplateRepository nodeTemplateRepository;
@@ -63,17 +61,20 @@ public class TestNodeTemplateService {
     private static final String UPDATED_NODE_TEMPLATE_JSON = "nodetemplates/nodetemplates.metadatasets.update.json";
 
     private static ToscaServiceTemplate updatedToscaServiceTemplate;
-    private StandardCoder standardCoder;
-    private YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator();
+    private final YamlJsonTranslator yamlJsonTranslator = new YamlJsonTranslator();
     ToscaServiceTemplate policyServiceTemplate;
 
+    AutoCloseable closeable;
+
     /**
      * Set up for tests.
+     *
      * @throws CoderException if error in json parsing
      */
-    @Before
+    @BeforeEach
     public void setUp() throws CoderException {
-        standardCoder = new StandardCoder();
+        closeable = MockitoAnnotations.openMocks(this);
+        StandardCoder standardCoder = new StandardCoder();
         policyServiceTemplate =
             yamlJsonTranslator.fromYaml(ResourceUtils.getResourceAsString(POLICY_WITH_METADATA_SET_REF),
                 ToscaServiceTemplate.class);
@@ -82,11 +83,15 @@ public class TestNodeTemplateService {
                 ToscaServiceTemplate.class);
     }
 
+    @AfterEach
+    void tearDown() throws Exception {
+        closeable.close();
+    }
+
     @Test
-    public void testVerifyNodeType() {
-        assertThatThrownBy(() -> {
-            nodeTemplateService.verifyNodeTypeInDbTemplate(new JpaToscaNodeTemplate());
-        }).hasMessageMatching("^NODE_TYPE .* for toscaNodeTemplate .* does not exist$");
+    void testVerifyNodeType() {
+        assertThatThrownBy(() -> nodeTemplateService.verifyNodeTypeInDbTemplate(new JpaToscaNodeTemplate()))
+            .hasMessageMatching("^NODE_TYPE .* for toscaNodeTemplate .* does not exist$");
 
         JpaToscaNodeTemplate jpaToscaNodeTemplate = new JpaToscaNodeTemplate();
         PfConceptKey nodeType = new PfConceptKey("dummyType", "1.0.0");
@@ -97,19 +102,19 @@ public class TestNodeTemplateService {
     }
 
     @Test
-    public void testNodeTemplateUsedInPolicy() {
+    void testNodeTemplateUsedInPolicy() {
         assertDoesNotThrow(() -> nodeTemplateService.assertNodeTemplateNotUsedInPolicy("dummyName", "1.0.0",
             new JpaToscaServiceTemplate(policyServiceTemplate)));
 
-        assertThatThrownBy(() -> {
-            nodeTemplateService.assertNodeTemplateNotUsedInPolicy("apexMetadata_decisionMaker", "1.0.0",
-                new JpaToscaServiceTemplate(policyServiceTemplate));
-        }).hasMessage("Node template is in use, it is referenced in Tosca Policy operational.apex.decisionMaker "
-            + "version 1.0.0");
+        assertThatThrownBy(() -> nodeTemplateService
+            .assertNodeTemplateNotUsedInPolicy("apexMetadata_decisionMaker", "1.0.0",
+                new JpaToscaServiceTemplate(policyServiceTemplate)))
+            .hasMessage("Node template is in use, it is referenced in Tosca Policy operational.apex.decisionMaker "
+                + "version 1.0.0");
     }
 
     @Test
-    public void testNodeTemplateUpdate() throws PfModelException {
+    void testNodeTemplateUpdate() {
 
         Mockito.when(nodeTypeRepository.findById(Mockito.any())).thenReturn(Optional.of(new JpaToscaNodeType()));
         Mockito.when(nodeTemplateRepository.findById(Mockito.any())).thenReturn(Optional.of(
index 4c04a08..d46592f 100644 (file)
@@ -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.
@@ -26,12 +27,12 @@ import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
 import org.onap.policy.api.main.repository.PdpGroupRepository;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
@@ -39,8 +40,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.pdp.concepts.PdpGroups;
 import org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup;
 
-@RunWith(MockitoJUnitRunner.class)
-public class TestPdpGroupService {
+class TestPdpGroupService {
 
     @Mock
     private PdpGroupRepository pdpGroupRepository;
@@ -48,12 +48,16 @@ public class TestPdpGroupService {
     @InjectMocks
     private PdpGroupService pdpGroupService;
 
+    AutoCloseable closeable;
+
     /**
      * Test setup.
+     *
      * @throws CoderException decode errors
      */
-    @Before
+    @BeforeEach
     public void setUp() throws CoderException {
+        closeable = MockitoAnnotations.openMocks(this);
         var pdpGroups = new StandardCoder().decode(ResourceUtils.getResourceAsString("pdpgroups/PdpGroups.json"),
             PdpGroups.class).getGroups();
         List<JpaPdpGroup> jpaPdpGroupList = new ArrayList<>();
@@ -62,8 +66,13 @@ public class TestPdpGroupService {
         when(pdpGroupRepository.findAll()).thenReturn(jpaPdpGroupList);
     }
 
+    @AfterEach
+    void tearDown() throws Exception {
+        closeable.close();
+    }
+
     @Test
-    public void testAssertPolicyTypeNotSupportedInPdpGroup() {
+    void testAssertPolicyTypeNotSupportedInPdpGroup() {
         assertThatCode(() -> pdpGroupService.assertPolicyTypeNotSupportedInPdpGroup("policy_type_not_supported",
             "1.0.0")).doesNotThrowAnyException();
 
@@ -73,7 +82,7 @@ public class TestPdpGroupService {
     }
 
     @Test
-    public void testAssertPolicyNotDeployedInPdpGroup() {
+    void testAssertPolicyNotDeployedInPdpGroup() {
         assertThatCode(() -> pdpGroupService.assertPolicyNotDeployedInPdpGroup("policy_not_deployed", "1.0.0"))
             .doesNotThrowAnyException();
 
index f9baf76..6820ad3 100644 (file)
@@ -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.
@@ -22,26 +23,37 @@ package org.onap.policy.api.main.service;
 
 import static org.assertj.core.api.Assertions.assertThatCode;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
 import org.onap.policy.api.main.repository.PolicyRepository;
 import org.onap.policy.models.base.PfConceptKey;
 
-@RunWith(MockitoJUnitRunner.class)
-public class TestPolicyService {
+class TestPolicyService {
 
     @Mock
     private PolicyRepository policyRepository;
 
-    @InjectMocks
+    @Mock
     private PolicyService policyService;
 
+    AutoCloseable autoCloseable;
+
+    @BeforeEach
+    void before() {
+        autoCloseable = MockitoAnnotations.openMocks(this);
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        autoCloseable.close();
+    }
+
     @Test
-    public void testDeletePolicy() {
+    void testDeletePolicy() {
         PfConceptKey id = new PfConceptKey("dummy", "1.0.0");
         Mockito.doNothing().when(policyRepository).deleteById(id);
         assertThatCode(() -> policyService.deletePolicy(id)).doesNotThrowAnyException();
index 21f1ba4..278d597 100644 (file)
@@ -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.
@@ -22,17 +23,17 @@ package org.onap.policy.api.main.service;
 
 import static org.assertj.core.api.Assertions.assertThatCode;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
 import org.onap.policy.api.main.repository.PolicyTypeRepository;
 import org.onap.policy.models.base.PfConceptKey;
 
-@RunWith(MockitoJUnitRunner.class)
-public class TestPolicyTypeService {
+class TestPolicyTypeService {
 
     @Mock
     private PolicyTypeRepository policyTypeRepository;
@@ -40,8 +41,20 @@ public class TestPolicyTypeService {
     @InjectMocks
     private PolicyTypeService policyTypeService;
 
+    AutoCloseable closeable;
+
+    @BeforeEach
+    public void setUp() {
+        closeable = MockitoAnnotations.openMocks(this);
+    }
+
+    @AfterEach
+    void tearDown() throws Exception {
+        closeable.close();
+    }
+
     @Test
-    public void testDeletePolicy() {
+    void testDeletePolicy() {
         PfConceptKey id = new PfConceptKey("dummy", "1.0.0");
         Mockito.doNothing().when(policyTypeRepository).deleteById(id);
         assertThatCode(() -> policyTypeService.deletePolicyType(id)).doesNotThrowAnyException();
index 8f8fc46..fee7f40 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy API
  * ================================================================================
- * Copyright (C) 2022 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2022-2023 Nordix Foundation. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,16 +24,14 @@ package org.onap.policy.api.main.service;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;
-import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -42,20 +40,17 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
 
-@RunWith(MockitoJUnitRunner.class)
-public class TestToscaServiceTemplateForNodeTemplate extends TestCommonToscaServiceTemplateService {
+class TestToscaServiceTemplateForNodeTemplate extends TestCommonToscaServiceTemplateService {
 
     private static final String NODE_TEMPLATES_JSON = "nodetemplates/nodetemplates.metadatasets.input.tosca.json";
     private static final String UPDATED_NODE_TEMPLATE_JSON = "nodetemplates/nodetemplates.metadatasets.update.json";
     private static ToscaServiceTemplate toscaServiceTemplate;
     private static ToscaServiceTemplate updatedToscaServiceTemplate;
-    private StandardCoder standardCoder;
 
     @InjectMocks
     private ToscaServiceTemplateService toscaServiceTemplateService;
 
-
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
     }
@@ -65,9 +60,9 @@ public class TestToscaServiceTemplateForNodeTemplate extends TestCommonToscaServ
      *
      * @throws CoderException when error parsing the json
      */
-    @Before
-    public void fetchToscaNodeTemplateJson() throws CoderException {
-        standardCoder = new StandardCoder();
+    @BeforeEach
+    void fetchToscaNodeTemplateJson() throws CoderException {
+        StandardCoder standardCoder = new StandardCoder();
         toscaServiceTemplate =
             standardCoder.decode(ResourceUtils.getResourceAsString(NODE_TEMPLATES_JSON), ToscaServiceTemplate.class);
         updatedToscaServiceTemplate =
@@ -76,7 +71,7 @@ public class TestToscaServiceTemplateForNodeTemplate extends TestCommonToscaServ
     }
 
     @Test
-    public void testToscaNodeTemplatesGet() throws Exception {
+    void testToscaNodeTemplatesGet() throws Exception {
 
         assertNotNull(toscaServiceTemplate);
         var createdTemplate = toscaServiceTemplateService.createToscaNodeTemplates(toscaServiceTemplate);
@@ -99,11 +94,10 @@ public class TestToscaServiceTemplateForNodeTemplate extends TestCommonToscaServ
     }
 
     @Test
-    public void testToscaNodeTemplatesCreate() throws Exception {
+    void testToscaNodeTemplatesCreate() throws Exception {
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.createToscaNodeTemplates(null);
-        }).hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
+        assertThatThrownBy(() -> toscaServiceTemplateService.createToscaNodeTemplates(null))
+            .hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
 
         ToscaServiceTemplate createdNodeTemplates =
             toscaServiceTemplateService.createToscaNodeTemplates(toscaServiceTemplate);
@@ -113,11 +107,10 @@ public class TestToscaServiceTemplateForNodeTemplate extends TestCommonToscaServ
     }
 
     @Test
-    public void testToscaNodeTemplateUpdate() throws Exception {
+    void testToscaNodeTemplateUpdate() throws Exception {
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.updateToscaNodeTemplates(null);
-        }).hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
+        assertThatThrownBy(() -> toscaServiceTemplateService.updateToscaNodeTemplates(null))
+            .hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
 
         JpaToscaNodeTemplate jpaNodeTemplate = new JpaToscaNodeTemplate();
         PfConceptKey key = new PfConceptKey("apexMetadata_grpc", "1.0.0");
@@ -131,21 +124,18 @@ public class TestToscaServiceTemplateForNodeTemplate extends TestCommonToscaServ
     }
 
     @Test
-    public void testToscaNodeTemplateDelete() throws Exception {
+    void testToscaNodeTemplateDelete() throws Exception {
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.deleteToscaNodeTemplate(null, null);
-        }).hasMessageMatching("^name is marked .*on.*ull but is null$");
+        assertThatThrownBy(() -> toscaServiceTemplateService.deleteToscaNodeTemplate(null, null))
+            .hasMessageMatching("^name is marked .*on.*ull but is null$");
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.deleteToscaNodeTemplate("name", null);
-        }).hasMessageMatching("^version is marked .*on.*ull but is null$");
+        assertThatThrownBy(() -> toscaServiceTemplateService.deleteToscaNodeTemplate("name", null))
+            .hasMessageMatching("^version is marked .*on.*ull but is null$");
 
         var createdTemplate = toscaServiceTemplateService.createToscaNodeTemplates(toscaServiceTemplate);
         mockDbServiceTemplate(createdTemplate, null, null);
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.deleteToscaNodeTemplate("dummyname", "1.0.1");
-        }).hasMessage("node template dummyname:1.0.1 not found");
+        assertThatThrownBy(() -> toscaServiceTemplateService.deleteToscaNodeTemplate("dummyname", "1.0.1"))
+            .hasMessage("node template dummyname:1.0.1 not found");
 
         ToscaServiceTemplate responseTemplate =
             toscaServiceTemplateService.deleteToscaNodeTemplate("apexMetadata_decisionMaker", "1.0.0");
index 6986428..14d9056 100644 (file)
@@ -3,8 +3,8 @@
  * ONAP Policy API
  * ================================================================================
  * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2020,2022 Bell Canada.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022 Bell Canada.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,24 +27,21 @@ package org.onap.policy.api.main.service;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
+import jakarta.ws.rs.core.Response;
 import java.util.Optional;
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.coder.StandardYamlCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.base.PfModelRuntimeException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
@@ -54,11 +51,10 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
  *
  * @author Chenfei Gao (cgao@research.att.com)
  */
-@RunWith(MockitoJUnitRunner.class)
-public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonToscaServiceTemplateService {
+class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonToscaServiceTemplateService {
 
-    private static StandardCoder standardCoder = new StandardCoder();
-    private static StandardYamlCoder standardYamlCoder = new StandardYamlCoder();
+    private static final StandardCoder standardCoder = new StandardCoder();
+    private static final StandardYamlCoder standardYamlCoder = new StandardYamlCoder();
 
     private static final String POLICY_RESOURCE = "policies/vCPE.policy.monitoring.input.tosca.json";
     private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policies.monitoring.tcagen2.yaml";
@@ -83,48 +79,43 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
     @InjectMocks
     private ToscaServiceTemplateService toscaServiceTemplateService;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
     }
 
     @Test
-    public void testFetchPolicies() {
+    void testFetchPolicies() {
         Mockito.when(toscaServiceTemplateRepository.findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME,
             JpaToscaServiceTemplate.DEFAULT_VERSION))).thenReturn(Optional.empty());
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", null, null, null);
-        }).hasMessage("service template not found in database");
+        assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", null, null, null))
+            .hasMessage("service template not found in database");
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", "dummy", null, null);
-        }).hasMessage("service template not found in database");
+        assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", "dummy", null, null))
+            .hasMessage("service template not found in database");
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", "dummy", "1.0.0", null);
-        }).hasMessage("service template not found in database");
+        assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicies("dummy", "1.0.0", "dummy", "1.0.0", null))
+            .hasMessage("service template not found in database");
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.fetchPolicies(null, null, "dummy", "1.0.0", null);
-        }).hasMessage("service template not found in database");
+        assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicies(null, null, "dummy", "1.0.0", null))
+            .hasMessage("service template not found in database");
     }
 
     @Test
-    public void testFetchLatestPolicies() {
+    void testFetchLatestPolicies() {
         Mockito.when(toscaServiceTemplateRepository.findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME,
             JpaToscaServiceTemplate.DEFAULT_VERSION))).thenReturn(Optional.empty());
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.fetchLatestPolicies("dummy", "dummy", "dummy", null);
-        }).hasMessage("service template not found in database");
+        assertThatThrownBy(() -> toscaServiceTemplateService.fetchLatestPolicies("dummy", "dummy", "dummy", null))
+            .hasMessage("service template not found in database");
     }
 
     @Test
-    public void testCreatePolicy() throws Exception {
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.createPolicy("dummy", "1.0.0", new ToscaServiceTemplate());
-        }).hasMessage("topology template not specified on service template");
+    void testCreatePolicy() throws Exception {
+        assertThatThrownBy(() -> toscaServiceTemplateService
+            .createPolicy("dummy", "1.0.0", new ToscaServiceTemplate()))
+            .hasMessage("topology template not specified on service template");
 
         var policyTypeServiceTemplate = standardYamlCoder
             .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
@@ -179,7 +170,7 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
     }
 
     @Test
-    public void testCreateOperationalDroolsPolicy() throws CoderException {
+    void testCreateOperationalDroolsPolicy() throws CoderException {
         var policyTypeServiceTemplate = standardYamlCoder.decode(
             ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
 
@@ -199,7 +190,7 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
     }
 
     @Test
-    public void testSimpleCreatePolicy() throws Exception {
+    void testSimpleCreatePolicy() throws Exception {
 
         assertThatThrownBy(() -> {
             String multiPoliciesString = ResourceUtils.getResourceAsString(MULTIPLE_POLICIES_RESOURCE);
@@ -291,11 +282,10 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
     }
 
     @Test
-    public void testDeletePolicy() throws CoderException, PfModelException {
+    void testDeletePolicy() throws CoderException {
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.deletePolicy("dummy", "1.0.0", "dummy", "1.0.0");
-        }).hasMessage("no policies found");
+        assertThatThrownBy(() -> toscaServiceTemplateService.deletePolicy("dummy", "1.0.0", "dummy", "1.0.0"))
+            .hasMessage("no policies found");
 
         var policyTypeServiceTemplate = standardYamlCoder
             .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
@@ -312,10 +302,10 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
         var exceptionMessage = "policy is in use, it is deployed in PDP group dummy subgroup dummy";
         Mockito.doThrow(new PfModelRuntimeException(Response.Status.NOT_ACCEPTABLE, exceptionMessage))
             .when(pdpGroupService).assertPolicyNotDeployedInPdpGroup("onap.restart.tca", "1.0.0");
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
-                "onap.restart.tca", "1.0.0");
-        }).hasMessage(exceptionMessage);
+        assertThatThrownBy(() -> toscaServiceTemplateService
+            .deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", "1.0.0"))
+            .hasMessage(exceptionMessage);
+
         Mockito.doNothing().when(pdpGroupService).assertPolicyNotDeployedInPdpGroup("onap.restart.tca", "1.0.0");
 
         var deletePolicyResponseFragment = toscaServiceTemplateService
@@ -323,14 +313,13 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
         assertFalse(deletePolicyResponseFragment.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
 
         mockDbServiceTemplate(serviceTemplate, deletePolicyResponseFragment, Operation.DELETE_POLICY);
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
-                "onap.restart.tca", "1.0.0");
-        }).hasMessageContaining("no policies found");
+        assertThatThrownBy(() -> toscaServiceTemplateService
+            .deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", "1.0.0"))
+            .hasMessageContaining("no policies found");
     }
 
     @Test
-    public void testFetchAllPolicies() throws Exception {
+    void testFetchAllPolicies() throws Exception {
         // Create Policy Type
         var policyTypeServiceTemplate = standardYamlCoder
             .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
@@ -353,7 +342,7 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
     }
 
     @Test
-    public void testFetchSpecificPolicy_availablePolicy() throws Exception {
+    void testFetchSpecificPolicy_availablePolicy() throws Exception {
         // Create Policy Type
         var policyTypeServiceTemplate = standardYamlCoder
             .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
@@ -375,7 +364,7 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
     }
 
     @Test
-    public void testFetchSpecificPolicy_unavailablePolicy() throws Exception {
+    void testFetchSpecificPolicy_unavailablePolicy() throws Exception {
         // Create Policy Type
         var policyTypeServiceTemplate = standardYamlCoder
             .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
@@ -397,7 +386,7 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
     }
 
     @Test
-    public void testDeleteSpecificPolicy_availablePolicy() throws Exception {
+    void testDeleteSpecificPolicy_availablePolicy() throws Exception {
         var policyTypeServiceTemplate = standardYamlCoder
             .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
         var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
@@ -415,7 +404,7 @@ public class TestToscaServiceTemplateServiceForPolicyCrud extends TestCommonTosc
     }
 
     @Test
-    public void testDeleteSpecificPolicy_unavailablePolicy() throws Exception {
+    void testDeleteSpecificPolicy_unavailablePolicy() throws Exception {
         var policyTypeServiceTemplate = standardYamlCoder
             .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
         var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
index cea2bcf..9dcb433 100644 (file)
@@ -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.
 package org.onap.policy.api.main.service;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import jakarta.ws.rs.core.Response;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardYamlCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.base.PfModelRuntimeException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
@@ -45,10 +43,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
  *
  * @author Chenfei Gao (cgao@research.att.com)
  */
-@RunWith(MockitoJUnitRunner.class)
-public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommonToscaServiceTemplateService {
+class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommonToscaServiceTemplateService {
 
-    private static StandardYamlCoder coder = new StandardYamlCoder();
+    private static final StandardYamlCoder coder = new StandardYamlCoder();
     private static final String POLICY_TYPE_VERSION = "1.0.0";
 
     private static final String POLICY_RESOURCE_MONITORING = "policies/vCPE.policy.monitoring.input.tosca.yaml";
@@ -76,20 +73,18 @@ public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommon
     /**
      * Test setup.
      */
-    @Before
+    @BeforeEach
     public void setUp() {
         super.setUp();
     }
 
     @Test
-    public void testFetchPolicyTypes() throws PfModelException {
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.fetchPolicyTypes("dummy", null);
-        }).hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=null) do not exist");
+    void testFetchPolicyTypes() {
+        assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicyTypes("dummy", null))
+            .hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=null) do not exist");
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.fetchPolicyTypes("dummy", "dummy");
-        }).hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=dummy) do not exist");
+        assertThatThrownBy(() -> toscaServiceTemplateService.fetchPolicyTypes("dummy", "dummy"))
+            .hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=dummy) do not exist");
 
         // FIXME
         // ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(null, null);
@@ -97,15 +92,13 @@ public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommon
     }
 
     @Test
-    public void testFetchLatestPolicyTypes() {
-
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.fetchLatestPolicyTypes("dummy");
-        }).hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=LATEST) do not exist");
+    void testFetchLatestPolicyTypes() {
+        assertThatThrownBy(() -> toscaServiceTemplateService.fetchLatestPolicyTypes("dummy"))
+            .hasMessage("policy types for filter ToscaEntityFilter(name=dummy, version=LATEST) do not exist");
     }
 
     @Test
-    public void testCreatePolicyType() throws CoderException {
+    void testCreatePolicyType() throws CoderException {
         var policyTypeServiceTemplate = coder
             .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_MONITORING), ToscaServiceTemplate.class);
         var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
@@ -116,10 +109,9 @@ public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommon
         policyTypeServiceTemplate.getPolicyTypes().get("onap.policies.monitoring.tcagen2")
             .setDescription("Some other description");
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
-        }).hasMessageContaining("item \"entity\" value \"onap.policies.monitoring.tcagen2:1.0.0\" INVALID, "
-            + "does not equal existing entity");
+        assertThatThrownBy(() -> toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate))
+            .hasMessageContaining("item \"entity\" value \"onap.policies.monitoring.tcagen2:1.0.0\" INVALID, "
+                + "does not equal existing entity");
 
         assertThatThrownBy(() -> {
             ToscaServiceTemplate badPolicyType =
@@ -132,7 +124,7 @@ public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommon
     }
 
     @Test
-    public void testCreateOperationalPolicyTypes() throws CoderException {
+    void testCreateOperationalPolicyTypes() throws CoderException {
         ToscaServiceTemplate policyTypeServiceTemplate = coder.decode(
             ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
         ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
@@ -152,7 +144,7 @@ public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommon
     }
 
     @Test
-    public void testCreateApexOperationalPolicyTypes() throws CoderException {
+    void testCreateApexOperationalPolicyTypes() throws CoderException {
         var policyTypeServiceTemplate = coder.decode(
             ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_OPERATIONAL_COMMON), ToscaServiceTemplate.class);
         var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
@@ -168,7 +160,7 @@ public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommon
     }
 
     @Test
-    public void testDeletePolicyType() throws CoderException {
+    void testDeletePolicyType() throws CoderException {
         var policyTypeServiceTemplate = coder
             .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE_MONITORING), ToscaServiceTemplate.class);
         var serviceTemplate = toscaServiceTemplateService.createPolicyType(policyTypeServiceTemplate);
@@ -183,9 +175,8 @@ public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommon
         mockDbServiceTemplate(serviceTemplate, createPolicyResponseFragment, Operation.CREATE_POLICY);
         var exceptionMessage = "policy type onap.policies.monitoring.tcagen2:1.0.0 is in use, "
             + "it is referenced in policy onap.restart.tca:1.0.0";
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2", "1.0.0");
-        }).hasMessage(exceptionMessage);
+        assertThatThrownBy(() -> toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2",
+            "1.0.0")).hasMessage(exceptionMessage);
 
         var deletePolicyResponseFragment = toscaServiceTemplateService
             .deletePolicy("onap.policies.monitoring.tcagen2", "1.0.0", "onap.restart.tca", "1.0.0");
@@ -195,9 +186,8 @@ public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommon
         exceptionMessage = "policy type is in use, it is referenced in PDP group dummy subgroup dummy";
         Mockito.doThrow(new PfModelRuntimeException(Response.Status.NOT_ACCEPTABLE, exceptionMessage))
             .when(pdpGroupService).assertPolicyTypeNotSupportedInPdpGroup("onap.policies.monitoring.tcagen2", "1.0.0");
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2", "1.0.0");
-        }).hasMessage(exceptionMessage);
+        assertThatThrownBy(() -> toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2",
+            "1.0.0")).hasMessage(exceptionMessage);
 
         Mockito.doNothing().when(pdpGroupService)
             .assertPolicyTypeNotSupportedInPdpGroup("onap.policies.monitoring.tcagen2", "1.0.0");
@@ -206,8 +196,7 @@ public class TestToscaServiceTemplateServiceForPolicyTypeCrud extends TestCommon
         assertFalse(deletePolicyTypeResponseFragment.getPolicyTypes().isEmpty());
 
         mockDbServiceTemplate(serviceTemplate, deletePolicyTypeResponseFragment, Operation.DELETE_POLICY_TYPE);
-        assertThatThrownBy(() -> {
-            toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2", "1.0.0");
-        }).hasMessage("policy type onap.policies.monitoring.tcagen2:1.0.0 not found");
+        assertThatThrownBy(() -> toscaServiceTemplateService.deletePolicyType("onap.policies.monitoring.tcagen2",
+            "1.0.0")).hasMessage("policy type onap.policies.monitoring.tcagen2:1.0.0 not found");
     }
 }
\ No newline at end of file
index aa86d73..d7df3d8 100644 (file)
@@ -4,6 +4,7 @@
  * ================================================================================
  * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications 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.
@@ -23,21 +24,18 @@ package org.onap.policy.api.main.startstop;
 
 import static org.assertj.core.api.Assertions.assertThatCode;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.onap.policy.api.main.PolicyApiApplication;
 import org.onap.policy.api.main.config.PolicyPreloadConfig;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
 
-@RunWith(SpringRunner.class)
 @SpringBootTest(classes = PolicyApiApplication.class)
 @ActiveProfiles("test")
 @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
-public class ApiDatabaseInitializerTest {
+class ApiDatabaseInitializerTest {
 
     @Autowired
     private PolicyPreloadConfig params;
@@ -46,7 +44,7 @@ public class ApiDatabaseInitializerTest {
     private ApiDatabaseInitializer adi;
 
     @Test
-    public void testInitializeApiDatabase() {
+    void testInitializeApiDatabase() {
         assertThatCode(() -> adi.initializeApiDatabase(params.getPolicyTypes(),
                 params.getPolicies())).doesNotThrowAnyException();
 
index 68f49da..f73f7d0 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
   ============LICENSE_START=======================================================
-   Copyright (C) 2019-2020 Nordix Foundation.
+   Copyright (C) 2019-2020, 2023 Nordix Foundation.
    Modifications Copyright (C) 2021 AT&T Intellectual Property.
    Modifications Copyright (C) 2023 Bell Canada. All rights reserved.
   ================================================================================
@@ -56,7 +56,7 @@
         <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
         <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
         <properties>
-            <property name="javax.persistence.schema-generation.database.action" value="create" />
+            <property name="jakarta.persistence.schema-generation.database.action" value="create" />
             <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
             <property name="eclipselink.ddl-generation.output-mode" value="database" />
             <property name="eclipselink.logging.level" value="INFO" />
index c1d3b8c..f9d2b97 100644 (file)
@@ -28,7 +28,7 @@
     <parent>
         <groupId>org.onap.policy.api</groupId>
         <artifactId>api-packages</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
+        <version>3.0.1-SNAPSHOT</version>
     </parent>
 
     <packaging>pom</packaging>
index 7f41c75..91ede32 100644 (file)
@@ -26,7 +26,7 @@ RUN mkdir /packages /extracted
 COPY /maven/lib/policy-api.tar.gz /packages/
 RUN tar xvzf /packages/policy-api.tar.gz --directory /extracted/
 
-FROM onap/policy-jre-alpine:3.0.0-SNAPSHOT
+FROM onap/policy-jre-alpine:3.0.1-SNAPSHOT
 
 LABEL maintainer="Policy Team"
 LABEL org.opencontainers.image.title="Policy API"
index a666ec5..ecab83f 100644 (file)
 -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onap.policy.api</groupId>
         <artifactId>api-packages</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
+        <version>3.0.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>policy-api-tarball</artifactId>
index a1aabfa..520be64 100644 (file)
   ============LICENSE_END=========================================================
 -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onap.policy.api</groupId>
         <artifactId>policy-api</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
+        <version>3.0.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>api-packages</artifactId>
@@ -33,7 +34,7 @@
     <name>${project.artifactId}</name>
 
     <properties>
-        <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. -->
+        <!-- There is no code in this submodule, only holds interfaces. So skip sonar. -->
         <sonar.skip>true</sonar.skip>
     </properties>
 
diff --git a/pom.xml b/pom.xml
index deb8fa3..fe58f2b 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
   ================================================================================
   Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
   Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
-  Modifications Copyright (C) 2019-2020 Nordix Foundation.
+  Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
   Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <parent>
         <groupId>org.onap.policy.parent</groupId>
         <artifactId>integration</artifactId>
-        <version>4.0.0-SNAPSHOT</version>
-        <relativePath />
+        <version>4.0.1-SNAPSHOT</version>
+        <relativePath/>
     </parent>
 
     <groupId>org.onap.policy.api</groupId>
     <artifactId>policy-api</artifactId>
-    <version>3.0.0-SNAPSHOT</version>
+    <version>3.0.1-SNAPSHOT</version>
 
     <packaging>pom</packaging>
 
@@ -42,8 +42,8 @@
     <description>Code that define our external API.</description>
 
     <properties>
-        <policy.common.version>2.0.0-SNAPSHOT</policy.common.version>
-        <policy.models.version>3.0.0-SNAPSHOT</policy.models.version>
+        <policy.common.version>2.0.1-SNAPSHOT</policy.common.version>
+        <policy.models.version>3.0.1-SNAPSHOT</policy.models.version>
     </properties>
 
     <modules>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.onap.policy.common</groupId>
             <artifactId>policy-endpoints</artifactId>
             <version>${policy.common.version}</version>
         </dependency>
         <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>javax.servlet-api</artifactId>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-server</artifactId>
+            <groupId>org.glassfish.jersey.containers</groupId>
+            <artifactId>jersey-container-servlet</artifactId>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-security</artifactId>
+            <artifactId>jetty-server</artifactId>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-servlet</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.glassfish.jersey.containers</groupId>
-            <artifactId>jersey-container-servlet</artifactId>
-            <version>${version.jersey}</version>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-security</artifactId>
         </dependency>
     </dependencies>
 
index 9dafc8b..9ee4c16 100644 (file)
   limitations under the License.
   ============LICENSE_END=========================================================
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onap.policy.api</groupId>
         <artifactId>api-testsuites</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
+        <version>3.0.1-SNAPSHOT</version>
     </parent>
     <artifactId>api-performance</artifactId>
     <build>
index c49276c..dad3137 100644 (file)
   limitations under the License.
   ============LICENSE_END=========================================================
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onap.policy.api</groupId>
         <artifactId>policy-api</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
+        <version>3.0.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>api-testsuites</artifactId>
     <packaging>pom</packaging>
 
     <properties>
-        <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. -->
+        <!-- There is no code in this submodule, only holds interfaces. So skip sonar. -->
         <sonar.skip>true</sonar.skip>
     </properties>
 
index fcd0bd4..57d7491 100644 (file)
   limitations under the License.
   ============LICENSE_END=========================================================
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onap.policy.api</groupId>
         <artifactId>api-testsuites</artifactId>
-        <version>3.0.0-SNAPSHOT</version>
+        <version>3.0.1-SNAPSHOT</version>
     </parent>
     <artifactId>api-stability</artifactId>
     <build>
index 4ba0a9a..3288dcd 100644 (file)
@@ -4,7 +4,7 @@
 
 minor=3
 minor=0
-patch=0
+patch=1
 
 base_version=${major}.${minor}.${patch}