* 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.
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;
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.
@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);
}
/**
@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);
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.
<artifactId>assertj-core</artifactId>
<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>
<scope>provided</scope>
<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>
* 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.
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.
}
}
+ @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();
* 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.
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;
* 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.
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 {
/**
* 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");
}
/**
*/
@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);
}
/**
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<>();
* 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.
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 {
/**
* 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");
}
/**
*/
@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);
}
/**
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<>();
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.
<artifactId>umlgraph</artifactId>
<version>5.6</version>
</docletArtifact>
- <additionalparam>-views</additionalparam>
<useStandardDocletOptions>true</useStandardDocletOptions>
</configuration>
</plugin>
<artifactId>junit</artifactId>
<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>