aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controlloop/common/feature-controlloop-management/src/test/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeatureTest.java11
-rw-r--r--controlloop/common/rules-test/pom.xml11
-rw-r--r--controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java8
-rw-r--r--controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTest.java3
-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
-rw-r--r--pom.xml12
7 files changed, 49 insertions, 48 deletions
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 e5034017f..2a9abafb8 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
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-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.
@@ -21,7 +22,7 @@
package org.onap.policy.drools.apps.controlloop.feature.management;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -33,7 +34,7 @@ import org.junit.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;
-import org.powermock.reflect.Whitebox;
+import org.springframework.test.util.ReflectionTestUtils;
/**
* Control Loop Management Feature Test.
@@ -47,12 +48,12 @@ public class ControlLoopManagementFeatureTest {
@BeforeClass
public static void setUpBeforeClass() {
- saveFactory = Whitebox.getInternalState(ControlLoopManagementFeature.class, FACTORY_FIELD);
+ saveFactory = (Factory) ReflectionTestUtils.getField(ControlLoopManagementFeature.class, FACTORY_FIELD);
}
@After
public void tearDown() {
- Whitebox.setInternalState(ControlLoopManagementFeature.class, FACTORY_FIELD, saveFactory);
+ ReflectionTestUtils.setField(ControlLoopManagementFeature.class, FACTORY_FIELD, saveFactory);
}
/**
@@ -74,7 +75,7 @@ public class ControlLoopManagementFeatureTest {
@Test
public void testControlLoops_InvalidArgs() {
Factory factory = mock(Factory.class);
- Whitebox.setInternalState(ControlLoopManagementFeature.class, FACTORY_FIELD, factory);
+ ReflectionTestUtils.setField(ControlLoopManagementFeature.class, FACTORY_FIELD, factory);
// returns null controller
when(factory.getController(any())).thenReturn(null);
diff --git a/controlloop/common/rules-test/pom.xml b/controlloop/common/rules-test/pom.xml
index 586c45e9a..fbf7f93d8 100644
--- a/controlloop/common/rules-test/pom.xml
+++ b/controlloop/common/rules-test/pom.xml
@@ -3,6 +3,7 @@
ONAP
================================================================================
Copyright (C) 2020-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.
@@ -76,6 +77,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
@@ -108,11 +114,6 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>utils-test</artifactId>
<version>${version.policy.common}</version>
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<String, SimpleLock> 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<String, SimpleLock>) 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<String, Rules> ruleMaker = Rules::new;
+ private static Function<String, Rules> ruleMaker = Rules::new;
protected static Rules rules;
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<>();
diff --git a/pom.xml b/pom.xml
index 209edd780..777359b9d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
drools-pdp-apps
================================================================================
Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2019,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.
@@ -100,7 +100,6 @@
<artifactId>umlgraph</artifactId>
<version>5.6</version>
</docletArtifact>
- <additionalparam>-views</additionalparam>
<useStandardDocletOptions>true</useStandardDocletOptions>
</configuration>
</plugin>
@@ -119,18 +118,13 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>