From 0d52472a24ba317d6c96fcd215c7f2a2b6bd43f8 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 31 Jan 2023 10:44:54 +0000 Subject: Upgrade and clean up dependencies - Upgrade Hibernate - Upgrade Mockito - Upgrade Mockserver - Remove Powermock (no longer supported) and replace with spring-test ReflectionTestUtils - Upgrade Spring Framework - Add spring-security to allow authentication on unit tests using MockMVC Minor clean-up - Replace deprecated authorization configuraiton on spring boot applications with SecurityFilterChain bean - Change @LocalPort include on tests to use test include rather than runtime include - Remove unused imports - Remove unused constants and variables - Add deprecation annotations where required Issue-ID: POLICY-4482 Change-Id: I8f3eeba7bd476c2b8e74a6a6a9d1f53b4c5304c3 Signed-off-by: liamfallon --- .../org/onap/policy/controlloop/common/rules/test/BaseTest.java | 8 +++++--- .../onap/policy/controlloop/common/rules/test/DroolsRuleTest.java | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'controlloop/common/rules-test/src/main') diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java index 044fa8121..f36a3780b 100644 --- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java +++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2022 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. @@ -50,7 +51,7 @@ import org.onap.policy.drools.system.internal.SimpleLockManager; import org.onap.policy.drools.system.internal.SimpleLockManager.SimpleLock; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.sdnr.PciMessage; -import org.powermock.reflect.Whitebox; +import org.springframework.test.util.ReflectionTestUtils; /** * Superclass used for rule tests. @@ -766,10 +767,11 @@ public abstract class BaseTest { } } + @SuppressWarnings("unchecked") private Map getLockMap() { - Object lockMgr = Whitebox.getInternalState(PolicyEngineConstants.getManager(), "lockManager"); + Object lockMgr = ReflectionTestUtils.getField(PolicyEngineConstants.getManager(), "lockManager"); if (lockMgr instanceof SimpleLockManager) { - return Whitebox.getInternalState(lockMgr, "resource2lock"); + return (Map) ReflectionTestUtils.getField(lockMgr, "resource2lock"); } return Collections.emptyMap(); diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTest.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTest.java index 449096223..97bbeeadf 100644 --- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTest.java +++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020, 2022 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. @@ -31,7 +32,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; public abstract class DroolsRuleTest extends BaseTest { // these may be overridden by junit tests - private static final Function ruleMaker = Rules::new; + private static Function ruleMaker = Rules::new; protected static Rules rules; -- cgit 1.2.3-korg