summaryrefslogtreecommitdiffstats
path: root/controlloop/common/feature-controlloop-management
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2023-08-30 14:57:10 +0100
committeradheli.tavares <adheli.tavares@est.tech>2023-09-22 16:08:42 +0100
commitfc19178b956f4474ed14e810fd911ac60f3756d0 (patch)
tree196af66a25ca190af8f2b2199f977a4e58aad8b3 /controlloop/common/feature-controlloop-management
parentd7d54fef032a2ba3118232506a7ed37f24eb4131 (diff)
Upgrade Java 17 in policy-drools-apps
Issue-ID: POLICY-4816 Change-Id: I61d5c2c0b8bf2cc08416d91bbd84f27f2ed5c5c1 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'controlloop/common/feature-controlloop-management')
-rw-r--r--controlloop/common/feature-controlloop-management/pom.xml19
-rw-r--r--controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java19
-rw-r--r--controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeatureTest.java32
-rw-r--r--controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java26
4 files changed, 49 insertions, 47 deletions
diff --git a/controlloop/common/feature-controlloop-management/pom.xml b/controlloop/common/feature-controlloop-management/pom.xml
index e8eec80d0..589a76e5f 100644
--- a/controlloop/common/feature-controlloop-management/pom.xml
+++ b/controlloop/common/feature-controlloop-management/pom.xml
@@ -20,13 +20,14 @@
============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.drools-applications.controlloop.common</groupId>
<artifactId>drools-applications-common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>feature-controlloop-management</artifactId>
@@ -109,15 +110,15 @@
<language>jaxrs-spec</language>
<generateModels>false</generateModels>
<generateSupportingFiles>false</generateSupportingFiles>
- <sortParamsByRequiredFlag>false</sortParamsByRequiredFlag>
<importMappings>
- Response=javax.ws.rs.core.Response
+ Response=jakarta.ws.rs.core.Response
</importMappings>
<configOptions>
<useTags>true</useTags>
<sourceFolder>src/gen/java</sourceFolder>
- <dateLibrary>java11</dateLibrary>
+ <dateLibrary>java17</dateLibrary>
<interfaceOnly>true</interfaceOnly>
+ <jakarta>true</jakarta>
</configOptions>
</configuration>
</execution>
@@ -307,10 +308,10 @@
<version>${policy.models.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.models.policy-models-interactions</groupId>
- <artifactId>simulators</artifactId>
- <version>${policy.models.version}</version>
- <scope>test</scope>
+ <groupId>org.onap.policy.models.policy-models-interactions</groupId>
+ <artifactId>simulators</artifactId>
+ <version>${policy.models.version}</version>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>
diff --git a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java
index d6ee19017..b33ab7704 100644
--- a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java
+++ b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,17 +21,17 @@
package org.onap.policy.drools.server.restful;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
import org.onap.policy.aai.AaiManager;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
import org.onap.policy.drools.apps.controlloop.feature.management.ControlLoopManagementFeature;
@@ -111,7 +112,7 @@ public class RestControlLoopManager implements PolicyApi {
*/
@GET
@Path("engine/tools/controlloops/aai/customQuery/{vserverId}")
- public Response aaiCustomQuery(String vserverId) {
+ public Response aaiCustomQuery(@PathParam("vserverId") String vserverId) {
var mgr = PolicyEngineConstants.getManager();
return Response
diff --git a/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeatureTest.java b/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeatureTest.java
index 2a9abafb8..e6bd7c368 100644
--- a/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeatureTest.java
+++ b/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeatureTest.java
@@ -22,15 +22,15 @@
package org.onap.policy.drools.apps.controlloop.feature.management;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Collections;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.apps.controlloop.feature.management.ControlLoopManagementFeature.Factory;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.system.PolicyController;
@@ -39,19 +39,19 @@ import org.springframework.test.util.ReflectionTestUtils;
/**
* Control Loop Management Feature Test.
*/
-public class ControlLoopManagementFeatureTest {
+class ControlLoopManagementFeatureTest {
private static final String FACTORY_FIELD = "factory";
private static final String SESSION_NAME = "my-session";
private static final String CONTROLLER_NAME = "my-controller";
private static Factory saveFactory;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
saveFactory = (Factory) ReflectionTestUtils.getField(ControlLoopManagementFeature.class, FACTORY_FIELD);
}
- @After
+ @AfterEach
public void tearDown() {
ReflectionTestUtils.setField(ControlLoopManagementFeature.class, FACTORY_FIELD, saveFactory);
}
@@ -60,21 +60,21 @@ public class ControlLoopManagementFeatureTest {
* Sequence Number Test.
*/
@Test
- public void getSequenceNumber() {
- Assert.assertEquals(1000, new ControlLoopManagementFeature().getSequenceNumber());
+ void getSequenceNumber() {
+ assertEquals(1000, new ControlLoopManagementFeature().getSequenceNumber());
}
/**
* Name Test.
*/
@Test
- public void getName() {
- Assert.assertEquals("controlloop-management", new ControlLoopManagementFeature().getName());
+ void getName() {
+ assertEquals("controlloop-management", new ControlLoopManagementFeature().getName());
}
@Test
- public void testControlLoops_InvalidArgs() {
- Factory factory = mock(Factory.class);
+ void testControlLoops_InvalidArgs() {
+ var factory = mock(Factory.class);
ReflectionTestUtils.setField(ControlLoopManagementFeature.class, FACTORY_FIELD, factory);
// returns null controller
@@ -84,9 +84,9 @@ public class ControlLoopManagementFeatureTest {
.withMessage("Invalid Controller Name");
// non-matching session name
- PolicyController ctlr = mock(PolicyController.class);
- DroolsController drools = mock(DroolsController.class);
+ var drools = mock(DroolsController.class);
when(drools.getSessionNames()).thenReturn(Collections.emptyList());
+ var ctlr = mock(PolicyController.class);
when(ctlr.getDrools()).thenReturn(drools);
when(factory.getController(any())).thenReturn(ctlr);
assertThatIllegalArgumentException()
@@ -95,7 +95,7 @@ public class ControlLoopManagementFeatureTest {
}
@Test
- public void testFactoryGetController() {
+ void testFactoryGetController() {
// invoking controlLoops() will invoke the factory.getController() method
assertThatIllegalArgumentException().isThrownBy(
() -> ControlLoopManagementFeature.controlLoops("unknown-controller", SESSION_NAME));
diff --git a/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java b/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java
index b9caef9da..279b47c38 100644
--- a/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java
+++ b/controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/server/restful/RestControlLoopManagerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,19 +23,18 @@ package org.onap.policy.drools.server.restful;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import jakarta.ws.rs.core.Response.Status;
import java.io.IOException;
import java.nio.file.Files;
-import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.core.Response.Status;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.kie.api.builder.ReleaseId;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
@@ -51,7 +51,7 @@ import org.onap.policy.simulators.Util;
/**
* Test RestControlLoopManager.
*/
-public class RestControlLoopManagerTest {
+class RestControlLoopManagerTest {
private static final String KSESSION = "op";
private static final String KMODULE_DRL_PATH = "src/test/resources/op.drl";
@@ -91,7 +91,7 @@ public class RestControlLoopManagerTest {
*
* @throws Exception if failure to complete the set up.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
System.setProperty("kie.maven.settings.custom", "src/test/resources/settings.xml");
LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "WARN");
@@ -133,7 +133,7 @@ public class RestControlLoopManagerTest {
/**
* test tear down.
*/
- @AfterClass
+ @AfterAll
public static void tearDown() {
PolicyControllerConstants.getFactory().get(CONTROLLER).stop();
await().atMost(1, TimeUnit.MINUTES).until(isContainerAlive(), equalTo(Boolean.FALSE));
@@ -141,7 +141,7 @@ public class RestControlLoopManagerTest {
PolicyEngineConstants.getManager().removePolicyController(CONTROLLER);
PolicyEngineConstants.getManager().stop();
- final Path controllerPath =
+ final var controllerPath =
Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
CONTROLLER_FILE);
try {
@@ -150,7 +150,7 @@ public class RestControlLoopManagerTest {
/* to satisfy checkstyle */
}
- Path controllerBakPath =
+ var controllerBakPath =
Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
CONTROLLER_FILE_BAK);
@@ -165,7 +165,7 @@ public class RestControlLoopManagerTest {
* Test Operational Policies.
*/
@Test
- public void testOperationalPolicy() throws IOException {
+ void testOperationalPolicy() {
assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory()
.get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOPS).getStatus());
@@ -180,7 +180,7 @@ public class RestControlLoopManagerTest {
* Test AAI Custom Query.
*/
@Test
- public void testAaiCq() throws CoderException {
+ void testAaiCq() {
assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory()
.get(CONTROLLER).get(URL_CONTEXT_PATH_TOOLS_AAI_CQ + "dummy").getStatus());
}