diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-03-14 21:48:25 +0000 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2024-03-15 08:39:39 +0000 |
commit | 12142469280ab15d3c38802e6be7d7676435c2b9 (patch) | |
tree | 7b2803fb67ecd28c3f2d2c099c5ca35a55fe0627 /policy-management | |
parent | e51bea1cd5dff02cd00ab93fd4a7f5726fa9a2fb (diff) |
Make drools-pdp work with drools and java versions compatible
with current DRL rules files syntax.
Issue-ID: POLICY-4857
Change-Id: If4b385bdef865d07114b8ea0e69abb4589f3a97b
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'policy-management')
5 files changed, 24 insertions, 30 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java index 76836ba2..1201c26e 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java +++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java @@ -165,30 +165,32 @@ public class PdpdConfiguration { } protected boolean declaredProperty(String name, Object value) { - return switch (name) { - case "requestID" -> { + switch (name) { + case "requestID": callSetRequestId(value); - yield true; - } - case "entity" -> { + return true; + case "entity": callSetEntity(value); - yield true; - } - case "controllers" -> { + return true; + case "controllers": callSetControllers(value); - yield true; - } - default -> false; - }; + return true; + default: + return false; + } } protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) { - return switch (name) { - case "requestID" -> getRequestId(); - case "entity" -> getEntity(); - case "controllers" -> getControllers(); - default -> notFoundValue; - }; + switch (name) { + case "requestID": + return getRequestId(); + case "entity": + return getEntity(); + case "controllers": + return getControllers(); + default: + return notFoundValue; + } } /** diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java index ecc6c083..ec06882f 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java @@ -1722,11 +1722,12 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA @Path("engine/tools/loggers") public Response loggers() { final List<String> names = new ArrayList<>(); - if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext context)) { + if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) { logger.warn("The SLF4J logger factory is not configured for logback"); return Response.status(Status.INTERNAL_SERVER_ERROR).entity(names).build(); } + final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); for (final Logger lgr : context.getLoggerList()) { names.add(lgr.getName()); } @@ -1744,11 +1745,12 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA @Path("engine/tools/loggers/{logger}") @Produces(MediaType.TEXT_PLAIN) public Response loggerName1(@PathParam("logger") String loggerName) { - if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext context)) { + if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) { logger.warn("The SLF4J logger factory is not configured for logback"); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } + final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); var lgr = context.getLogger(loggerName); if (lgr == null) { return Response.status(Status.NOT_FOUND).build(); diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java index 23511abd..8a10c516 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java @@ -40,7 +40,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.Serial; import java.util.concurrent.ScheduledExecutorService; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; @@ -189,7 +188,6 @@ class FeatureLockImplTest { PolicySession session = mock(PolicySession.class); MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback) { - @Serial private static final long serialVersionUID = 1L; @Override @@ -397,7 +395,6 @@ class FeatureLockImplTest { * Lock that inherits the normal getSession() method. */ public static class MyLockStdSession extends FeatureLockImpl { - @Serial private static final long serialVersionUID = 1L; protected int nupdates = 0; @@ -433,7 +430,6 @@ class FeatureLockImplTest { } public static class MyLock extends MyLockStdSession { - @Serial private static final long serialVersionUID = 1L; public MyLock() { @@ -451,7 +447,6 @@ class FeatureLockImplTest { } public static class MyLockNoFeature extends MyLock { - @Serial private static final long serialVersionUID = 1L; public MyLockNoFeature() { diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java index 74e1a9c1..47d0f275 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java @@ -33,7 +33,6 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.io.Serial; import java.util.concurrent.ScheduledExecutorService; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -225,7 +224,6 @@ class LockManagerTest { } private class MyLock extends FeatureLockImpl { - @Serial private static final long serialVersionUID = 1L; public MyLock(LockState waiting, String resourceId, String ownerKey, int holdSec, LockCallback callback) { diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java index 3ee5583a..242492bb 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java @@ -44,7 +44,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.Serial; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -310,7 +309,6 @@ class SimpleLockManagerTest { protected SimpleLock makeLock(LockState waiting, String resourceId, String ownerKey, int holdSec, LockCallback callback) { return new SimpleLock(waiting, resourceId, ownerKey, holdSec, callback, feature) { - @Serial private static final long serialVersionUID = 1L; @Override @@ -367,7 +365,6 @@ class SimpleLockManagerTest { madeLock = true; return new SimpleLock(waiting, resourceId, ownerKey, holdSec, callback, feature) { - @Serial private static final long serialVersionUID = 1L; @Override |