summaryrefslogtreecommitdiffstats
path: root/controlloop/common/rules-test/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2023-01-31 10:44:54 +0000
committerliamfallon <liam.fallon@est.tech>2023-01-31 12:56:17 +0000
commit0d52472a24ba317d6c96fcd215c7f2a2b6bd43f8 (patch)
treea4a5f06ba1ab41033f7cca9cc160333d87f20247 /controlloop/common/rules-test/src/test
parent6895f4d2004cf3ccb94d9d7bbb0928db50dae39a (diff)
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 <liam.fallon@est.tech>
Diffstat (limited to 'controlloop/common/rules-test/src/test')
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java23
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java29
2 files changed, 27 insertions, 25 deletions
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java
index a2b4d328e..0c8c6fb1c 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021,2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ import org.onap.policy.sdnr.PciBody;
import org.onap.policy.sdnr.PciCommonHeader;
import org.onap.policy.sdnr.PciMessage;
import org.onap.policy.sdnr.PciRequest;
-import org.powermock.reflect.Whitebox;
+import org.springframework.test.util.ReflectionTestUtils;
@RunWith(MockitoJUnitRunner.class)
public class BaseTestTest {
@@ -106,11 +106,12 @@ public class BaseTestTest {
/**
* Saves static values from the class.
*/
+ @SuppressWarnings("unchecked")
@BeforeClass
public static void setUpBeforeClass() {
- httpClientMaker = Whitebox.getInternalState(BaseTest.class, "httpClientMaker");
- simMaker = Whitebox.getInternalState(BaseTest.class, "simMaker");
- topicMaker = Whitebox.getInternalState(BaseTest.class, "topicMaker");
+ httpClientMaker = (Supplier<HttpClients>) ReflectionTestUtils.getField(BaseTest.class, "httpClientMaker");
+ simMaker = (Supplier<Simulators>) ReflectionTestUtils.getField(BaseTest.class, "simMaker");
+ topicMaker = (Supplier<Topics>) ReflectionTestUtils.getField(BaseTest.class, "topicMaker");
}
/**
@@ -118,9 +119,9 @@ public class BaseTestTest {
*/
@AfterClass
public static void tearDownAfterClass() {
- Whitebox.setInternalState(BaseTest.class, "httpClientMaker", httpClientMaker);
- Whitebox.setInternalState(BaseTest.class, "simMaker", simMaker);
- Whitebox.setInternalState(BaseTest.class, "topicMaker", topicMaker);
+ ReflectionTestUtils.setField(BaseTest.class, "httpClientMaker", httpClientMaker);
+ ReflectionTestUtils.setField(BaseTest.class, "simMaker", simMaker);
+ ReflectionTestUtils.setField(BaseTest.class, "topicMaker", topicMaker);
}
/**
@@ -141,9 +142,9 @@ public class BaseTestTest {
Supplier<Simulators> simMaker = this::makeSim;
Supplier<Topics> topicMaker = this::makeTopics;
- Whitebox.setInternalState(BaseTest.class, "httpClientMaker", httpClientMaker);
- Whitebox.setInternalState(BaseTest.class, "simMaker", simMaker);
- Whitebox.setInternalState(BaseTest.class, "topicMaker", topicMaker);
+ ReflectionTestUtils.setField(BaseTest.class, "httpClientMaker", httpClientMaker);
+ ReflectionTestUtils.setField(BaseTest.class, "simMaker", simMaker);
+ ReflectionTestUtils.setField(BaseTest.class, "topicMaker", topicMaker);
clMgtQueue = new LinkedList<>();
appcLcmQueue = new LinkedList<>();
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java
index 82b9ed6cc..4b9f5774d 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021,2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
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;
@RunWith(MockitoJUnitRunner.class)
public class DroolsRuleTestTest {
@@ -105,12 +105,13 @@ public class DroolsRuleTestTest {
/**
* Saves static values from the class.
*/
+ @SuppressWarnings("unchecked")
@BeforeClass
public static void setUpBeforeClass() {
- ruleMaker = Whitebox.getInternalState(DroolsRuleTest.class, "ruleMaker");
- httpClientMaker = Whitebox.getInternalState(DroolsRuleTest.class, "httpClientMaker");
- simMaker = Whitebox.getInternalState(DroolsRuleTest.class, "simMaker");
- topicMaker = Whitebox.getInternalState(DroolsRuleTest.class, "topicMaker");
+ ruleMaker = (Function<String, Rules>) ReflectionTestUtils.getField(DroolsRuleTest.class, "ruleMaker");
+ httpClientMaker = (Supplier<HttpClients>) ReflectionTestUtils.getField(DroolsRuleTest.class, "httpClientMaker");
+ simMaker = (Supplier<Simulators>) ReflectionTestUtils.getField(DroolsRuleTest.class, "simMaker");
+ topicMaker = (Supplier<Topics>) ReflectionTestUtils.getField(DroolsRuleTest.class, "topicMaker");
}
/**
@@ -118,10 +119,10 @@ public class DroolsRuleTestTest {
*/
@AfterClass
public static void tearDownAfterClass() {
- Whitebox.setInternalState(DroolsRuleTest.class, "ruleMaker", ruleMaker);
- Whitebox.setInternalState(DroolsRuleTest.class, "httpClientMaker", httpClientMaker);
- Whitebox.setInternalState(DroolsRuleTest.class, "simMaker", simMaker);
- Whitebox.setInternalState(DroolsRuleTest.class, "topicMaker", topicMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "ruleMaker", ruleMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "httpClientMaker", httpClientMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "simMaker", simMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "topicMaker", topicMaker);
}
/**
@@ -142,10 +143,10 @@ public class DroolsRuleTestTest {
Supplier<Simulators> simMaker = this::makeSim;
Supplier<Topics> topicMaker = this::makeTopics;
- Whitebox.setInternalState(DroolsRuleTest.class, "ruleMaker", ruleMaker);
- Whitebox.setInternalState(DroolsRuleTest.class, "httpClientMaker", httpClientMaker);
- Whitebox.setInternalState(DroolsRuleTest.class, "simMaker", simMaker);
- Whitebox.setInternalState(DroolsRuleTest.class, "topicMaker", topicMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "ruleMaker", ruleMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "httpClientMaker", httpClientMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "simMaker", simMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "topicMaker", topicMaker);
clMgtQueue = new LinkedList<>();
appcLcmQueue = new LinkedList<>();