<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.8.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>3.8.6</version>
+ </dependency>
</dependencies>
<profiles>
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
future = new CompletableFuture<>();
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder().actorService(actors)
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
future = new CompletableFuture<>();
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder().actorService(actors)
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
future = new CompletableFuture<>();
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder().actorService(actors)
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder());
master = new Step2(stepContext, params, event);
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* 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.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
-import org.onap.aai.domain.yang.Vserver;
import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.so.VfModuleCreate;
private final AaiCqResponse customQuery = mock(AaiCqResponse.class);
private final GenericVnf genericVnf = mock(GenericVnf.class);
private final CloudRegion cloudRegion = mock(CloudRegion.class);
- private final Vserver theVserver = mock(Vserver.class);
private TargetType target;
private Map<String, String> aai = new HashMap<>();
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
aai.put("vserver.vserver-name", MY_SERVERNAME);
when(event.getAai()).thenReturn(aai);
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
future = new CompletableFuture<>();
when(stepContext.requestLock(MY_TARGET)).thenReturn(future);
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
// configure policy operation
when(actors.getActor(POLICY_ACTOR)).thenReturn(policyActor);
when(policyActor.getOperator(POLICY_OPERATION)).thenReturn(policyOperator);
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Prepare tests.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
clp.setClosedLoopControlName(CONTROL_LOOP_NAME);
clp.setPolicyName(POLICY_NAME);
clp.setPolicyScope(POLICY_SCOPE);
* ONAP
* ================================================================================
* Copyright (C) 2021, 2023 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() throws ControlLoopException, CoderException {
+ void setUp() throws ControlLoopException, CoderException {
when(services.getActorService()).thenReturn(actors);
when(services.getDataManager()).thenReturn(dataMgr);
@Override
protected void loadPolicyStep(ControlLoopOperationParams params) {
- getSteps().add(new MyStep(this, params, getEvent()));
+ getSteps().add(new MyStep(params));
}
}
private static class MyStep extends Step {
- public MyStep(StepContext stepContext, ControlLoopOperationParams params, VirtualControlLoopEvent event) {
+ public MyStep(ControlLoopOperationParams params) {
super(params, new AtomicReference<>());
}
}
* ONAP
* ================================================================================
* Copyright (C) 2021, 2023 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicReference;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.controlloop.ControlLoopException;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Operator;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
import org.onap.policy.drools.core.lock.LockCallback;
import org.onap.policy.drools.core.lock.LockImpl;
private final PolicyEngine engineMgr = mock(PolicyEngine.class);
private final WorkingMemory workMem = mock(WorkingMemory.class);
private final InternalFactHandle factHandle = mock(InternalFactHandle.class);
- private final Operator policyOperator = mock(Operator.class);
- private final Operation policyOperation = mock(Operation.class);
- private final Actor policyActor = mock(Actor.class);
private final EventManagerServices services = mock(EventManagerServices.class);
private final ExecutorService executor = mock(ExecutorService.class);
- private final MyStep stepa = mock(MyStep.class);
- private final MyStep stepb = mock(MyStep.class);
private List<LockImpl> locks;
private ToscaPolicy tosca;
* Sets up.
*/
@BeforeEach
- public void setUp() throws ControlLoopException, CoderException {
+ void setUp() throws ControlLoopException, CoderException {
when(workMem.getFactHandle(any())).thenReturn(factHandle);
params = new ControlLoopParams();
// start and load step for first policy
mgr.start();
- assertEquals("OperationA", mgr.getSteps().poll().getOperationName());
+ assertEquals("OperationA", Objects.requireNonNull(mgr.getSteps().poll()).getOperationName());
assertNull(mgr.getFinalResult());
// add an outcome
// indicate success and load next policy
mgr.loadNextPolicy(OperationResult.SUCCESS);
- assertEquals("OperationB", mgr.getSteps().poll().getOperationName());
+ assertEquals("OperationB", Objects.requireNonNull(mgr.getSteps().poll()).getOperationName());
assertNull(mgr.getFinalResult());
// loadPolicy() should clear the partial history, but not the full history
assertThat(mgr.getPartialHistory()).hasSize(1);
assertThat(mgr.getFullHistory()).hasSize(1);
assertSame(outcome, mgr.getPartialHistory().peek().getOutcome());
+ assertNotNull(mgr.getFullHistory().peek());
assertSame(outcome, mgr.getFullHistory().peek().getOutcome());
// add another start
assertThat(mgr.getPartialHistory()).hasSize(2);
assertThat(mgr.getFullHistory()).hasSize(2);
assertSame(outcome, mgr.getPartialHistory().peekLast().getOutcome());
+ assertNotNull(mgr.getFullHistory().peekLast());
assertSame(outcome, mgr.getFullHistory().peekLast().getOutcome());
// remove the last item from the full history and then add a "completion"
assertThat(mgr.getPartialHistory()).hasSize(4);
assertThat(mgr.getFullHistory()).hasSize(4);
assertSame(outcome, mgr.getPartialHistory().peekLast().getOutcome());
+ assertNotNull(mgr.getFullHistory().peekLast());
assertSame(outcome, mgr.getFullHistory().peekLast().getOutcome());
}
@Override
protected void loadPolicyStep(ControlLoopOperationParams params) {
- getSteps().add(new MyStep(this, params));
+ getSteps().add(new MyStep(params));
}
}
private static class MyStep extends Step {
- public MyStep(StepContext stepContext, ControlLoopOperationParams params) {
+ public MyStep(ControlLoopOperationParams params) {
super(params, new AtomicReference<>());
}
}
* ONAP
* ================================================================================
* Copyright (C) 2021, 2023 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() throws ControlLoopException, CoderException {
+ void setUp() throws ControlLoopException, CoderException {
when(services.getActorService()).thenReturn(actors);
when(workMem.getFactHandle(any())).thenReturn(factHandle);
* Tests start() when the manager is not in working memory.
*/
@Test
- void testStartNotInWorkingMemory() throws ControlLoopException {
+ void testStartNotInWorkingMemory() {
when(workMem.getFactHandle(any())).thenReturn(null);
assertThatCode(() -> mgr.start()).isInstanceOf(IllegalStateException.class)
@Test
void testLoadPreprocessorSteps() {
- stepa = new MyStep(mgr, ControlLoopOperationParams.builder().build()) {
+ stepa = new MyStep(ControlLoopOperationParams.builder().build()) {
@Override
protected Operation buildOperation() {
return policyOperation;
*/
@Test
void testLoadPreprocessorStepsTooManySteps() {
- stepa = new MyStep(mgr, ControlLoopOperationParams.builder().build()) {
+ stepa = new MyStep(ControlLoopOperationParams.builder().build()) {
@Override
protected Operation buildOperation() {
return policyOperation;
@Override
protected void loadPolicyStep(ControlLoopOperationParams params) {
- getSteps().add(new MyStep(this, params));
+ getSteps().add(new MyStep(params));
}
}
@Override
protected void loadPolicyStep(ControlLoopOperationParams params) {
- getSteps().add(new MyStep(this, params));
+ getSteps().add(new MyStep(params));
}
}
private static class MyStep extends Step {
- public MyStep(StepContext stepContext, ControlLoopOperationParams params) {
+ public MyStep(ControlLoopOperationParams params) {
super(params, new AtomicReference<>());
}
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() throws ControlLoopException, CoderException {
+ void setUp() throws ControlLoopException, CoderException {
when(services.getDataManager()).thenReturn(dataMgr);
params = new ControlLoopParams();
// ensure destroy() doesn't throw an exception if the object is deserialized
var mgr2 = Serializer.roundTrip(mgr);
- assertThatCode(() -> mgr2.destroy()).doesNotThrowAnyException();
+ assertThatCode(mgr2::destroy).doesNotThrowAnyException();
// locks should not have been freed
for (var lock : locks) {
}
@Test
- void testDetmControlLoopTimeoutMs() throws Exception {
+ void testDetmControlLoopTimeoutMs() {
long timeMs = 1200 * 1000L;
long end = mgr.getEndTimeMs();
assertThat(end).isGreaterThanOrEqualTo(preCreateTimeMs + timeMs).isLessThan(preCreateTimeMs + timeMs + 5000);
* Tests getDataManager() when not disabled.
*/
@Test
- void testGetDataManagerNotDisabled() throws ControlLoopException {
+ void testGetDataManagerNotDisabled() {
assertThat(mgr.getDataManager()).isSameAs(dataMgr);
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
* Configures HTTP clients.
*/
@BeforeAll
- public static void setUpBeforeClass() throws Exception {
+ static void setUpBeforeClass() throws Exception {
// start with a clean slate
HttpClientFactoryInstance.getClientFactory().destroy();
}
@AfterAll
- public static void teatDownBeforeClass() {
+ static void teatDownBeforeClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
}
@AfterEach
- public void tearDown() {
+ void tearDown() {
closeDb();
}
void testEventManagerServices_testGetActorService() {
// try with guard disabled - should use DB stub
services = new EventManagerServices(FILEPFX + "event-svc-guard-disabled");
- assertTrue(services.getDataManager() instanceof OperationHistoryDataManagerStub);
+ assertInstanceOf(OperationHistoryDataManagerStub.class, services.getDataManager());
assertNotNull(services.getActorService());
// try with guard enabled - should create a DB connection
services = new EventManagerServices(FILEPFX + "event-svc-with-db");
- assertTrue(services.getDataManager() instanceof OperationHistoryDataManagerImpl);
+ assertInstanceOf(OperationHistoryDataManagerImpl.class, services.getDataManager());
assertNotNull(services.getActorService());
}
void testIsGuardEnabled() {
// cannot check guard
services = new EventManagerServices(FILEPFX + "event-svc-no-guard-actor");
- assertTrue(services.getDataManager() instanceof OperationHistoryDataManagerStub);
+ assertInstanceOf(OperationHistoryDataManagerStub.class, services.getDataManager());
// force exception when checking for guard operator
services = new EventManagerServices(FILEPFX + "event-svc-with-db") {
return svc;
}
};
- assertTrue(services.getDataManager() instanceof OperationHistoryDataManagerStub);
+ assertInstanceOf(OperationHistoryDataManagerStub.class, services.getDataManager());
}
@Test
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
data = new LockData(ENTITY, REQ_ID);
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
future = new CompletableFuture<>();
// configure policy operation
assertEquals("operB", params2.getOperation());
assertNull(params2.getRetry());
assertNull(params2.getTimeoutSec());
- assertEquals(target.getTargetType().toString(), params2.getTargetType().toString());
+ assertEquals(target.getTargetType(), params2.getTargetType().toString());
assertSame(entityIds, params2.getTargetEntityIds());
assertTrue(params2.getPayload().isEmpty());
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up for all tests.
*/
@BeforeAll
- public static void setUpBeforeClass() {
+ static void setUpBeforeClass() {
var params = makeBuilder().build();
// capture the entity manager factory for re-use
* Restores the environment after all tests.
*/
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
emf.close();
}
* Sets up for an individual test.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(MY_LOOP_NAME);
event.setRequestId(UUID.randomUUID());
}
@AfterEach
- public void tearDown() {
+ void tearDown() {
mgr.stop();
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private OperationHistoryDataManagerParams params;
@BeforeEach
- public void setUp() {
+ void setUp() {
params = makeBuilder().build();
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
var mgr = new OperationHistoryDataManagerStub();
assertThatCode(() -> mgr.store(null, null, null, null, null)).doesNotThrowAnyException();
- assertThatCode(() -> mgr.stop()).doesNotThrowAnyException();
+ assertThatCode(mgr::stop).doesNotThrowAnyException();
}
}
* ONAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
class ControlLoopUtilsTest {
serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get("operational.restart");
var params = ControlLoopUtils.toControlLoopParams(toscaPolicy);
+ Assertions.assertNotNull(params);
assertEquals("ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", params.getClosedLoopControlName());
assertEquals(toscaPolicy.getName(), params.getPolicyName());
assertEquals(toscaPolicy.getVersion(), params.getPolicyVersion());
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.8.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>3.8.6</version>
+ </dependency>
</dependencies>
</project>
* ONAP
* ================================================================================
* Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static Factory saveFactory;
@BeforeAll
- public static void setUpBeforeClass() {
+ static void setUpBeforeClass() {
saveFactory = (Factory) ReflectionTestUtils.getField(ControlLoopManagementFeature.class, FACTORY_FIELD);
}
@AfterEach
- public void tearDown() {
+ void tearDown() {
ReflectionTestUtils.setField(ControlLoopManagementFeature.class, FACTORY_FIELD, saveFactory);
}
* ONAP
* ================================================================================
* Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @throws Exception if failure to complete the setup.
*/
@BeforeAll
- public static void setUp() throws Exception {
+ static void setUp() throws Exception {
System.setProperty("kie.maven.settings.custom", "src/test/resources/settings.xml");
LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "WARN");
* test tear down.
*/
@AfterAll
- public static void tearDown() {
+ static void tearDown() {
PolicyControllerConstants.getFactory().get(CONTROLLER).stop();
await().atMost(1, TimeUnit.MINUTES).until(isContainerAlive(), equalTo(Boolean.FALSE));
* ONAP
* ================================================================================
* Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Setup method.
*/
@BeforeAll
- public static void setUp() {
+ static void setUp() {
SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
testController = PolicyEngineConstants.getManager().createPolicyController("metrics",
SystemPersistenceConstants.getManager().getControllerProperties("metrics"));
}
@AfterAll
- public static void tearDown() {
+ static void tearDown() {
SystemPersistenceConstants.getManager().setConfigurationDir(configPath.toString());
resetStats();
}
@BeforeEach
- public void beforeTest() {
+ void beforeTest() {
resetStats();
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static HttpClient client;
@BeforeAll
- public static void testBeforeClass() throws Exception {
+ static void testBeforeClass() throws Exception {
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@AfterAll
- public static void testAfterClass() {
+ static void testAfterClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* 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.common.utils.coder.StandardCoderInstantAsMillis;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
-import org.onap.policy.drools.controller.DroolsController;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.sdnr.PciBody;
import org.onap.policy.sdnr.PciCommonHeader;
private final Listener<Request> appcClSink = mock();
private final Listener<AppcLcmMessageWrapper> appcLcmRead = mock();
private final Listener<PciMessage> sdnrClSink = mock();
- private final DroolsController drools = mock(DroolsController.class);
- private final ToscaPolicy policy = mock(ToscaPolicy.class);
- private final ToscaConceptIdentifier policyIdent = mock(ToscaConceptIdentifier.class);
/**
* Saves static values from the class.
*/
@SuppressWarnings("unchecked")
@BeforeAll
- public static void setUpBeforeClass() {
+ static void setUpBeforeClass() {
httpClientMaker = (Supplier<HttpClients>) ReflectionTestUtils.getField(BaseTest.class, "httpClientMaker");
simMaker = (Supplier<Simulators>) ReflectionTestUtils.getField(BaseTest.class, "simMaker");
topicMaker = (Supplier<Topics>) ReflectionTestUtils.getField(BaseTest.class, "topicMaker");
* Restores static values.
*/
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
ReflectionTestUtils.setField(BaseTest.class, "httpClientMaker", httpClientMaker);
ReflectionTestUtils.setField(BaseTest.class, "simMaker", simMaker);
ReflectionTestUtils.setField(BaseTest.class, "topicMaker", topicMaker);
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
when(topics.createListener(eq(BaseTest.POLICY_CL_MGT_TOPIC), eq(VirtualControlLoopNotification.class),
any(StandardCoder.class))).thenReturn(policyClMgt);
when(topics.createListener(eq(BaseTest.APPC_LCM_READ_TOPIC), eq(AppcLcmMessageWrapper.class),
when(topics.createListener(eq(BaseTest.SDNR_CL_TOPIC), eq(PciMessage.class), any(StandardCoder.class)))
.thenReturn(sdnrClSink);
- Supplier<HttpClients> httpClientMaker = this::makeHttpClients;
- Supplier<Simulators> simMaker = this::makeSim;
- Supplier<Topics> topicMaker = this::makeTopics;
+ Supplier<HttpClients> localHttpClientMaker = this::makeHttpClients;
+ Supplier<Simulators> localSimMaker = this::makeSim;
+ Supplier<Topics> localTopicMaker = this::makeTopics;
- ReflectionTestUtils.setField(BaseTest.class, "httpClientMaker", httpClientMaker);
- ReflectionTestUtils.setField(BaseTest.class, "simMaker", simMaker);
- ReflectionTestUtils.setField(BaseTest.class, "topicMaker", topicMaker);
+ ReflectionTestUtils.setField(BaseTest.class, "httpClientMaker", localHttpClientMaker);
+ ReflectionTestUtils.setField(BaseTest.class, "simMaker", localSimMaker);
+ ReflectionTestUtils.setField(BaseTest.class, "topicMaker", localTopicMaker);
clMgtQueue = new LinkedList<>();
appcLcmQueue = new LinkedList<>();
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
@SuppressWarnings("unchecked")
@BeforeAll
- public static void setUpBeforeClass() {
+ static void setUpBeforeClass() {
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");
* Restores static values.
*/
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
ReflectionTestUtils.setField(DroolsRuleTest.class, "ruleMaker", ruleMaker);
ReflectionTestUtils.setField(DroolsRuleTest.class, "httpClientMaker", httpClientMaker);
ReflectionTestUtils.setField(DroolsRuleTest.class, "simMaker", simMaker);
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
when(rules.getController()).thenReturn(controller);
when(rules.setupPolicyFromFile(any())).thenReturn(policy);
when(topics.createListener(eq(DroolsRuleTest.APPC_LCM_READ_TOPIC), eq(AppcLcmMessageWrapper.class),
any(StandardCoder.class))).thenReturn(appcLcmRead);
- Function<String, Rules> ruleMaker = this::makeRules;
- Supplier<HttpClients> httpClientMaker = this::makeHttpClients;
- Supplier<Simulators> simMaker = this::makeSim;
- Supplier<Topics> topicMaker = this::makeTopics;
+ Function<String, Rules> localRuleMaker = this::makeRules;
+ Supplier<HttpClients> localHttpClientMaker = this::makeHttpClients;
+ Supplier<Simulators> localSimMaker = this::makeSim;
+ Supplier<Topics> localTopicMaker = this::makeTopics;
- ReflectionTestUtils.setField(DroolsRuleTest.class, "ruleMaker", ruleMaker);
- ReflectionTestUtils.setField(DroolsRuleTest.class, "httpClientMaker", httpClientMaker);
- ReflectionTestUtils.setField(DroolsRuleTest.class, "simMaker", simMaker);
- ReflectionTestUtils.setField(DroolsRuleTest.class, "topicMaker", topicMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "ruleMaker", localRuleMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "httpClientMaker", localHttpClientMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "simMaker", localSimMaker);
+ ReflectionTestUtils.setField(DroolsRuleTest.class, "topicMaker", localTopicMaker);
clMgtQueue = new LinkedList<>();
appcLcmQueue = new LinkedList<>();
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@BeforeAll
- public static void setUpBeforeClass() {
+ static void setUpBeforeClass() {
SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
}
@AfterEach
- public void tearDown() {
+ void tearDown() {
HttpClientFactoryInstance.getClientFactory().destroy();
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Creates topics.
*/
@BeforeAll
- public static void setUpBeforeClass() {
+ static void setUpBeforeClass() {
TopicEndpointManager.getManager().shutdown();
var params = new TopicParameters();
}
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
TopicEndpointManager.getManager().shutdown();
}
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
when(mgr.getNoopTopicSink(MY_TOPIC)).thenReturn(sink);
listener = new Listener<>(MY_TOPIC, msg -> msg + MSG_SUFFIX) {
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static int testCount = 0;
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
assertEquals(2, testCount);
}
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private static int testCount = 0;
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
assertEquals(5, testCount);
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Attaches the appender to the logger.
*/
@BeforeAll
- public static void setUpBeforeClass() throws Exception {
+ static void setUpBeforeClass() {
/*
* Attach appender to the logger.
*/
* Stops the appender.
*/
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
appender.stop();
}
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
facts = new LinkedList<>();
ruleListeners = new LinkedList<>();
agendaListeners = new LinkedList<>();
}
@Test
- void testStart() throws Exception {
+ void testStart() {
verify(repo).setConfigurationDir("src/test/resources/config");
assertTrue(installed);
verify(engine).configure(any(Properties.class));
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
simulators = new Simulators();
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
TopicEndpointManager.getManager().shutdown();
}
* Sets up.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
policy = new ToscaPolicy();
policy.setName(POLICY_NAME);
policy.setVersion("1.0.0");