============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
<artifactId>drools-applications-common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>controller-usecases</artifactId>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
+ <version>${version.drools}</version>
<extensions>true</extensions>
</plugin>
</plugins>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hibernate.orm</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-model-compiler</artifactId>
+ <version>${version.drools}</version>
+ </dependency>
</dependencies>
<profiles>
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
throw new ControlLoopException("The Target type is null");
}
switch (event.getTargetType()) {
- case VM:
- case VNF:
+ case VM, VNF:
validateAaiVmVnfData(eventAai);
return;
case PNF:
* 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.
not (EventManagerServices())
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}", drools.getRule().getName());
try {
$params : ControlLoopParams()
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {} : TOSCA-POLICY=[{}]", $params.getClosedLoopControlName(), $params.getPolicyName() + "."
+ drools.getRule().getName(), $params.getToscaPolicy());
end
$policy : ToscaPolicy()
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: [{}|{}|{}|{}]: CONTENT: {}", drools.getRule().getName(),
$policy.getType(), $policy.getTypeVersion(), $policy.getName(),
$policy.getVersion(), $policy);
not ( ToscaPolicy( getName() == $policyName, getVersion() == $policyVersion ) )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: [{}|{}|{}]", drools.getRule().getName(),
$params.getPolicyScope(), $params.getPolicyName(), $params.getPolicyVersion());
getEvent() == $event ) )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: event={}",
$clName, $params.getPolicyName(), drools.getRule().getName(),
$event);
getEvent() == $event )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: event={} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$event, $manager);
getSteps().isEmpty() )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$manager);
!$step.isPreprocessed() )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
$step.acceptsEvent() )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
$step.isPreprocessed() )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
$outcome.isFor("SDNR", $step.getOperationName()) )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
$outcome.isFor($step.getActorName(), $step.getOperationName()) )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
$outcome.isFor($step.getActorName(), $step.getOperationName()) )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
$outcome.isFor($step.getActorName(), $step.getOperationName()) )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
$outcome.isFor($step.getActorName(), $step.getOperationName()) )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
$step : getSteps().peek() )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
notification.setPolicyName($manager.getPolicyName());
notification.setPolicyVersion($manager.getPolicyVersion());
notification.setHistory($manager.getPartialHistory().stream().map(OperationOutcome2::getClOperation)
- .collect(Collectors.toList()));
+ .toList());
// trigger move to the next policy - clear all steps
$manager.getSteps().clear();
$step : getSteps().peek() )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
notification.setPolicyName($manager.getPolicyName());
notification.setPolicyVersion($manager.getPolicyVersion());
notification.setHistory($manager.getPartialHistory().stream().map(OperationOutcome2::getClOperation)
- .collect(Collectors.toList()));
+ .toList());
$manager.deliver("POLICY-CL-MGT", notification, "notification", drools.getRule().getName());
$outcome.isFor($step.getActorName(), $step.getOperationName()) )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
$step : getSteps().peek() )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $outcome.getResult(), $manager);
$step : getSteps().peek() )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: {} manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$step, $manager);
!isActive() || getState() == State.DONE )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}.{}: manager={}",
$manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(),
$manager);
notification.setPolicyName($manager.getPolicyName());
notification.setPolicyVersion($manager.getPolicyVersion());
notification.setHistory($manager.getFullHistory().stream().map(OperationOutcome2::getClOperation)
- .collect(Collectors.toList()));
+ .toList());
OperationFinalResult finalResult = $manager.getFinalResult();
if (finalResult == null) {
$event : VirtualControlLoopEvent( $clName: closedLoopControlName )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {}", $clName, drools.getRule().getName());
logger.debug("{}: {}: orphan event={}",
$clName, drools.getRule().getName(), $event);
* 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.
package org.onap.policy.controlloop;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.policy.controlloop.common.rules.test.DroolsRuleTest;
import org.onap.policy.controlloop.common.rules.test.Listener;
import org.onap.policy.controlloop.common.rules.test.NamedRunner;
* <p/>
* Note: this runs ALL tests (i.e., any whose names start with "test").
*/
-@RunWith(NamedRunner.class)
+@ExtendWith(NamedRunner.class)
@TestNames(prefixes = {"test"})
-
-public class UsecasesTest extends DroolsRuleTest {
+class UsecasesTest extends DroolsRuleTest {
protected static final String CONTROLLER_NAME = "usecases";
/**
* Sets up statics.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
initStatics(CONTROLLER_NAME);
/**
* Cleans up statics.
*/
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
finishStatics();
}
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
init();
}
/**
* Tears down.
*/
- @After
+ @AfterEach
public void tearDown() {
finish();
}
* 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.
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.List;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.eventmanager.StepContext;
-@RunWith(MockitoJUnitRunner.class)
-public class GetTargetEntityOperation2Test {
+class GetTargetEntityOperation2Test {
private static final String GENERIC_VNF_ID = "generic-vnf.vnf-id";
private static final String VSERVER_NAME = "vserver.vserver-name";
private static final String GENERIC_VNF_NAME = "generic-vnf.vnf-name";
private static final String MY_ACTOR = "my-actor";
private static final String MY_OPERATION = "my-operation";
- @Mock
- private StepContext stepContext;
- @Mock
- private ControlLoopOperationParams params;
+ private final StepContext stepContext = mock(StepContext.class);
+ private final ControlLoopOperationParams params = mock(ControlLoopOperationParams.class);
private VirtualControlLoopEvent event;
private GenericVnf vnf;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
event = new VirtualControlLoopEvent();
event.setTarget("pnf.pnf-name");
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// already have the data - no properties needed
assertThat(oper.getPropertyNames()).isEmpty();
}
@Test
- public void testStart() {
+ void testStart() {
assertThatThrownBy(() -> oper.start()).isInstanceOf(UnsupportedOperationException.class)
.hasMessage("cannot start get-target-entity operation");
}
* Tests detmTarget() when the target has already been determined.
*/
@Test
- public void testDetmTargetRepeat() {
+ void testDetmTargetRepeat() {
remakeWithoutData();
assertFalse(oper.getPropertyNames().isEmpty());
* Tests detmTarget() when the target type is {@code null}.
*/
@Test
- public void testDetmTargetNullType() {
+ void testDetmTargetNullType() {
remakeWithoutData();
when(params.getTargetType()).thenReturn(null);
* Tests detmTarget() when the target type is VM and enrichment data is provided.
*/
@Test
- public void testDetmTargetVm() {
+ void testDetmTargetVm() {
when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(VSERVER_NAME);
assertThat(oper.getPropertyNames()).isEmpty();
* Tests detmTarget() when the target type is VNF and enrichment data is provided.
*/
@Test
- public void testDetmTargetVnf() {
+ void testDetmTargetVnf() {
when(params.getTargetType()).thenReturn(TargetType.VNF);
enrichTarget(VSERVER_NAME);
assertThat(oper.getPropertyNames()).isEmpty();
* provided.
*/
@Test
- public void testDetmTargetVfModule() {
+ void testDetmTargetVfModule() {
when(params.getTargetType()).thenReturn(TargetType.VFMODULE);
enrichTarget(VSERVER_NAME);
assertThat(oper.getPropertyNames()).isEmpty();
* Tests detmTarget() when the target type is unknown.
*/
@Test
- public void testDetmTargetUnknownType() {
+ void testDetmTargetUnknownType() {
when(params.getTargetType()).thenReturn(TargetType.VFC);
enrichTarget(VSERVER_NAME);
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames())
}
@Test
- public void testDetmPnfTargetPnf() {
+ void testDetmPnfTargetPnf() {
assertThat(oper.getPropertyNames()).isEmpty();
verifyTarget(MY_PNF);
}
* Tests detmPnfTarget() when the target name is incorrect.
*/
@Test
- public void testDetmPnfTargetInvalidName() {
+ void testDetmPnfTargetInvalidName() {
event.setTarget("unknown-pnf");
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames())
.withMessage("Target does not match target type");
* Tests detmPnfTarget() when the enrichment data is missing.
*/
@Test
- public void testDetmPnfTargetPnfNoEnrichment() {
+ void testDetmPnfTargetPnfNoEnrichment() {
event.setAai(Map.of());
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames())
.withMessage("AAI section is missing pnf.pnf-name");
* Tests detmVfModuleTarget() when the target is null.
*/
@Test
- public void testDetmVfModuleTargetNullTarget() {
+ void testDetmVfModuleTargetNullTarget() {
when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(null);
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames()).withMessage("Target is null");
* Tests detmVfModuleTarget() when the target is the vserver name.
*/
@Test
- public void testDetmVfModuleTargetVserverName() {
+ void testDetmVfModuleTargetVserverName() {
when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(VSERVER_NAME);
assertThat(oper.getPropertyNames()).isEmpty();
* Tests detmVfModuleTarget() when the target is the VNF ID.
*/
@Test
- public void testDetmVfModuleTargetVnfId() {
+ void testDetmVfModuleTargetVnfId() {
when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(GENERIC_VNF_ID);
assertThat(oper.getPropertyNames()).isEmpty();
* data is actually stored in the VNF ID field.
*/
@Test
- public void testDetmVfModuleTargetVnfName() {
+ void testDetmVfModuleTargetVnfName() {
when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(GENERIC_VNF_ID);
* Tests detmVfModuleTarget() when the target is unknown.
*/
@Test
- public void testDetmVfModuleTargetUnknown() {
+ void testDetmVfModuleTargetUnknown() {
when(params.getTargetType()).thenReturn(TargetType.VM);
enrichTarget(VSERVER_NAME);
event.setTarget("unknown-vnf");
* Tests detmVfModuleTarget() when the enrichment data is missing.
*/
@Test
- public void testDetmVfModuleTargetMissingEnrichment() {
+ void testDetmVfModuleTargetMissingEnrichment() {
when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(VSERVER_NAME);
assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames())
* Tests detmVnfName() when enrichment data is available.
*/
@Test
- public void testDetmVnfNameHaveData() {
+ void testDetmVnfNameHaveData() {
when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(GENERIC_VNF_NAME);
event.setAai(Map.of(GENERIC_VNF_ID, MY_VNF));
* Tests detmVnfName() when enrichment data is missing.
*/
@Test
- public void testDetmVnfNameNoData() {
+ void testDetmVnfNameNoData() {
when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(GENERIC_VNF_NAME);
assertThat(oper.getPropertyNames()).isEqualTo(List.of(UsecasesConstants.AAI_DEFAULT_GENERIC_VNF));
}
@Test
- public void testSetProperty() {
+ void testSetProperty() {
event.setTarget(GENERIC_VNF_NAME);
// not a property of interest - should be ignored
}
@Test
- public void testGetActorName_testGetName() {
+ void testGetActorName_testGetName() {
assertEquals(MY_ACTOR, oper.getActorName());
assertEquals(MY_OPERATION, oper.getName());
}
* 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.
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.eventmanager.StepContext;
-@RunWith(MockitoJUnitRunner.class)
-public class LockOperation2Test {
+class LockOperation2Test {
private static final String MY_PNF = "my-pnf";
private static final String MY_VNF = "my-vnf";
private static final String MY_ACTOR = "my-actor";
private static final String MY_OPERATION = "my-operation";
- @Mock
- private StepContext stepContext;
- @Mock
- private ControlLoopOperationParams params;
+ private final StepContext stepContext = mock(StepContext.class);
+ private final ControlLoopOperationParams params = mock(ControlLoopOperationParams.class);
private VirtualControlLoopEvent event;
private CompletableFuture<OperationOutcome> future;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
event = new VirtualControlLoopEvent();
event.setTarget("pnf.pnf-name");
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_TARGET_ENTITY));
}
@Test
- public void testStart() {
+ void testStart() {
// missing data
assertThatIllegalStateException().isThrownBy(() -> oper.start())
.withMessage("target lock entity has not been determined yet");
}
@Test
- public void testSetProperty() {
+ void testSetProperty() {
oper.setProperty("unknown-property", "some data");
assertNull(oper.getTargetEntity());
}
@Test
- public void testGetActorName_testGetName() {
+ void testGetActorName_testGetName() {
assertEquals(MY_ACTOR, oper.getActorName());
assertEquals(MY_OPERATION, oper.getName());
}
* ONAP
* ================================================================================
* Copyright (C) 2020-2021, 2023 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 static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+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.verify;
import static org.mockito.Mockito.when;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Deque;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ExecutorService;
import org.drools.core.WorkingMemory;
import org.drools.core.common.InternalFactHandle;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopException;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.sdnr.PciMessage;
import org.onap.policy.sdnr.PciResponse;
-@RunWith(MockitoJUnitRunner.class)
-public class UsecasesEventManagerTest {
+class UsecasesEventManagerTest {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String CL_NAME = "my-closed-loop-name";
private static final String POLICY_NAME = "my-policy-name";
private static final Coder yamlCoder = new StandardYamlCoder();
private static final String OUTCOME_MSG = "my outcome message";
- @Mock
- private PolicyEngine engineMgr;
- @Mock
- private WorkingMemory workMem;
- @Mock
- private InternalFactHandle factHandle;
- @Mock
- private Operator policyOperator;
- @Mock
- private Operation policyOperation;
- @Mock
- private Actor policyActor;
- @Mock
- private EventManagerServices services;
- @Mock
- private OperationHistoryDataManager dataMgr;
- @Mock
- private ExecutorService executor;
- @Mock
- private Step2 stepa;
- @Mock
- private Step2 stepb;
+ 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 OperationHistoryDataManager dataMgr = mock(OperationHistoryDataManager.class);
+ private final ExecutorService executor = mock(ExecutorService.class);
+ private Step2 stepa = mock(Step2.class);
+ private final Step2 stepb = mock(Step2.class);
private List<LockImpl> locks;
private ToscaPolicy tosca;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() throws ControlLoopException, CoderException {
when(services.getDataManager()).thenReturn(dataMgr);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(POLICY_NAME, mgr.getPolicyName());
assertSame(event, mgr.getEvent());
- Map<String, String> orig = event.getAai();
+ var orig = event.getAai();
event.setAai(addAai(orig, UsecasesConstants.VSERVER_IS_CLOSED_LOOP_DISABLED, "true"));
assertThatThrownBy(() -> new UsecasesEventManager(services, params, event, workMem))
}
@Test
- public void testLoadPreprocessorSteps() {
+ void testLoadPreprocessorSteps() {
stepa = new Step2(mgr, ControlLoopOperationParams.builder().build(), event) {
@Override
public List<String> getPropertyNames() {
mgr.loadPreprocessorSteps();
- Deque<Step2> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
Step2 lockStep = steps.poll();
assertNotNull(lockStep);
* Tests loadPreprocessorSteps() when no additional steps are needed.
*/
@Test
- public void testLoadPreprocessorStepsNothingToLoad() {
+ void testLoadPreprocessorStepsNothingToLoad() {
when(stepa.isPolicyStep()).thenReturn(false);
when(stepa.getPropertyNames()).thenReturn(List.of("unknown-property"));
- Deque<Step2> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
steps.add(stepa);
steps.add(stepb);
* Tests loadPreprocessorSteps() when an A&AI custom query is needed.
*/
@Test
- public void testLoadPreprocessorStepsCq() {
+ void testLoadPreprocessorStepsCq() {
loadStepsWithProperties(OperationProperties.AAI_DEFAULT_CLOUD_REGION, OperationProperties.AAI_DEFAULT_TENANT);
setTargetEntity();
mgr.loadPreprocessorSteps();
- Deque<Step2> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
assertThat(steps.poll()).isInstanceOf(AaiCqStep2.class);
assertSame(stepa, steps.poll());
* Tests loadPreprocessorSteps() when an A&AI PNF query is needed.
*/
@Test
- public void testLoadPreprocessorStepsPnf() {
+ void testLoadPreprocessorStepsPnf() {
// doubling up the property to check both branches
loadStepsWithProperties(OperationProperties.AAI_PNF, OperationProperties.AAI_PNF);
setTargetEntity();
mgr.loadPreprocessorSteps();
- Deque<Step2> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
assertThat(steps.poll()).isInstanceOf(AaiGetPnfStep2.class);
assertSame(stepa, steps.poll());
* Tests loadPreprocessorSteps() when an A&AI Tenant query is needed.
*/
@Test
- public void testLoadPreprocessorStepsTenant() {
+ void testLoadPreprocessorStepsTenant() {
// doubling up the property to check both branches
event.getAai().put(Step2.VSERVER_VSERVER_NAME, "my-vserver");
loadStepsWithProperties(OperationProperties.AAI_VSERVER_LINK, OperationProperties.AAI_VSERVER_LINK);
setTargetEntity();
mgr.loadPreprocessorSteps();
- Deque<Step2> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
assertThat(steps.poll()).isInstanceOf(AaiGetTenantStep2.class);
assertSame(stepa, steps.poll());
* Tests loadPreprocessorSteps() when the target entity is unset.
*/
@Test
- public void testLoadPreprocessorStepsNeedTargetEntity() {
+ void testLoadPreprocessorStepsNeedTargetEntity() {
stepa = new Step2(mgr, ControlLoopOperationParams.builder()
.targetType(TargetType.toTargetType(event.getTargetType())).targetEntityIds(Map.of()).build(),
event) {
}
};
- Deque<Step2> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
steps.add(stepa);
steps.add(stepb);
}
@Test
- public void testIsAbort() {
- OperationOutcome outcome = makeCompletedOutcome();
+ void testIsAbort() {
+ var outcome = makeCompletedOutcome();
outcome.setResult(OperationResult.FAILURE);
// closed loop timeout
}
@Test
- public void testStoreInDataBase() throws ControlLoopException {
+ void testStoreInDataBase() throws ControlLoopException {
mgr.start();
- OperationOutcome outcome = makeOutcome();
+ var outcome = makeOutcome();
mgr.addToHistory(outcome);
mgr.storeInDataBase(mgr.getPartialHistory().peekLast());
}
@Test
- public void testMakeControlLoopResponse() {
- final OperationOutcome outcome = new OperationOutcome();
+ void testMakeControlLoopResponse() {
+ final var outcome = new OperationOutcome();
// no message - should return null
checkResp(outcome, null);
/*
* now work with a PciMessage
*/
- PciMessage msg = new PciMessage();
+ var msg = new PciMessage();
outcome.setResponse(msg);
- PciBody body = new PciBody();
+ var body = new PciBody();
msg.setBody(body);
- PciResponse output = new PciResponse();
+ var output = new PciResponse();
body.setOutput(output);
output.setPayload("my-payload");
}
@Test
- public void testCheckEventSyntax() {
+ void testCheckEventSyntax() {
/*
* only need to check one success and one failure from the super class method
*/
}
@Test
- public void testValidateStatus() {
+ void testValidateStatus() {
/*
* only need to check one success and one failure from the super class method
*/
}
@Test
- public void testValidateAaiData() {
+ void testValidateAaiData() {
event.setTargetType("unknown-target-type");
assertThatCode(() -> mgr.checkEventSyntax(event)).isInstanceOf(ControlLoopException.class)
.hasMessage("The target type is not supported");
}
@Test
- public void testValidateAaiVmVnfData() {
+ void testValidateAaiVmVnfData() {
event.setTargetType(ControlLoopTargetType.VM);
event.setAai(Map.of(UsecasesConstants.GENERIC_VNF_VNF_ID, MY_TARGET));
assertThatCode(() -> mgr.checkEventSyntax(event)).doesNotThrowAnyException();
}
@Test
- public void testValidateAaiPnfData() {
+ void testValidateAaiPnfData() {
event.setTargetType(ControlLoopTargetType.PNF);
event.setAai(Map.of(UsecasesConstants.PNF_NAME, MY_TARGET));
assertThatCode(() -> mgr.checkEventSyntax(event)).doesNotThrowAnyException();
}
@Test
- public void testIsClosedLoopDisabled() {
- Map<String, String> orig = event.getAai();
+ void testIsClosedLoopDisabled() {
+ var orig = event.getAai();
event.setAai(addAai(orig, UsecasesConstants.VSERVER_IS_CLOSED_LOOP_DISABLED, "true"));
assertThatThrownBy(() -> new UsecasesEventManager(services, params, event, workMem))
}
@Test
- public void testIsProvStatusInactive() {
- Map<String, String> orig = event.getAai();
+ void testIsProvStatusInactive() {
+ var orig = event.getAai();
event.setAai(addAai(orig, UsecasesConstants.VSERVER_PROV_STATUS, "ACTIVE"));
assertThatCode(() -> new UsecasesEventManager(services, params, event, workMem)).doesNotThrowAnyException();
}
@Test
- public void testIsAaiTrue() {
- Map<String, String> orig = event.getAai();
+ void testIsAaiTrue() {
+ var orig = event.getAai();
- for (String value : Arrays.asList("yes", "y", "true", "t", "yEs", "trUe")) {
+ for (var value : Arrays.asList("yes", "y", "true", "t", "yEs", "trUe")) {
event.setAai(addAai(orig, UsecasesConstants.VSERVER_IS_CLOSED_LOOP_DISABLED, value));
assertThatThrownBy(() -> new UsecasesEventManager(services, params, event, workMem))
.isInstanceOf(IllegalStateException.class);
}
private void loadPolicy(String fileName) throws CoderException {
- ToscaServiceTemplate template =
- yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
+ var template = yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
tosca = template.getToscaTopologyTemplate().getPolicies().get(0).values().iterator().next();
params.setToscaPolicy(tosca);
}
private OperationOutcome makeCompletedOutcome() {
- OperationOutcome outcome = makeOutcome();
+ var outcome = makeOutcome();
outcome.setEnd(outcome.getStart());
return outcome;
}
private OperationOutcome makeOutcome() {
- OperationOutcome outcome = new OperationOutcome();
+ var outcome = new OperationOutcome();
outcome.setActor(SIMPLE_ACTOR);
outcome.setOperation(SIMPLE_OPERATION);
outcome.setMessage(OUTCOME_MSG);
}
private void checkResp(OperationOutcome outcome, String expectedPayload) {
- ControlLoopResponse resp = mgr.makeControlLoopResponse(outcome);
+ var resp = mgr.makeControlLoopResponse(outcome);
assertNotNull(resp);
assertEquals(REQ_ID, resp.getRequestId());
assertEquals(expectedPayload, resp.getPayload());
@Override
protected void makeLock(String targetEntity, String requestId, int holdSec, LockCallback callback) {
- LockImpl lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback);
+ var lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback);
locks.add(lock);
callback.lockAvailable(lock);
}
* 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.
package org.onap.policy.drools.apps.controller.usecases.step;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+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.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.aai.AaiActor;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.eventmanager.StepContext;
-@RunWith(MockitoJUnitRunner.class)
-public class AaiCqStep2Test {
+class AaiCqStep2Test {
private static final UUID REQ_ID = UUID.randomUUID();
- @Mock
- private Operator policyOperator;
- @Mock
- private Operation policyOperation;
- @Mock
- private Actor policyActor;
- @Mock
- private ActorService actors;
- @Mock
- private ControlLoopOperationParams params;
- @Mock
- private StepContext stepContext;
- @Mock
- private VirtualControlLoopEvent event;
+ private final Operator policyOperator = mock(Operator.class);
+ private final Operation policyOperation = mock(Operation.class);
+ private final Actor policyActor = mock(Actor.class);
+ private final ActorService actors = mock(ActorService.class);
+ private final ControlLoopOperationParams params = mock(ControlLoopOperationParams.class);
+ private final StepContext stepContext = mock(StepContext.class);
+ private final VirtualControlLoopEvent event = mock(VirtualControlLoopEvent.class);
private CompletableFuture<OperationOutcome> future;
private Step2 master;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
future = new CompletableFuture<>();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiActor.NAME, step.getActorName());
assertEquals(AaiCustomQueryOperation.NAME, step.getOperationName());
assertSame(stepContext, step.stepContext);
}
@Test
- public void testStart() {
+ void testStart() {
step.init();
assertTrue(step.start(100));
verify(policyOperation).start();
* Tests start() when the data has already been retrieved.
*/
@Test
- public void testStartAlreadyHaveData() {
+ void testStartAlreadyHaveData() {
when(stepContext.contains(AaiCqResponse.CONTEXT_KEY)).thenReturn(true);
step.init();
}
@Test
- public void testSuccess() {
- AaiCqResponse data = new AaiCqResponse("{}");
- OperationOutcome outcome = new OperationOutcome();
+ void testSuccess() {
+ var data = new AaiCqResponse("{}");
+ var outcome = new OperationOutcome();
outcome.setResponse(data);
step.success(outcome);
* 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.
package org.onap.policy.drools.apps.controller.usecases.step;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+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.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.aai.AaiActor;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.eventmanager.StepContext;
-@RunWith(MockitoJUnitRunner.class)
-public class AaiGetPnfStep2Test {
+class AaiGetPnfStep2Test {
private static final String MY_TARGET = "my-target";
private static final UUID REQ_ID = UUID.randomUUID();
- @Mock
- private Operator policyOperator;
- @Mock
- private Operation policyOperation;
- @Mock
- private Actor policyActor;
- @Mock
- private ActorService actors;
- @Mock
- private ControlLoopOperationParams params;
- @Mock
- private StepContext stepContext;
- @Mock
- private VirtualControlLoopEvent event;
+ private final Operator policyOperator = mock(Operator.class);
+ private final Operation policyOperation = mock(Operation.class);
+ private final Actor policyActor = mock(Actor.class);
+ private final ActorService actors = mock(ActorService.class);
+ private final ControlLoopOperationParams params = mock(ControlLoopOperationParams.class);
+ private final StepContext stepContext = mock(StepContext.class);
+ private final VirtualControlLoopEvent event = mock(VirtualControlLoopEvent.class);
private CompletableFuture<OperationOutcome> future;
private Step2 master;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
future = new CompletableFuture<>();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiActor.NAME, step.getActorName());
assertEquals(AaiGetPnfOperation.NAME, step.getOperationName());
assertSame(stepContext, step.stepContext);
}
@Test
- public void testStart() {
+ void testStart() {
step.init();
assertTrue(step.start(100));
verify(policyOperation).start();
* Tests start() when the data has already been retrieved.
*/
@Test
- public void testStartAlreadyHaveData() {
+ void testStartAlreadyHaveData() {
when(stepContext.contains(AaiGetPnfOperation.getKey(MY_TARGET))).thenReturn(true);
step.init();
}
@Test
- public void testSuccess() {
- StandardCoderObject data = new StandardCoderObject();
- OperationOutcome outcome = new OperationOutcome();
+ void testSuccess() {
+ var data = new StandardCoderObject();
+ var outcome = new OperationOutcome();
outcome.setResponse(data);
step.success(outcome);
* 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.
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+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.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.aai.AaiActor;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.eventmanager.StepContext;
-@RunWith(MockitoJUnitRunner.class)
-public class AaiGetTenantStep2Test {
+class AaiGetTenantStep2Test {
private static final String MY_VSERVER = "my-vserver";
private static final UUID REQ_ID = UUID.randomUUID();
- @Mock
- private Operator policyOperator;
- @Mock
- private Operation policyOperation;
- @Mock
- private Actor policyActor;
- @Mock
- private ActorService actors;
- @Mock
- private ControlLoopOperationParams params;
- @Mock
- private StepContext stepContext;
- @Mock
- private VirtualControlLoopEvent event;
+ private final Operator policyOperator = mock(Operator.class);
+ private final Operation policyOperation = mock(Operation.class);
+ private final Actor policyActor = mock(Actor.class);
+ private final ActorService actors = mock(ActorService.class);
+ private final ControlLoopOperationParams params = mock(ControlLoopOperationParams.class);
+ private final StepContext stepContext = mock(StepContext.class);
+ private final VirtualControlLoopEvent event = mock(VirtualControlLoopEvent.class);
private CompletableFuture<OperationOutcome> future;
private Step2 master;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
future = new CompletableFuture<>();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiActor.NAME, step.getActorName());
assertEquals(AaiGetTenantOperation.NAME, step.getOperationName());
assertSame(stepContext, step.stepContext);
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(step.getPropertyNames()).isEmpty();
}
@Test
- public void testSetProperties() {
+ void testSetProperties() {
step.init();
step.setProperties();
}
@Test
- public void testStart() {
+ void testStart() {
step.init();
assertTrue(step.start(100));
verify(policyOperation).start();
* Tests start() when the data has already been retrieved.
*/
@Test
- public void testStartAlreadyHaveData() {
+ void testStartAlreadyHaveData() {
when(stepContext.contains(AaiGetTenantOperation.getKey(MY_VSERVER))).thenReturn(true);
step.init();
}
@Test
- public void testSuccess() {
- StandardCoderObject data = new StandardCoderObject();
- OperationOutcome outcome = new OperationOutcome();
+ void testSuccess() {
+ var data = new StandardCoderObject();
+ var outcome = new OperationOutcome();
outcome.setResponse(data);
step.success(outcome);
* 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.
package org.onap.policy.drools.apps.controller.usecases.step;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.eventmanager.StepContext;
import org.onap.policy.drools.apps.controller.usecases.GetTargetEntityOperation2;
import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants;
-@RunWith(MockitoJUnitRunner.class)
-public class GetTargetEntityStep2Test {
- @Mock
- private ControlLoopOperationParams params;
- @Mock
- private StepContext stepContext;
- @Mock
- private VirtualControlLoopEvent event;
+class GetTargetEntityStep2Test {
+ private final ControlLoopOperationParams params = mock(ControlLoopOperationParams.class);
+ private final StepContext stepContext = mock(StepContext.class);
+ private final VirtualControlLoopEvent event = mock(VirtualControlLoopEvent.class);
private Step2 master;
private GetTargetEntityStep2 step;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder());
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(UsecasesConstants.GET_TARGET_ENTITY_ACTOR, step.getActorName());
assertEquals(UsecasesConstants.GET_TARGET_ENTITY_OPERATION, step.getOperationName());
assertSame(stepContext, step.stepContext);
}
@Test
- public void testBuildOperation() {
- Operation oper = step.buildOperation();
+ void testBuildOperation() {
+ var oper = step.buildOperation();
assertTrue(oper instanceof GetTargetEntityOperation2);
}
@Test
- public void testStart() {
+ void testStart() {
assertThatIllegalStateException().isThrownBy(() -> step.start(200))
.withMessage("step has not been initialized");
* 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.
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.policy.controlloop.eventmanager.StepContext;
import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants;
-@RunWith(MockitoJUnitRunner.class)
-public class GuardStep2Test {
+class GuardStep2Test {
private static final String SOME_OTHER_VALUE = "some-other-value";
private static final String SOME_OTHER_KEY = "some-other-key";
private static final String CL_NAME = "my-closed-loop";
private static final UUID REQ_ID = UUID.randomUUID();
private static final int VF_COUNT = 10;
- @Mock
- private StepContext stepContext;
- @Mock
- private VirtualControlLoopEvent event;
- @Mock
- private Operation policyOper;
- @Mock
- private AaiCqResponse customQuery;
- @Mock
- private GenericVnf genericVnf;
- @Mock
- private CloudRegion cloudRegion;
- @Mock Vserver theVserver;
-
- TargetType target;
- Map<String, String> aai = new HashMap<>();
+ private final StepContext stepContext = mock(StepContext.class);
+ private final VirtualControlLoopEvent event = mock(VirtualControlLoopEvent.class);
+ private final Operation policyOper = mock(Operation.class);
+ 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<>();
private ControlLoopOperationParams params;
private Step2 master;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
aai.put("vserver.vserver-name", MY_SERVERNAME);
when(event.getAai()).thenReturn(aai);
when(genericVnf.getVnfType()).thenReturn(MY_TYPE);
when(genericVnf.getNfNamingCode()).thenReturn(MY_CODE);
- RelationshipList relList = new RelationshipList();
+ var relList = new RelationshipList();
when(genericVnf.getRelationshipList()).thenReturn(relList);
relList.getRelationship().add(new Relationship());
- Relationship relationship = new Relationship();
+ var relationship = new Relationship();
relList.getRelationship().add(relationship);
relationship.setRelatedTo("vserver");
relationship.getRelatedToProperty().add(new RelatedToProperty());
// property key mismatch
- RelatedToProperty relProp = new RelatedToProperty();
+ var relProp = new RelatedToProperty();
relationship.getRelatedToProperty().add(relProp);
relProp.setPropertyKey(SOME_OTHER_KEY);
relProp.setPropertyValue(MY_NAME);
relProp.setPropertyValue(MY_SERVERNAME);
// data key mismatch
- RelationshipData relData = new RelationshipData();
+ var relData = new RelationshipData();
relationship.getRelationshipData().add(relData);
relData.setRelationshipKey(SOME_OTHER_KEY);
relData.setRelationshipValue(SOME_OTHER_VALUE);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(XacmlActor.NAME, step.getActorName());
assertEquals(GuardOperation.NAME, step.getOperationName());
assertSame(stepContext, step.stepContext);
master = new Step2(stepContext, params, event);
assertThatIllegalStateException().isThrownBy(() -> new GuardStep2(master, CL_NAME));
- ControlLoopOperationParams params2 = step.getParams();
+ var params2 = step.getParams();
// @formatter:off
assertThat(params2.getPayload()).isEqualTo(Map.of(
}
@Test
- public void testAcceptsEvent() {
+ void testAcceptsEvent() {
// it should always accept events
assertTrue(step.acceptsEvent());
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// unmatching property names
when(policyOper.getPropertyNames()).thenReturn(List.of("propA", "propB"));
assertThat(step.getPropertyNames())
}
@Test
- public void testLoadTargetEntity() {
+ void testLoadTargetEntity() {
step.loadTargetEntity(OperationProperties.AAI_TARGET_ENTITY);
assertThat(step.getParams().getPayload()).containsEntry(GuardStep2.PAYLOAD_KEY_TARGET_ENTITY, MY_TARGET);
}
@Test
- public void testLoadDefaultGenericVnf() {
+ void testLoadDefaultGenericVnf() {
step.loadDefaultGenericVnf(OperationProperties.AAI_VNF);
assertThat(step.getParams().getPayload())
.containsEntry(GuardStep2.PAYLOAD_KEY_VNF_ID, MY_TARGET)
}
@Test
- public void testLoadCloudRegion() {
+ void testLoadCloudRegion() {
step.loadCloudRegion(OperationProperties.AAI_DEFAULT_CLOUD_REGION);
assertThat(step.getParams().getPayload()).containsEntry(GuardStep2.PAYLOAD_KEY_CLOUD_REGION_ID, MY_REGION);
}
* Tests loadVfCount() when the policy operation is NOT "VF Module Create".
*/
@Test
- public void testLoadVfCountNotVfModuleCreate() {
+ void testLoadVfCountNotVfModuleCreate() {
// should decrement the count
step.loadVfCount("");
assertThat(step.getParams().getPayload()).containsEntry(GuardStep2.PAYLOAD_KEY_VF_COUNT, VF_COUNT - 1);
* Tests loadVfCount() when the policy operation is "VF Module Create".
*/
@Test
- public void testLoadVfCountVfModuleCreate() {
+ void testLoadVfCountVfModuleCreate() {
when(policyOper.getName()).thenReturn(VfModuleCreate.NAME);
// should increment the count
* 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.
package org.onap.policy.drools.apps.controller.usecases.step;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+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.verify;
import static org.mockito.Mockito.when;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.eventmanager.ActorConstants;
import org.onap.policy.controlloop.eventmanager.StepContext;
-@RunWith(MockitoJUnitRunner.class)
-public class LockStep2Test {
+class LockStep2Test {
private static final String MY_TARGET = "my-target";
- @Mock
- private StepContext stepContext;
- @Mock
- private Operation policyOper;
- @Mock
- private VirtualControlLoopEvent event;
- @Mock
- private Consumer<OperationOutcome> callback;
+ private final StepContext stepContext = mock(StepContext.class);
+ private final Operation policyOper = mock(Operation.class);
+ private final VirtualControlLoopEvent event = mock(VirtualControlLoopEvent.class);
+ private final Consumer<OperationOutcome> callback = mock();
private ControlLoopOperationParams params;
private CompletableFuture<OperationOutcome> future;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
future = new CompletableFuture<>();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(ActorConstants.LOCK_ACTOR, step.getActorName());
assertEquals(ActorConstants.LOCK_OPERATION, step.getOperationName());
assertSame(stepContext, step.stepContext);
}
@Test
- public void testAcceptsEvent() {
+ void testAcceptsEvent() {
// it should always accept events
assertTrue(step.acceptsEvent());
}
@Test
- public void testStart() {
+ void testStart() {
// start the operation
step.init();
step.setProperties();
assertTrue(step.start(100));
// complete the operation's future
- OperationOutcome outcome = step.makeOutcome();
+ var outcome = step.makeOutcome();
outcome.setTarget(MY_TARGET);
future.complete(outcome);
* Tests start when the operation throws an exception.
*/
@Test
- public void testStartNoFuture() {
+ void testStartNoFuture() {
// start the operation
step.init();
* 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.
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.LinkedBlockingQueue;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ModelVer;
import org.onap.policy.controlloop.eventmanager.StepContext;
import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants;
-@RunWith(MockitoJUnitRunner.class)
-public class Step2Test {
+class Step2Test {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String POLICY_ACTOR = "my-actor";
private static final String POLICY_OPERATION = "my-operation";
private static final String NO_SLASH = "noslash";
private static final String ONE_SLASH = "/one";
- @Mock
- private Operator policyOperator;
- @Mock
- private Operation policyOperation;
- @Mock
- private Actor policyActor;
- @Mock
- private ActorService actors;
- @Mock
- private StepContext stepContext;
- @Mock
- private AaiCqResponse aaicq;
+ private final Operator policyOperator = mock(Operator.class);
+ private final Operation policyOperation = mock(Operation.class);
+ private final Actor policyActor = mock(Actor.class);
+ private final ActorService actors = mock(ActorService.class);
+ private final StepContext stepContext = mock(StepContext.class);
+ private final AaiCqResponse aaicq = mock(AaiCqResponse.class);
private Map<String, String> payload;
private VirtualControlLoopEvent event;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
// configure policy operation
when(actors.getActor(POLICY_ACTOR)).thenReturn(policyActor);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertSame(stepContext, step.stepContext);
assertSame(event, step.event);
assertSame(actors, step.getParams().getActorService());
}
@Test
- public void testConstructorStep2() {
+ void testConstructorStep2() {
step = new Step2(step, "actorB", "operationB");
assertSame(stepContext, step.stepContext);
assertSame(event, step.event);
}
@Test
- public void testAcceptsEvent() {
+ void testAcceptsEvent() {
// it's a policy step, thus it accepts events
assertTrue(step.acceptsEvent());
}
@Test
- public void testSuccess() {
+ void testSuccess() {
assertThatCode(() -> step.success(null)).doesNotThrowAnyException();
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// empty property list
assertThat(step.getPropertyNames()).isEmpty();
}
@Test
- public void testSetProperties() {
- CloudRegion cloudRegion = new CloudRegion();
+ void testSetProperties() {
+ var cloudRegion = new CloudRegion();
when(aaicq.getDefaultCloudRegion()).thenReturn(cloudRegion);
- Tenant tenant = new Tenant();
+ var tenant = new Tenant();
when(aaicq.getDefaultTenant()).thenReturn(tenant);
when(policyOperation.getPropertyNames()).thenReturn(
* Tests setProperties() when the property is unknown.
*/
@Test
- public void testSetPropertiesUnknown() {
+ void testSetPropertiesUnknown() {
when(policyOperation.getPropertyNames()).thenReturn(List.of("unknown-property"));
assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties())
}
@Test
- public void testLoadCloudRegion_testGetCloudRegion() {
- CloudRegion data = new CloudRegion();
+ void testLoadCloudRegion_testGetCloudRegion() {
+ var data = new CloudRegion();
when(aaicq.getDefaultCloudRegion()).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_DEFAULT_CLOUD_REGION));
}
@Test
- public void testLoadTenant_testGetTenant() {
- Tenant data = new Tenant();
+ void testLoadTenant_testGetTenant() {
+ var data = new Tenant();
when(aaicq.getDefaultTenant()).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_DEFAULT_TENANT));
}
@Test
- public void testLoadPnf_testGetPnf() {
- StandardCoderObject data = new StandardCoderObject();
+ void testLoadPnf_testGetPnf() {
+ var data = new StandardCoderObject();
when(stepContext.getProperty(OperationProperties.AAI_TARGET_ENTITY)).thenReturn(MY_TARGET);
when(stepContext.getProperty(AaiGetPnfOperation.getKey(MY_TARGET))).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_PNF));
}
@Test
- public void testLoadResourceVnf_testGetResourceVnf() {
+ void testLoadResourceVnf_testGetResourceVnf() {
params.getTargetEntityIds().put(Step2.TARGET_RESOURCE_ID, "my-resource");
- GenericVnf data = new GenericVnf();
+ var data = new GenericVnf();
when(aaicq.getGenericVnfByModelInvariantId("my-resource")).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_RESOURCE_VNF));
}
@Test
- public void testLoadService_testGetService() {
- ServiceInstance data = new ServiceInstance();
+ void testLoadService_testGetService() {
+ var data = new ServiceInstance();
when(aaicq.getServiceInstance()).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_SERVICE));
}
@Test
- public void testLoadServiceModel_testGetServiceModel() {
- ServiceInstance service = new ServiceInstance();
+ void testLoadServiceModel_testGetServiceModel() {
+ var service = new ServiceInstance();
service.setModelVersionId("my-service-version");
when(aaicq.getServiceInstance()).thenReturn(service);
- ModelVer data = new ModelVer();
+ var data = new ModelVer();
when(aaicq.getModelVerByVersionId("my-service-version")).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_SERVICE_MODEL));
}
@Test
- public void testGetVserver() {
- Vserver vserver = new Vserver();
+ void testGetVserver() {
+ var vserver = new Vserver();
when(aaicq.getVserver()).thenReturn(vserver);
assertSame(vserver, step.getVServer());
}
@Test
- public void testGetTargetEntity() {
+ void testGetTargetEntity() {
when(stepContext.getProperty(OperationProperties.AAI_TARGET_ENTITY)).thenReturn(MY_TARGET);
assertEquals(MY_TARGET, step.getTargetEntity());
}
@Test
- public void testLoadVnf_testGetVnf() {
+ void testLoadVnf_testGetVnf() {
params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, "my-model-invariant");
- GenericVnf data = new GenericVnf();
+ var data = new GenericVnf();
when(aaicq.getGenericVnfByVfModuleModelInvariantId("my-model-invariant")).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_VNF));
}
@Test
- public void testLoadVnfModel_testGetVnfModel() {
+ void testLoadVnfModel_testGetVnfModel() {
params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, "my-model-invariant");
- GenericVnf vnf = new GenericVnf();
+ var vnf = new GenericVnf();
when(aaicq.getGenericVnfByVfModuleModelInvariantId("my-model-invariant")).thenReturn(vnf);
vnf.setModelVersionId("my-vnf-model-version-id");
- ModelVer data = new ModelVer();
+ var data = new ModelVer();
when(aaicq.getModelVerByVersionId("my-vnf-model-version-id")).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_VNF_MODEL));
}
@Test
- public void testLoadVserverLink_testGetVserverLink() {
+ void testLoadVserverLink_testGetVserverLink() {
event.setAai(Map.of(Step2.VSERVER_VSERVER_NAME, "vserverB"));
- StandardCoderObject tenant = mock(StandardCoderObject.class);
+ var tenant = mock(StandardCoderObject.class);
when(stepContext.getProperty(AaiGetTenantOperation.getKey("vserverB"))).thenReturn(tenant);
when(tenant.getString("result-data", 0, "resource-link")).thenReturn("/aai/v7/some/link/bbb");
}
@Test
- public void testLoadVfCount_testGetVfCount() {
+ void testLoadVfCount_testGetVfCount() {
params.getTargetEntityIds().put(Step2.TARGET_MODEL_CUSTOMIZATION_ID, "vf-count-customization");
params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, "vf-count-invariant");
params.getTargetEntityIds().put(Step2.TARGET_MODEL_VERSION_ID, "vf-count-version");
}
@Test
- public void testLoadEnrichment_testGetEnrichment() {
+ void testLoadEnrichment_testGetEnrichment() {
event.setAai(Map.of("bandwidth", "bandwidth-value"));
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.ENRICHMENT_BANDWIDTH));
}
@Test
- public void testLoadAdditionalEventParams_testGetAdditionalEventParams() {
+ void testLoadAdditionalEventParams_testGetAdditionalEventParams() {
Map<String, String> data = Map.of("addA", "add-valueA", "addB", "add-valueB");
event.setAdditionalEventParams(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.EVENT_ADDITIONAL_PARAMS));
}
@Test
- public void testLoadEventPayload_testGetEventPayload() {
+ void testLoadEventPayload_testGetEventPayload() {
event.setPayload("some-event-payload");
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.EVENT_PAYLOAD));
}
@Test
- public void testLoadOptCdsGrpcAaiProperties() {
+ void testLoadOptCdsGrpcAaiProperties() {
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES));
step.setProperties();
}
@Test
- public void testLoadDefaultGenericVnf_testGetDefaultGenericVnf() {
- GenericVnf data = new GenericVnf();
+ void testLoadDefaultGenericVnf_testGetDefaultGenericVnf() {
+ var data = new GenericVnf();
when(aaicq.getDefaultGenericVnf()).thenReturn(data);
when(policyOperation.getPropertyNames()).thenReturn(List.of(UsecasesConstants.AAI_DEFAULT_GENERIC_VNF));
}
@Test
- public void testGetCustomQueryData() {
+ void testGetCustomQueryData() {
assertSame(aaicq, step.getCustomQueryData());
when(stepContext.getProperty(AaiCqResponse.CONTEXT_KEY)).thenReturn(null);
}
@Test
- public void testVerifyNotNull() {
+ void testVerifyNotNull() {
assertThatCode(() -> step.verifyNotNull("verifyA", "verify-value-A")).doesNotThrowAnyException();
assertThatIllegalArgumentException().isThrownBy(() -> step.verifyNotNull("verifyB", null))
}
@Test
- public void testStripPrefix() {
+ void testStripPrefix() {
assertEquals(NO_SLASH, Step2.stripPrefix(NO_SLASH, 0));
assertEquals(NO_SLASH, Step2.stripPrefix(NO_SLASH, 1));
assertEquals(NO_SLASH, Step2.stripPrefix(NO_SLASH, 2));
assertEquals("/and/more", Step2.stripPrefix("prefix/three/slashes/and/more", 3));
}
-
}
================================================================================
Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
+ 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.
limitations under the License.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
- <artifactId>drools-applications-common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
+ <artifactId>drools-applications-common</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
- <artifactId>coordination</artifactId>
+ <artifactId>coordination</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>policy-management</artifactId>
- <version>${version.policy.drools-pdp}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-management</artifactId>
+ <version>${version.policy.drools-pdp}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
</project>
* ONAP
* ================================================================================
* Copyright (C) 2019-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.
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.inspector.TagInspector;
public final class Util {
* @return the CoordinationDirective
*/
public static CoordinationDirective loadCoordinationDirectiveFromFile(String directiveFilename) {
- try (var is = new FileInputStream(new File(directiveFilename))) {
+ try (var is = new FileInputStream(directiveFilename)) {
+ var loaderoptions = new LoaderOptions();
+ TagInspector taginspector = tag -> tag.getClassName().equals(CoordinationDirective.class.getName());
+ loaderoptions.setTagInspector(taginspector);
+
var contents = IOUtils.toString(is, StandardCharsets.UTF_8);
//
// Read the yaml into our Java Object
//
- var yaml = new Yaml(new Constructor(CoordinationDirective.class));
+ var yaml = new Yaml(new Constructor(CoordinationDirective.class, loaderoptions));
Object obj = yaml.load(contents);
logger.debug(contents);
* controlloop
* ================================================================================
* Copyright (C) 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.coordination;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class CoordinationDirectiveTest {
+class CoordinationDirectiveTest {
@Test
- public void test() {
+ void test() {
CoordinationDirective cd1 = new CoordinationDirective();
* controlloop
* ================================================================================
* Copyright (C) 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.coordination;
import static org.assertj.core.api.Assertions.assertThatNullPointerException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class UtilTest {
+class UtilTest {
@Test
- public void test() {
+ void test() {
- String filename = "src/test/resources/test_coordination_directive.yaml";
- CoordinationDirective cd1 = Util.loadCoordinationDirectiveFromFile(filename);
+ var filename = "src/test/resources/test_coordination_directive.yaml";
+ var cd1 = Util.loadCoordinationDirectiveFromFile(filename);
assertNotNull(cd1);
assertEquals("cf", cd1.getCoordinationFunction());
filename = "src/test/resources/non_existent_coordination_directive.yaml";
- CoordinationDirective cd2 = Util.loadCoordinationDirectiveFromFile(filename);
+ var cd2 = Util.loadCoordinationDirectiveFromFile(filename);
assertNull(cd2);
<parent>
<groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
<artifactId>drools-applications-common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>eventmanager</artifactId>
<dependencies>
+ <dependency>
+ <groupId>org.hibernate.orm</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
+ <artifactId>hibernate-core-jakarta</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.onap.policy.models</groupId>
- <artifactId>policy-models-decisions</artifactId>
- <version>${policy.models.version}</version>
+ <groupId>org.onap.policy.models</groupId>
+ <artifactId>policy-models-decisions</artifactId>
+ <version>${policy.models.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
package org.onap.policy.controlloop.ophistory;
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
+import jakarta.persistence.Persistence;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Consumer;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
*/
private Properties toProperties(OperationHistoryDataManagerParams params) {
var props = new Properties();
- props.put("javax.persistence.jdbc.driver", params.getDriver());
- props.put("javax.persistence.jdbc.url", params.getUrl());
- props.put("javax.persistence.jdbc.user", params.getUserName());
- props.put("javax.persistence.jdbc.password", params.getPassword());
+ props.put("jakarta.persistence.jdbc.driver", params.getDriver());
+ props.put("jakarta.persistence.jdbc.url", params.getUrl());
+ props.put("jakarta.persistence.jdbc.user", params.getUserName());
+ props.put("jakarta.persistence.jdbc.password", params.getPassword());
props.put("hibernate.dialect", params.getDbHibernateDialect());
return props;
limitations under the License.
============LICENSE_END=========================================================
-->
-<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
+ version="3.0">
<persistence-unit name="OperationsHistoryPU" transaction-type="RESOURCE_LOCAL">
+ <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>org.onap.policy.guard.OperationsHistory</class>
<properties>
- <property name="javax.persistence.schema-generation.database.action" value="create" />
+ <property name="jakarta.persistence.schema-generation.database.action" value="create" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MariaDBDialect" />
<property name="hibernate.show_sql" value="false" />
</properties>
* eventmanager
* ================================================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-20201 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-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.
package org.onap.policy.controlloop;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class ControlLoopExceptionTest {
+class ControlLoopExceptionTest {
@Test
- public void testControlLoopException() {
+ void testControlLoopException() {
new ExceptionsTester().test(ControlLoopException.class);
}
}
* ONAP
* ================================================================================
* Copyright (C) 2020 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.controlloop.drl.legacy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.Validator;
import com.openpojo.validation.ValidatorBuilder;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class ControlLoopParamsTest {
+
+class ControlLoopParamsTest {
private static final String CONTROL_LOOP_NAME = "c";
private static final String POLICY_NAME = "m";
private static final String POLICY_SCOPE = "s";
private static final String POLICY_VERSION = "v";
- private ControlLoopParams clp = new ControlLoopParams();
+ private final ControlLoopParams clp = new ControlLoopParams();
/**
* Prepare tests.
*/
- @Before
+ @BeforeEach
public void setUp() {
clp.setClosedLoopControlName(CONTROL_LOOP_NAME);
clp.setPolicyName(POLICY_NAME);
}
@Test
- public void testPojo() {
- PojoClass controlLoopParams = PojoClassFactory.getPojoClass(ControlLoopParams.class);
- Validator validator = ValidatorBuilder.create()
+ void testPojo() {
+ var controlLoopParams = PojoClassFactory.getPojoClass(ControlLoopParams.class);
+ var validator = ValidatorBuilder.create()
.with(new SetterTester(), new GetterTester()).build();
validator.validate(controlLoopParams);
}
@Test
- public void getClosedLoopControlName() {
+ void getClosedLoopControlName() {
assertEquals(CONTROL_LOOP_NAME, clp.getClosedLoopControlName());
}
@Test
- public void getPolicyName() {
+ void getPolicyName() {
assertEquals(POLICY_NAME, clp.getPolicyName());
}
@Test
- public void getPolicyScope() {
+ void getPolicyScope() {
assertEquals(POLICY_SCOPE, clp.getPolicyScope());
}
@Test
- public void getPolicyVersion() {
+ void getPolicyVersion() {
assertEquals(POLICY_VERSION, clp.getPolicyVersion());
}
@Test
- public void setClosedLoopControlName() {
+ void setClosedLoopControlName() {
clp.setClosedLoopControlName(CONTROL_LOOP_NAME.toUpperCase());
assertEquals(CONTROL_LOOP_NAME.toUpperCase(), clp.getClosedLoopControlName());
}
@Test
- public void setPolicyName() {
+ void setPolicyName() {
clp.setPolicyName(POLICY_NAME.toUpperCase());
assertEquals(POLICY_NAME.toUpperCase(), clp.getPolicyName());
}
@Test
- public void setPolicyScope() {
+ void setPolicyScope() {
clp.setPolicyScope(POLICY_SCOPE.toUpperCase());
assertEquals(POLICY_SCOPE.toUpperCase(), clp.getPolicyScope());
}
@Test
- public void setPolicyVersion() {
+ void setPolicyVersion() {
clp.setPolicyVersion(POLICY_VERSION.toUpperCase());
assertEquals(POLICY_VERSION.toUpperCase(), clp.getPolicyVersion());
}
@Test
- public void testTwo() {
- ControlLoopParams other = new ControlLoopParams();
+ void testTwo() {
+ var other = new ControlLoopParams();
other.setClosedLoopControlName(CONTROL_LOOP_NAME);
other.setPolicyName(POLICY_NAME);
other.setPolicyScope(POLICY_SCOPE);
* ONAP
* ================================================================================
* Copyright (C) 2021, 2023 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 static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.concurrent.atomic.AtomicReference;
import org.drools.core.WorkingMemory;
import org.drools.core.common.InternalFactHandle;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopException;
-import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-@RunWith(MockitoJUnitRunner.class)
-public class ClEventManagerWithEventTest {
+class ClEventManagerWithEventTest {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String CL_NAME = "my-closed-loop-name";
private static final String POLICY_NAME = "my-policy-name";
private static final Coder yamlCoder = new StandardYamlCoder();
private static final String OUTCOME_MSG = "my outcome message";
- @Mock
- private PolicyEngine engineMgr;
- @Mock
- private WorkingMemory workMem;
- @Mock
- private InternalFactHandle factHandle;
- @Mock
- private Operator policyOperator;
- @Mock
- private Operation policyOperation;
- @Mock
- private Actor policyActor;
- @Mock
- private EventManagerServices services;
- @Mock
- private ActorService actors;
- @Mock
- private OperationHistoryDataManager dataMgr;
- @Mock
- private ExecutorService executor;
- @Mock
- private MyStep stepa;
- @Mock
- private MyStep stepb;
+ 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 ActorService actors = mock(ActorService.class);
+ private final OperationHistoryDataManager dataMgr = mock(OperationHistoryDataManager.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.
*/
- @Before
+ @BeforeEach
public void setUp() throws ControlLoopException, CoderException {
when(services.getActorService()).thenReturn(actors);
when(services.getDataManager()).thenReturn(dataMgr);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(POLICY_NAME, mgr.getPolicyName());
assertSame(event, mgr.getEvent());
}
@Test
- public void testPopulateNotification() throws Exception {
+ void testPopulateNotification() throws Exception {
loadPolicy(EVENT_MGR_MULTI_YAML);
mgr = new MyManager(services, params, event, workMem);
}
@Test
- public void testStoreInDataBase() throws ControlLoopException {
+ void testStoreInDataBase() throws ControlLoopException {
mgr.start();
OperationOutcome outcome = makeOutcome();
mgr.addToHistory(outcome);
}
@Test
- public void testMakeControlLoopResponse() {
- final OperationOutcome outcome = new OperationOutcome();
+ void testMakeControlLoopResponse() {
+ final var outcome = new OperationOutcome();
- ControlLoopResponse resp = mgr.makeControlLoopResponse(outcome);
+ var resp = mgr.makeControlLoopResponse(outcome);
assertNotNull(resp);
assertEquals("DCAE", resp.getTarget());
assertEquals(event.getClosedLoopControlName(), resp.getClosedLoopControlName());
}
@Test
- public void testOnNewEvent() {
- VirtualControlLoopEvent event2 = new VirtualControlLoopEvent(event);
+ void testOnNewEvent() {
+ var event2 = new VirtualControlLoopEvent(event);
assertEquals(NewEventStatus.FIRST_ONSET, mgr.onNewEvent(event2));
event2.setPayload("other payload");
}
@Test
- public void testCheckEventSyntax() {
+ void testCheckEventSyntax() {
// initially, it's valid
assertThatCode(() -> mgr.checkEventSyntax(event)).doesNotThrowAnyException();
}
@Test
- public void testValidateStatus() {
+ void testValidateStatus() {
event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
assertThatCode(() -> mgr.checkEventSyntax(event)).doesNotThrowAnyException();
}
private void loadPolicy(String fileName) throws CoderException {
- ToscaServiceTemplate template =
+ var template =
yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
tosca = template.getToscaTopologyTemplate().getPolicies().get(0).values().iterator().next();
}
private OperationOutcome makeCompletedOutcome() {
- OperationOutcome outcome = makeOutcome();
+ var outcome = makeOutcome();
outcome.setEnd(outcome.getStart());
return outcome;
}
private OperationOutcome makeOutcome() {
- OperationOutcome outcome = new OperationOutcome();
+ var outcome = new OperationOutcome();
outcome.setActor(SIMPLE_ACTOR);
outcome.setOperation(SIMPLE_OPERATION);
outcome.setMessage(OUTCOME_MSG);
* ONAP
* ================================================================================
* Copyright (C) 2021, 2023 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 static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+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;
import java.time.Instant;
import java.util.concurrent.atomic.AtomicReference;
import org.drools.core.WorkingMemory;
import org.drools.core.common.InternalFactHandle;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
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.ControlLoopResponse;
-import org.onap.policy.controlloop.VirtualControlLoopNotification;
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.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-@RunWith(MockitoJUnitRunner.class)
-public class ClEventManagerWithOutcomeTest {
+class ClEventManagerWithOutcomeTest {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String CL_NAME = "my-closed-loop-name";
private static final String POLICY_NAME = "my-policy-name";
private static final Coder yamlCoder = new StandardYamlCoder();
private static final String OUTCOME_MSG = "my outcome message";
- @Mock
- private PolicyEngine engineMgr;
- @Mock
- private WorkingMemory workMem;
- @Mock
- private InternalFactHandle factHandle;
- @Mock
- private Operator policyOperator;
- @Mock
- private Operation policyOperation;
- @Mock
- private Actor policyActor;
- @Mock
- private EventManagerServices services;
- @Mock
- private ExecutorService executor;
- @Mock
- private MyStep stepa;
- @Mock
- private MyStep stepb;
+ 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.
*/
- @Before
+ @BeforeEach
public void setUp() throws ControlLoopException, CoderException {
when(workMem.getFactHandle(any())).thenReturn(factHandle);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(POLICY_NAME, mgr.getPolicyName());
// invalid
}
@Test
- public void testLoadNextPolicy_testGetFullHistory_testGetPartialHistory() throws Exception {
+ void testLoadNextPolicy_testGetFullHistory_testGetPartialHistory() throws Exception {
loadPolicy(EVENT_MGR_MULTI_YAML);
mgr = new MyManager(services, params, REQ_ID, workMem);
assertNull(mgr.getFinalResult());
// add an outcome
- OperationOutcome outcome = makeOutcome();
+ var outcome = makeOutcome();
mgr.addToHistory(outcome);
// indicate success and load next policy
}
@Test
- public void testExecuteStep() {
+ void testExecuteStep() {
mgr.bumpAttempts();
// no steps to execute
}
@Test
- public void testBumpAttempts() {
+ void testBumpAttempts() {
assertEquals(0, mgr.getAttempts());
mgr.bumpAttempts();
}
@Test
- public void testIsAbort() {
- OperationOutcome outcome = makeCompletedOutcome();
+ void testIsAbort() {
+ var outcome = makeCompletedOutcome();
outcome.setResult(OperationResult.FAILURE);
assertTrue(mgr.isAbort(outcome));
}
@Test
- public void testAddToHistory() throws ControlLoopException {
+ void testAddToHistory() throws ControlLoopException {
mgr.start();
// add a "start" outcome
- OperationOutcome outcome = makeOutcome();
+ var outcome = makeOutcome();
mgr.addToHistory(outcome);
assertThat(mgr.getPartialHistory()).hasSize(1);
}
@Test
- public void testMakeNotification() throws Exception {
+ void testMakeNotification() throws Exception {
loadPolicy(EVENT_MGR_MULTI_YAML);
mgr = new MyManager(services, params, REQ_ID, workMem);
mgr.addToHistory(makeCompletedOutcome());
// check notification while running
- VirtualControlLoopNotification notif = mgr.makeNotification();
+ var notif = mgr.makeNotification();
assertThat(notif.getMessage()).contains(SIMPLE_ACTOR);
assertThat(notif.getHistory()).hasSize(3);
}
@Test
- public void testGetOperationMessage() throws ControlLoopException {
+ void testGetOperationMessage() throws ControlLoopException {
// no history yet
assertNull(mgr.getOperationMessage());
// add an outcome
mgr.start();
- OperationOutcome outcome = makeOutcome();
+ var outcome = makeOutcome();
mgr.addToHistory(outcome);
assertThat(mgr.getOperationMessage()).contains("actor=" + SIMPLE_ACTOR)
}
@Test
- public void testMakeControlLoopResponse() {
- final OperationOutcome outcome = new OperationOutcome();
+ void testMakeControlLoopResponse() {
+ final var outcome = new OperationOutcome();
outcome.setActor(SIMPLE_ACTOR);
- ControlLoopResponse resp = mgr.makeControlLoopResponse(outcome);
+ var resp = mgr.makeControlLoopResponse(outcome);
assertNotNull(resp);
assertEquals(SIMPLE_ACTOR, resp.getFrom());
}
private void loadPolicy(String fileName) throws CoderException {
- ToscaServiceTemplate template =
- yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
+ var template = yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
tosca = template.getToscaTopologyTemplate().getPolicies().get(0).values().iterator().next();
params.setToscaPolicy(tosca);
}
private OperationOutcome makeCompletedOutcome() {
- OperationOutcome outcome = makeOutcome();
+ var outcome = makeOutcome();
outcome.setEnd(outcome.getStart());
return outcome;
}
private OperationOutcome makeOutcome() {
- OperationOutcome outcome = new OperationOutcome();
+ var outcome = new OperationOutcome();
outcome.setActor(SIMPLE_ACTOR);
outcome.setOperation(SIMPLE_OPERATION);
outcome.setMessage(OUTCOME_MSG);
@Override
protected void makeLock(String targetEntity, String requestId, int holdSec, LockCallback callback) {
- LockImpl lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback);
+ var lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback);
locks.add(lock);
callback.lockAvailable(lock);
}
* ONAP
* ================================================================================
* Copyright (C) 2021, 2023 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 static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.Deque;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicReference;
import org.drools.core.WorkingMemory;
import org.drools.core.common.InternalFactHandle;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-@RunWith(MockitoJUnitRunner.class)
-public class ClEventManagerWithStepsTest {
+class ClEventManagerWithStepsTest {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String CL_NAME = "my-closed-loop-name";
private static final String POLICY_NAME = "my-policy-name";
private static final String OUTCOME_MSG = "my outcome message";
private static final String MY_SINK = "my-topic-sink";
- @Mock
- private PolicyEngine engineMgr;
- @Mock
- private WorkingMemory workMem;
- @Mock
- private InternalFactHandle factHandle;
- @Mock
- private Operator policyOperator;
- @Mock
- private Operation policyOperation;
- @Mock
- private Actor policyActor;
- @Mock
- private ExecutorService executor;
- @Mock
- private EventManagerServices services;
- @Mock
- private ActorService actors;
- @Mock
- private MyStep stepa;
- @Mock
- private MyStep stepb;
+ 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 ExecutorService executor = mock(ExecutorService.class);
+ private final EventManagerServices services = mock(EventManagerServices.class);
+ private final ActorService actors = mock(ActorService.class);
+ private MyStep stepa = mock(MyStep.class);
+ private final MyStep stepb = mock(MyStep.class);
private List<LockImpl> locks;
private ToscaPolicy tosca;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() throws ControlLoopException, CoderException {
when(services.getActorService()).thenReturn(actors);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(POLICY_NAME, mgr.getPolicyName());
// invalid
}
@Test
- public void testDestroy_testGetSteps() {
+ void testDestroy_testGetSteps() {
// add some steps to the queue
mgr.getSteps().add(stepa);
mgr.getSteps().add(stepb);
}
@Test
- public void testOnStart() throws ControlLoopException {
- OperationOutcome outcome = makeOutcome();
+ void testOnStart() throws ControlLoopException {
+ var outcome = makeOutcome();
mgr.start();
mgr.onStart(outcome);
}
@Test
- public void testOnComplete() throws ControlLoopException {
- OperationOutcome outcome = makeCompletedOutcome();
+ void testOnComplete() throws ControlLoopException {
+ var outcome = makeCompletedOutcome();
mgr.start();
mgr.onComplete(outcome);
}
@Test
- public void testToString() {
+ void testToString() {
assertNotNull(mgr.toString());
}
@Test
- public void testStart() throws ControlLoopException {
+ void testStart() throws ControlLoopException {
// start it
mgr.start();
* Tests start() when the manager is not in working memory.
*/
@Test
- public void testStartNotInWorkingMemory() throws ControlLoopException {
+ void testStartNotInWorkingMemory() throws ControlLoopException {
when(workMem.getFactHandle(any())).thenReturn(null);
assertThatCode(() -> mgr.start()).isInstanceOf(IllegalStateException.class)
* Tests start() when the manager is not active.
*/
@Test
- public void testStartInactive() throws Exception {
+ void testStartInactive() throws Exception {
// make an inactive manager by deserializing it
- RealManager mgr2 = Serializer.roundTrip(new RealManager(services, params, REQ_ID, workMem));
- mgr = mgr2;
+ mgr = Serializer.roundTrip(new RealManager(services, params, REQ_ID, workMem));
// cannot re-start
assertThatCode(() -> mgr.start()).isInstanceOf(IllegalStateException.class)
}
@Test
- public void testAbort() {
+ void testAbort() {
mgr.abort(ClEventManagerWithSteps.State.DONE, OperationFinalResult.FINAL_FAILURE_GUARD, "some message");
assertEquals(ClEventManagerWithSteps.State.DONE, mgr.getState());
}
@Test
- public void testLoadPolicy() throws ControlLoopException {
+ void testLoadPolicy() throws ControlLoopException {
// start() will invoke loadPolicy()
mgr.start();
assertNull(mgr.getFinalResult());
- MyStep step = mgr.getSteps().peek();
+ var step = mgr.getSteps().peek();
assertNotNull(step);
assertEquals("First", step.getActorName());
assertEquals("OperationA", step.getOperationName());
- ControlLoopOperationParams params2 = step.getParams();
+ var params2 = step.getParams();
assertSame(actors, params2.getActorService());
assertSame(REQ_ID, params2.getRequestId());
assertSame(ForkJoinPool.commonPool(), params2.getExecutor());
}
@Test
- public void testLoadPreprocessorSteps() {
+ void testLoadPreprocessorSteps() {
stepa = new MyStep(mgr, ControlLoopOperationParams.builder().build()) {
@Override
protected Operation buildOperation() {
}
};
- Deque<MyStep> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
steps.add(stepa);
steps.add(stepb);
* Tests loadPreprocessorSteps() when there are too many steps in the queue.
*/
@Test
- public void testLoadPreprocessorStepsTooManySteps() {
+ void testLoadPreprocessorStepsTooManySteps() {
stepa = new MyStep(mgr, ControlLoopOperationParams.builder().build()) {
@Override
protected Operation buildOperation() {
}
};
- Deque<MyStep> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
// load up a bunch of steps
for (int nsteps = 0; nsteps < ClEventManagerWithSteps.MAX_STEPS; ++nsteps) {
}
@Test
- public void testExecuteStep() {
+ void testExecuteStep() {
// no steps to execute
assertFalse(mgr.executeStep());
}
@Test
- public void testNextStep() {
+ void testNextStep() {
mgr.getSteps().add(stepa);
mgr.nextStep();
}
@Test
- public void testDeliver() {
+ void testDeliver() {
mgr.deliver(MY_SINK, null, "null notification", "null rule");
verify(engineMgr, never()).deliver(any(), any());
}
private void loadPolicy(String fileName) throws CoderException {
- ToscaServiceTemplate template =
- yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
+ var template = yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
tosca = template.getToscaTopologyTemplate().getPolicies().get(0).values().iterator().next();
params.setToscaPolicy(tosca);
}
private OperationOutcome makeCompletedOutcome() {
- OperationOutcome outcome = makeOutcome();
+ var outcome = makeOutcome();
outcome.setEnd(outcome.getStart());
return outcome;
}
private OperationOutcome makeOutcome() {
- OperationOutcome outcome = new OperationOutcome();
+ var outcome = new OperationOutcome();
outcome.setActor(SIMPLE_ACTOR);
outcome.setOperation(SIMPLE_OPERATION);
outcome.setMessage(OUTCOME_MSG);
@Override
protected void makeLock(String targetEntity, String requestId, int holdSec, LockCallback callback) {
- LockImpl lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback);
+ var lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback);
locks.add(lock);
callback.lockAvailable(lock);
}
* 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.
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-@RunWith(MockitoJUnitRunner.class)
-public class ControlLoopEventManagerTest {
+class ControlLoopEventManagerTest {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String CL_NAME = "my-closed-loop-name";
private static final Coder yamlCoder = new StandardYamlCoder();
private static final String MY_KEY = "def";
- @Mock
- private ExecutorService executor;
- @Mock
- private EventManagerServices services;
- @Mock
- private OperationHistoryDataManager dataMgr;
+ private final ExecutorService executor = mock(ExecutorService.class);
+ private final EventManagerServices services = mock(EventManagerServices.class);
+ private final OperationHistoryDataManager dataMgr = mock(OperationHistoryDataManager.class);
private long preCreateTimeMs;
private List<LockImpl> locks;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() throws ControlLoopException, CoderException {
when(services.getDataManager()).thenReturn(dataMgr);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(POLICY_NAME, mgr.getPolicyName());
assertTrue(mgr.isActive());
}
@Test
- public void testGetCreateCount() throws ControlLoopException {
+ void testGetCreateCount() throws ControlLoopException {
long original = ControlLoopEventManager.getCreateCount();
new MyManager(services, params, REQ_ID);
}
@Test
- public void testIsActive() throws Exception {
+ void testIsActive() throws Exception {
mgr = new ControlLoopEventManager(services, params, REQ_ID);
assertTrue(mgr.isActive());
- ControlLoopEventManager mgr2 = Serializer.roundTrip(mgr);
+ var mgr2 = Serializer.roundTrip(mgr);
assertFalse(mgr2.isActive());
}
@Test
- public void testDestroy() throws IOException {
+ void testDestroy() throws IOException {
mgr.requestLock(LOCK1);
mgr.requestLock(LOCK2);
mgr.requestLock(LOCK1);
// ensure destroy() doesn't throw an exception if the object is deserialized
- ControlLoopEventManager mgr2 = Serializer.roundTrip(mgr);
+ var mgr2 = Serializer.roundTrip(mgr);
assertThatCode(() -> mgr2.destroy()).doesNotThrowAnyException();
// locks should not have been freed
- for (LockImpl lock : locks) {
+ for (var lock : locks) {
assertFalse(lock.isUnavailable());
}
runExecutor();
- for (LockImpl lock : locks) {
+ for (var lock : locks) {
assertTrue(lock.isUnavailable());
}
}
@Test
- public void testDetmControlLoopTimeoutMs() throws Exception {
+ void testDetmControlLoopTimeoutMs() throws Exception {
long timeMs = 1200 * 1000L;
long end = mgr.getEndTimeMs();
assertThat(end).isGreaterThanOrEqualTo(preCreateTimeMs + timeMs).isLessThan(preCreateTimeMs + timeMs + 5000);
}
@Test
- public void testRequestLock() {
- final CompletableFuture<OperationOutcome> future1 = mgr.requestLock(LOCK1);
+ void testRequestLock() {
+ final var future1 = mgr.requestLock(LOCK1);
assertTrue(mgr.getOutcomes().isEmpty());
- final CompletableFuture<OperationOutcome> future2 = mgr.requestLock(LOCK2);
+ final var future2 = mgr.requestLock(LOCK2);
assertTrue(mgr.getOutcomes().isEmpty());
assertSame(future1, mgr.requestLock(LOCK1));
}
@Test
- public void testReleaseLock() {
+ void testReleaseLock() {
mgr.requestLock(LOCK1);
mgr.requestLock(LOCK2);
// release one lock
- final CompletableFuture<OperationOutcome> future = mgr.releaseLock(LOCK1);
+ final var future = mgr.releaseLock(LOCK1);
// asynchronous, thus should not have executed yet
assertThat(future.isDone()).isFalse();
// asynchronous, thus everything should still be locked
- for (LockImpl lock : locks) {
+ for (var lock : locks) {
assertThat(lock.isUnavailable()).isFalse();
}
* Tests releaseLock() when there is no lock.
*/
@Test
- public void testReleaseLockNotLocked() {
- final CompletableFuture<OperationOutcome> future = mgr.releaseLock(LOCK1);
+ void testReleaseLockNotLocked() {
+ final var future = mgr.releaseLock(LOCK1);
// lock didn't exist, so the request should already be complete
assertThat(future.isDone()).isTrue();
* Tests releaseLock() when lock.free() throws an exception.
*/
@Test
- public void testReleaseLockException() throws ControlLoopException {
+ void testReleaseLockException() throws ControlLoopException {
mgr = new MyManager(services, params, REQ_ID) {
private static final long serialVersionUID = 1L;
@Override
protected void makeLock(String targetEntity, String requestId, int holdSec, LockCallback callback) {
- LockImpl lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback) {
+ var lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback) {
private static final long serialVersionUID = 1L;
@Override
mgr.requestLock(LOCK1);
// release the lock
- final CompletableFuture<OperationOutcome> future = mgr.releaseLock(LOCK1);
+ final var future = mgr.releaseLock(LOCK1);
// asynchronous, thus should not have executed yet
assertThat(future.isDone()).isFalse();
}
private void verifyLock(OperationResult result, String lockOperation) {
- OperationOutcome outcome = mgr.getOutcomes().poll();
+ var outcome = mgr.getOutcomes().poll();
assertNotNull(outcome);
assertEquals(ActorConstants.LOCK_ACTOR, outcome.getActor());
assertEquals(lockOperation, outcome.getOperation());
}
@Test
- public void testOnStart() {
- OperationOutcome outcome1 = new OperationOutcome();
- OperationOutcome outcome2 = new OperationOutcome();
+ void testOnStart() {
+ var outcome1 = new OperationOutcome();
+ var outcome2 = new OperationOutcome();
mgr.onStart(outcome1);
mgr.onStart(outcome2);
}
@Test
- public void testOnComplete() {
- OperationOutcome outcome1 = new OperationOutcome();
- OperationOutcome outcome2 = new OperationOutcome();
+ void testOnComplete() {
+ var outcome1 = new OperationOutcome();
+ var outcome2 = new OperationOutcome();
mgr.onComplete(outcome1);
mgr.onComplete(outcome2);
}
@Test
- public void testContains_testGetProperty_testSetProperty_testRemoveProperty() {
+ void testContains_testGetProperty_testSetProperty_testRemoveProperty() {
mgr.setProperty("abc", "a string");
mgr.setProperty(MY_KEY, 100);
assertTrue(mgr.contains(MY_KEY));
assertFalse(mgr.contains("ghi"));
- String strValue = mgr.getProperty("abc");
+ var strValue = mgr.getProperty("abc");
assertEquals("a string", strValue);
int intValue = mgr.getProperty(MY_KEY);
* Tests getDataManager() when not disabled.
*/
@Test
- public void testGetDataManagerNotDisabled() throws ControlLoopException {
+ void testGetDataManagerNotDisabled() throws ControlLoopException {
assertThat(mgr.getDataManager()).isSameAs(dataMgr);
}
* Tests getDataManager() when guard.disabled=true.
*/
@Test
- public void testGetDataManagerDisabled() throws ControlLoopException {
+ void testGetDataManagerDisabled() throws ControlLoopException {
mgr = new MyManager(services, params, REQ_ID) {
private static final long serialVersionUID = 1L;
}
@Test
- public void testToString() {
+ void testToString() {
assertNotNull(mgr.toString());
}
private void loadPolicy(String fileName) throws CoderException {
- ToscaServiceTemplate template =
- yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
+ var template = yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
tosca = template.getToscaTopologyTemplate().getPolicies().get(0).values().iterator().next();
params.setToscaPolicy(tosca);
}
private void runExecutor() {
- ArgumentCaptor<Runnable> runCaptor = ArgumentCaptor.forClass(Runnable.class);
+ var runCaptor = ArgumentCaptor.forClass(Runnable.class);
verify(executor).execute(runCaptor.capture());
runCaptor.getValue().run();
@Override
protected void makeLock(String targetEntity, String requestId, int holdSec, LockCallback callback) {
- LockImpl lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback);
+ var lock = new LockImpl(LockState.ACTIVE, targetEntity, requestId, holdSec, callback);
locks.add(lock);
callback.lockAvailable(lock);
}
* ONAP
* ================================================================================
* Copyright (C) 2020 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 static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+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;
-import java.util.Properties;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.controlloop.actorserviceprovider.ActorService;
import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerImpl;
import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerStub;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
-public class EventManagerServicesTest {
+class EventManagerServicesTest {
private static final String FILEPFX = "eventService/";
private static final IllegalArgumentException EXPECTED_EXCEPTION =
new IllegalArgumentException("expected exception");
/**
* Configures HTTP clients.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
// start with a clean slate
HttpClientFactoryInstance.getClientFactory().destroy();
SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
- Properties props = SystemPersistenceConstants.getManager().getProperties("eventService/event-svc-http-client");
+ var props = SystemPersistenceConstants.getManager().getProperties("eventService/event-svc-http-client");
HttpClientFactoryInstance.getClientFactory().build(props);
}
- @AfterClass
+ @AfterAll
public static void teatDownBeforeClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
}
- @After
+ @AfterEach
public void tearDown() {
closeDb();
}
@Test
- public void testEventManagerServices_testGetActorService() {
+ void testEventManagerServices_testGetActorService() {
// try with guard disabled - should use DB stub
services = new EventManagerServices(FILEPFX + "event-svc-guard-disabled");
assertTrue(services.getDataManager() instanceof OperationHistoryDataManagerStub);
}
@Test
- public void testStartActorService() {
+ void testStartActorService() {
// config file not found
assertThatIllegalStateException().isThrownBy(() -> new EventManagerServices("missing-config-file"));
}
@Test
- public void testIsGuardEnabled() {
+ void testIsGuardEnabled() {
// cannot check guard
services = new EventManagerServices(FILEPFX + "event-svc-no-guard-actor");
assertTrue(services.getDataManager() instanceof OperationHistoryDataManagerStub);
services = new EventManagerServices(FILEPFX + "event-svc-with-db") {
@Override
public ActorService getActorService() {
- ActorService svc = mock(ActorService.class);
+ var svc = mock(ActorService.class);
when(svc.getActor(any())).thenThrow(EXPECTED_EXCEPTION);
return svc;
}
}
@Test
- public void testMakeDataManager() {
+ void testMakeDataManager() {
assertThatThrownBy(() -> new EventManagerServices(FILEPFX + "event-svc-invalid-db"))
.isInstanceOf(IllegalArgumentException.class);
}
* 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.
package org.onap.policy.controlloop.eventmanager;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-import java.time.Instant;
import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.drools.core.lock.Lock;
-@RunWith(MockitoJUnitRunner.class)
-public class LockDataTest {
+class LockDataTest {
private static final String ENTITY = "my-entity";
private static final UUID REQ_ID = UUID.randomUUID();
- @Mock
- private Lock lock;
- @Mock
- private Consumer<OperationOutcome> callback1;
- @Mock
- private Consumer<OperationOutcome> callback2;
- @Mock
- private Consumer<OperationOutcome> callback3;
+ private final Lock lock = mock(Lock.class);
+ private final Consumer<OperationOutcome> callback1 = mock();
+ private final Consumer<OperationOutcome> callback2 = mock();
+ private final Consumer<OperationOutcome> callback3 = mock();
private LockData data;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
data = new LockData(ENTITY, REQ_ID);
}
@Test
- public void testGetFuture() {
- CompletableFuture<OperationOutcome> future = data.getFuture();
+ void testGetFuture() {
+ var future = data.getFuture();
assertNotNull(future);
assertFalse(future.isDone());
}
@Test
- public void testAddUnavailableCallback() {
+ void testAddUnavailableCallback() {
data.addUnavailableCallback(callback1);
data.addUnavailableCallback(callback2);
* Tests addUnavailableCallback() when the lock never becomes available.
*/
@Test
- public void testAddUnavailableCallbackNeverAvailable() {
+ void testAddUnavailableCallbackNeverAvailable() {
data.addUnavailableCallback(callback1);
data.addUnavailableCallback(callback2);
}
@Test
- public void testFree() {
+ void testFree() {
// no lock yet
assertThatCode(() -> data.free()).doesNotThrowAnyException();
}
@Test
- public void testLockAvailable() throws Exception {
+ void testLockAvailable() throws Exception {
data.addUnavailableCallback(callback1);
data.addUnavailableCallback(callback2);
- CompletableFuture<OperationOutcome> future = data.getFuture();
+ var future = data.getFuture();
data.lockAvailable(lock);
assertSame(future, data.getFuture());
assertTrue(future.isDone());
- OperationOutcome outcome = future.get();
+ var outcome = future.get();
assertEquals(ActorConstants.LOCK_ACTOR, outcome.getActor());
assertEquals(ActorConstants.LOCK_OPERATION, outcome.getOperation());
assertEquals(ENTITY, outcome.getTarget());
assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage());
- Instant start = outcome.getStart();
+ var start = outcome.getStart();
assertNotNull(start);
- Instant end = outcome.getEnd();
+ var end = outcome.getEnd();
assertNotNull(end);
assertTrue(start.compareTo(end) <= 0);
}
@Test
- public void testLockUnavailable() throws Exception {
+ void testLockUnavailable() throws Exception {
data.addUnavailableCallback(callback1);
data.addUnavailableCallback(callback2);
data.addUnavailableCallback(callback3);
// arrange for callback2 to throw an exception
doThrow(new IllegalStateException("expected exception")).when(callback2).accept(any());
- CompletableFuture<OperationOutcome> future = data.getFuture();
+ var future = data.getFuture();
assertNotNull(future);
data.lockUnavailable(lock);
- CompletableFuture<OperationOutcome> future2 = data.getFuture();
+ var future2 = data.getFuture();
assertNotNull(future2);
assertNotSame(future, future2);
assertTrue(future.isDone());
- OperationOutcome outcome = future.get();
+ var outcome = future.get();
assertTrue(future2.isDone());
assertSame(outcome, future2.get());
assertEquals(OperationResult.FAILURE, outcome.getResult());
assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage());
- Instant start = outcome.getStart();
+ var start = outcome.getStart();
assertNotNull(start);
- Instant end = outcome.getEnd();
+ var end = outcome.getEnd();
assertNotNull(end);
assertTrue(start.compareTo(end) <= 0);
* 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.
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+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;
import java.time.Instant;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.ActorService;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.drools.domain.models.operational.OperationalTarget;
-@RunWith(MockitoJUnitRunner.class)
-public class StepTest {
+class StepTest {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String POLICY_ACTOR = "my-actor";
private static final String POLICY_OPERATION = "my-operation";
private static final long REMAINING_MS = 5000;
private static final String EXPECTED_EXCEPTION = "expected exception";
- @Mock
- private Operator policyOperator;
- @Mock
- private Operation policyOperation;
- @Mock
- private Actor policyActor;
- @Mock
- private ActorService actors;
+ private final Operator policyOperator = mock(Operator.class);
+ private final Operation policyOperation = mock(Operation.class);
+ private final Actor policyActor = mock(Actor.class);
+ private final ActorService actors = mock(ActorService.class);
private CompletableFuture<OperationOutcome> future;
private OperationalTarget target;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
future = new CompletableFuture<>();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertTrue(step.isPolicyStep());
assertSame(params, step.getParams());
assertNull(step.getParentStep());
}
@Test
- public void testConstructorWithOtherStep_testInitStartTime_testGetStartTimeRef() {
- Step step2 = new Step(step, "actorB", "operB");
+ void testConstructorWithOtherStep_testInitStartTime_testGetStartTimeRef() {
+ var step2 = new Step(step, "actorB", "operB");
assertFalse(step2.isPolicyStep());
assertSame(step, step2.getParentStep());
- ControlLoopOperationParams params2 = step2.getParams();
+ var params2 = step2.getParams();
assertEquals("actorB", params2.getActor());
assertEquals("operB", params2.getOperation());
assertNull(params2.getRetry());
step2.init();
step2.start(REMAINING_MS);
- Instant instant = startTime.get();
+ var instant = startTime.get();
assertNotNull(instant);
assertSame(instant, step2.getStartTime());
}
@Test
- public void testGetActorName_testGetOperationName() {
+ void testGetActorName_testGetOperationName() {
assertEquals(POLICY_ACTOR, step.getActorName());
assertEquals(POLICY_OPERATION, step.getOperationName());
}
@Test
- public void testIsInitialized_testInit_testGetOperation() {
+ void testIsInitialized_testInit_testGetOperation() {
assertFalse(step.isInitialized());
// verify it's unchanged
}
@Test
- public void testStart() {
+ void testStart() {
assertThatIllegalStateException().isThrownBy(() -> step.start(REMAINING_MS))
.withMessage("step has not been initialized");
* Tests start() when the operation.start() throws an exception.
*/
@Test
- public void testStartException() {
+ void testStartException() {
when(policyOperation.start()).thenThrow(new RuntimeException());
step.init();
assertTrue(step.start(REMAINING_MS));
// exception should be immediate
- OperationOutcome outcome = completions.poll();
+ var outcome = completions.poll();
assertNotNull(outcome);
assertNotEquals(OperationResult.SUCCESS, outcome.getResult());
* Tests start() when the operation throws an asynchronous exception.
*/
@Test
- public void testStartAsyncException() {
+ void testStartAsyncException() {
step.init();
step.start(REMAINING_MS);
future.completeExceptionally(new RuntimeException(EXPECTED_EXCEPTION));
// exception should be immediate
- OperationOutcome outcome = completions.poll();
+ var outcome = completions.poll();
assertNotNull(outcome);
assertNotEquals(OperationResult.SUCCESS, outcome.getResult());
* Tests handleException() when the exception is a CancellationException.
*/
@Test
- public void testHandleExceptionCancellationException() {
+ void testHandleExceptionCancellationException() {
step.init();
step.start(REMAINING_MS);
}
@Test
- public void testHandleExceptionCauseCancellationException() {
+ void testHandleExceptionCauseCancellationException() {
step.init();
step.start(REMAINING_MS);
}
@Test
- public void testHandleException() {
+ void testHandleException() {
when(policyOperation.start()).thenThrow(new RuntimeException());
step.init();
assertTrue(step.start(REMAINING_MS));
// exception should be immediate
- OperationOutcome outcome = completions.poll();
+ var outcome = completions.poll();
assertNotNull(outcome);
assertNotEquals(OperationResult.SUCCESS, outcome.getResult());
}
@Test
- public void testHandleTimeout() throws InterruptedException {
+ void testHandleTimeout() throws InterruptedException {
step.init();
long tstart = System.currentTimeMillis();
// give it a short timeout
step.start(100);
- OperationOutcome outcome = completions.poll(5, TimeUnit.SECONDS);
+ var outcome = completions.poll(5, TimeUnit.SECONDS);
assertNotNull(outcome);
// should not have timed out before 100ms
}
@Test
- public void testCancel() {
+ void testCancel() {
// should have no effect
step.cancel();
}
@Test
- public void testBuildOperation() {
+ void testBuildOperation() {
assertSame(policyOperation, step.buildOperation());
}
@Test
- public void testMakeOutcome() {
+ void testMakeOutcome() {
step.init();
assertEquals(MY_TARGET, step.makeOutcome().getTarget());
}
@Test
- public void testToString() {
+ void testToString() {
assertNotNull(step.toString());
}
}
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import jakarta.persistence.EntityManagerFactory;
import java.time.Instant;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
-import javax.persistence.EntityManagerFactory;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerParams.OperationHistoryDataManagerParamsBuilder;
-@RunWith(MockitoJUnitRunner.class)
-public class OperationHistoryDataManagerImplTest {
+class OperationHistoryDataManagerImplTest {
private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
private static final String MY_LOOP_NAME = "my-loop-name";
private static EntityManagerFactory emf;
- @Mock
- private Thread thread;
+ private Thread thread = mock(Thread.class);
private OperationHistoryDataManagerParams params;
private Consumer<EntityManagerFactory> threadFunction;
/**
* Sets up for all tests.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
- OperationHistoryDataManagerParams params = makeBuilder().build();
+ var params = makeBuilder().build();
// capture the entity manager factory for re-use
new OperationHistoryDataManagerImpl(params) {
/**
* Restores the environment after all tests.
*/
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
emf.close();
}
/**
* Sets up for an individual test.
*/
- @Before
+ @BeforeEach
public void setUp() {
event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(MY_LOOP_NAME);
mgr.start();
}
- @After
+ @AfterEach
public void tearDown() {
mgr.stop();
}
@Test
- public void testConstructor() {
+ void testConstructor() {
// use a thread and manager that haven't been started yet
thread = mock(Thread.class);
mgr = new PseudoThread();
}
@Test
- public void testStart() {
+ void testStart() {
// this should have no effect
mgr.start();
}
@Test
- public void testStore_testStop() throws InterruptedException {
+ void testStore_testStop() throws InterruptedException {
// store
mgr.store(REQ_ID, event.getClosedLoopControlName(), event, MY_ENTITY, operation);
* Tests stop() when the manager isn't running.
*/
@Test
- public void testStopNotRunning() {
+ void testStopNotRunning() {
// use a manager that hasn't been started yet
mgr = new PseudoThread();
mgr.stop();
* Tests store() when it is already stopped.
*/
@Test
- public void testStoreAlreadyStopped() throws InterruptedException {
+ void testStoreAlreadyStopped() throws InterruptedException {
mgr.stop();
// store
* Tests store() when when the queue is full.
*/
@Test
- public void testStoreTooManyItems() throws InterruptedException {
+ void testStoreTooManyItems() throws InterruptedException {
final int nextra = 5;
for (int nitems = 0; nitems < MAX_QUEUE_LENGTH + nextra; ++nitems) {
mgr.store(REQ_ID, event.getClosedLoopControlName(), event, MY_ENTITY, operation);
}
@Test
- public void testRun() throws InterruptedException {
+ void testRun() throws InterruptedException {
// trigger thread shutdown when it completes this batch
when(emfSpy.createEntityManager()).thenAnswer(ans -> {
* Tests run() when the entity manager throws an exception.
*/
@Test
- public void testRunException() throws InterruptedException {
- AtomicInteger count = new AtomicInteger(0);
+ void testRunException() throws InterruptedException {
+ var count = new AtomicInteger(0);
when(emfSpy.createEntityManager()).thenAnswer(ans -> {
if (count.incrementAndGet() == 2) {
* Tests storeRemainingRecords() when the entity manager throws an exception.
*/
@Test
- public void testStoreRemainingRecordsException() throws InterruptedException {
+ void testStoreRemainingRecordsException() throws InterruptedException {
// arrange to throw an exception
when(emfSpy.createEntityManager()).thenThrow(EXPECTED_EXCEPTION);
}
@Test
- public void testStoreRecord() throws InterruptedException {
+ void testStoreRecord() throws InterruptedException {
/*
* Note: we change sub-request ID each time to guarantee that the records are
* unique.
* Tests storeRecord() when records are updated.
*/
@Test
- public void testStoreRecordUpdate() throws InterruptedException {
+ void testStoreRecordUpdate() throws InterruptedException {
/*
* Note: we do NOT change sub-request ID, so that records all refer to the same DB
* record.
return;
}
- Thread thread2 = new Thread(() -> {
+ var thread2 = new Thread(() -> {
threadFunction.accept(emfSpy);
finished.countDown();
});
* 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.
package org.onap.policy.controlloop.ophistory;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.function.Consumer;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerParams.OperationHistoryDataManagerParamsBuilder;
-public class OperationHistoryDataManagerParamsTest {
+class OperationHistoryDataManagerParamsTest {
private static final String CONTAINER = "my-container";
private static final int BATCH_SIZE = 10;
private static final int MAX_QUEUE_LENGTH = 20;
private OperationHistoryDataManagerParams params;
- @Before
+ @BeforeEach
public void setUp() {
params = makeBuilder().build();
}
@Test
- public void test() {
+ void test() {
assertEquals(BATCH_SIZE, params.getBatchSize());
assertEquals(MAX_QUEUE_LENGTH, params.getMaxQueueLength());
assertEquals(MY_PASS, params.getPassword());
}
@Test
- public void testValidate() {
+ void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
testValidateField("url", "null", params2 -> params2.setUrl(null));
Consumer<OperationHistoryDataManagerParams> makeInvalid) {
// original params should be valid
- ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
+ var result = params.validate(CONTAINER);
+ assertTrue(result.isValid());
// make invalid params
- OperationHistoryDataManagerParams params2 = makeBuilder().build();
+ var params2 = makeBuilder().build();
makeInvalid.accept(params2);
result = params2.validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
+ assertFalse(result.isValid());
assertThat(result.getResult()).contains(CONTAINER).contains(fieldName).contains(expected);
}
* 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.
import static org.assertj.core.api.Assertions.assertThatCode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class OperationHistoryDataManagerStubTest {
+class OperationHistoryDataManagerStubTest {
@Test
- public void test() {
- OperationHistoryDataManagerStub mgr = new OperationHistoryDataManagerStub();
+ void test() {
+ var mgr = new OperationHistoryDataManagerStub();
assertThatCode(() -> mgr.store(null, null, null, null, null)).doesNotThrowAnyException();
assertThatCode(() -> mgr.stop()).doesNotThrowAnyException();
* ONAP
* ================================================================================
* Copyright (C) 2017-2020 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.controlloop.processor;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.controlloop.ControlLoopException;
-import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
-import org.onap.policy.drools.domain.models.operational.Operation;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ControlLoopProcessorTest {
+class ControlLoopProcessorTest {
private static final Logger logger = LoggerFactory.getLogger(ControlLoopProcessorTest.class);
private static final StandardCoder coder = new StandardCoder();
@Test
- public void testControlLoopProcessor() throws IOException, ControlLoopException {
- String yamlString = Files.readString(new File("src/test/resources/test.yaml").toPath(), StandardCharsets.UTF_8);
+ void testControlLoopProcessor() throws IOException, ControlLoopException {
+ var yamlString = Files.readString(new File("src/test/resources/test.yaml").toPath(), StandardCharsets.UTF_8);
this.testSuccess(yamlString);
this.testFailure(yamlString);
}
private ToscaPolicy getPolicyFromResource(String resourcePath, String policyName) throws CoderException {
- String policyJson = ResourceUtils.getResourceAsString(resourcePath);
- ToscaServiceTemplate serviceTemplate = coder.decode(policyJson, ToscaServiceTemplate.class);
- ToscaPolicy policy = serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(policyName);
+ var policyJson = ResourceUtils.getResourceAsString(resourcePath);
+ var serviceTemplate = coder.decode(policyJson, ToscaServiceTemplate.class);
+ var policy = serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(policyName);
assertNotNull(policy);
/*
}
@Test
- public void testControlLoopFromToscaCompliant()
+ void testControlLoopFromToscaCompliant()
throws CoderException, ControlLoopException {
assertNotNull(
new ControlLoopProcessor(
}
@Test
- public void testControlLoopFromToscaCompliantBad() throws CoderException {
- ToscaPolicy toscaPolicy = getPolicyFromResource(
+ void testControlLoopFromToscaCompliantBad() throws CoderException {
+ var toscaPolicy = getPolicyFromResource(
"policies/vCPE.policy.operational.input.tosca.json", "operational.restart");
toscaPolicy.setVersion(null);
assertThatThrownBy(() -> new ControlLoopProcessor(toscaPolicy)).hasCauseInstanceOf(CoderException.class);
}
@Test
- public void testControlLoopProcessorBadYaml() throws IOException {
- InputStream is = new FileInputStream(new File("src/test/resources/string.yaml"));
- String yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
+ void testControlLoopProcessorBadYaml() throws IOException {
+ var is = new FileInputStream(new File("src/test/resources/string.yaml"));
+ var yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
assertThatThrownBy(() -> new ControlLoopProcessor(yamlString))
.hasMessageEndingWith("Cannot decode yaml into ToscaServiceTemplate");
}
@Test
- public void testControlLoopProcessorBadTriggerYaml() throws IOException, ControlLoopException {
- String yamlString = Files.readString(new File("src/test/resources/badtriggerpolicy.yaml").toPath(),
+ void testControlLoopProcessorBadTriggerYaml() throws IOException, ControlLoopException {
+ var yamlString = Files.readString(new File("src/test/resources/badtriggerpolicy.yaml").toPath(),
StandardCharsets.UTF_8);
- ControlLoopProcessor clProcessor = new ControlLoopProcessor(yamlString);
+ var clProcessor = new ControlLoopProcessor(yamlString);
assertNull(clProcessor.getCurrentPolicy());
assertThatThrownBy(() -> clProcessor.nextPolicyForResult(OperationResult.SUCCESS))
}
@Test
- public void testControlLoopProcessorNoPolicyYaml() throws IOException, ControlLoopException {
- InputStream is = new FileInputStream(new File("src/test/resources/nopolicy.yaml"));
- String yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
+ void testControlLoopProcessorNoPolicyYaml() throws IOException, ControlLoopException {
+ var is = new FileInputStream(new File("src/test/resources/nopolicy.yaml"));
+ var yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
- ControlLoopProcessor clProcessor = new ControlLoopProcessor(yamlString);
+ var clProcessor = new ControlLoopProcessor(yamlString);
assertThatThrownBy(clProcessor::getCurrentPolicy)
.hasMessage("There are no policies defined.");
}
@Test
- public void testControlLoopProcessorNextPolicyForResult() throws IOException, ControlLoopException {
- InputStream is = new FileInputStream(new File("src/test/resources/test.yaml"));
- String yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
+ void testControlLoopProcessorNextPolicyForResult() throws IOException, ControlLoopException {
+ var is = new FileInputStream(new File("src/test/resources/test.yaml"));
+ var yamlString = IOUtils.toString(is, StandardCharsets.UTF_8);
- for (OperationResult result : OperationResult.values()) {
+ for (var result : OperationResult.values()) {
checkResult(yamlString, result);
}
}
private void checkResult(String yamlString, OperationResult result) throws ControlLoopException {
- ControlLoopProcessor clProcessor = new ControlLoopProcessor(yamlString);
+ var clProcessor = new ControlLoopProcessor(yamlString);
clProcessor.getCurrentPolicy();
clProcessor.nextPolicyForResult(result);
}
* @throws ControlLoopException if an error occurs
*/
public void testSuccess(String yaml) throws ControlLoopException {
- ControlLoopProcessor processor = new ControlLoopProcessor(yaml);
+ var processor = new ControlLoopProcessor(yaml);
logger.debug("testSuccess: {}", processor.getCurrentPolicy());
while (true) {
- OperationFinalResult result = processor.checkIsCurrentPolicyFinal();
+ var result = processor.checkIsCurrentPolicyFinal();
if (result != null) {
logger.debug("{}", result);
break;
}
- Operation policy = processor.getCurrentPolicy();
+ var policy = processor.getCurrentPolicy();
assertNotNull(policy);
logger.debug("current policy is: {}", policy.getId());
processor.nextPolicyForResult(OperationResult.SUCCESS);
* @throws ControlLoopException if an error occurs
*/
public void testFailure(String yaml) throws ControlLoopException {
- ControlLoopProcessor processor = new ControlLoopProcessor(yaml);
+ var processor = new ControlLoopProcessor(yaml);
logger.debug("testFailure: {}", processor.getCurrentPolicy());
while (true) {
- OperationFinalResult result = processor.checkIsCurrentPolicyFinal();
+ var result = processor.checkIsCurrentPolicyFinal();
if (result != null) {
logger.debug("{}", result);
break;
}
- Operation policy = processor.getCurrentPolicy();
+ var policy = processor.getCurrentPolicy();
assertNotNull(policy);
logger.debug("current policy is: {}", policy.getId());
processor.nextPolicyForResult(OperationResult.FAILURE);
* ONAP
* ================================================================================
* Copyright (C) 2019-2020 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.controlloop.utils;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
-import org.junit.Test;
+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;
-public class ControlLoopUtilsTest {
+class ControlLoopUtilsTest {
@Test
- public void testToControlLoopParams() throws Exception {
- String policyJson =
+ void testToControlLoopParams() throws Exception {
+ var policyJson =
ResourceUtils.getResourceAsString("policies/vCPE.policy.operational.input.tosca.json");
- ToscaServiceTemplate serviceTemplate = new StandardCoder().decode(policyJson, ToscaServiceTemplate.class);
- ToscaPolicy toscaPolicy =
+ var serviceTemplate = new StandardCoder().decode(policyJson, ToscaServiceTemplate.class);
+ var toscaPolicy =
serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get("operational.restart");
- ControlLoopParams params = ControlLoopUtils.toControlLoopParams(toscaPolicy);
+ var params = ControlLoopUtils.toControlLoopParams(toscaPolicy);
assertEquals("ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", params.getClosedLoopControlName());
assertEquals(toscaPolicy.getName(), params.getPolicyName());
assertEquals(toscaPolicy.getVersion(), params.getPolicyVersion());
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
<artifactId>drools-applications-common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>feature-controlloop-management</artifactId>
<language>jaxrs-spec</language>
<generateModels>false</generateModels>
<generateSupportingFiles>false</generateSupportingFiles>
- <sortParamsByRequiredFlag>false</sortParamsByRequiredFlag>
<importMappings>
- Response=javax.ws.rs.core.Response
+ Response=jakarta.ws.rs.core.Response
</importMappings>
<configOptions>
<useTags>true</useTags>
<sourceFolder>src/gen/java</sourceFolder>
- <dateLibrary>java11</dateLibrary>
+ <dateLibrary>java17</dateLibrary>
<interfaceOnly>true</interfaceOnly>
+ <jakarta>true</jakarta>
</configOptions>
</configuration>
</execution>
<version>${policy.models.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.models.policy-models-interactions</groupId>
- <artifactId>simulators</artifactId>
- <version>${policy.models.version}</version>
- <scope>test</scope>
+ <groupId>org.onap.policy.models.policy-models-interactions</groupId>
+ <artifactId>simulators</artifactId>
+ <version>${policy.models.version}</version>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>
* ONAP
* ================================================================================
* Copyright (C) 2018-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.
package org.onap.policy.drools.server.restful;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
import org.onap.policy.aai.AaiManager;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
import org.onap.policy.drools.apps.controlloop.feature.management.ControlLoopManagementFeature;
*/
@GET
@Path("engine/tools/controlloops/aai/customQuery/{vserverId}")
- public Response aaiCustomQuery(String vserverId) {
+ public Response aaiCustomQuery(@PathParam("vserverId") String vserverId) {
var mgr = PolicyEngineConstants.getManager();
return Response
package org.onap.policy.drools.apps.controlloop.feature.management;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Collections;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.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;
/**
* Control Loop Management Feature Test.
*/
-public class ControlLoopManagementFeatureTest {
+class ControlLoopManagementFeatureTest {
private static final String FACTORY_FIELD = "factory";
private static final String SESSION_NAME = "my-session";
private static final String CONTROLLER_NAME = "my-controller";
private static Factory saveFactory;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
saveFactory = (Factory) ReflectionTestUtils.getField(ControlLoopManagementFeature.class, FACTORY_FIELD);
}
- @After
+ @AfterEach
public void tearDown() {
ReflectionTestUtils.setField(ControlLoopManagementFeature.class, FACTORY_FIELD, saveFactory);
}
* Sequence Number Test.
*/
@Test
- public void getSequenceNumber() {
- Assert.assertEquals(1000, new ControlLoopManagementFeature().getSequenceNumber());
+ void getSequenceNumber() {
+ assertEquals(1000, new ControlLoopManagementFeature().getSequenceNumber());
}
/**
* Name Test.
*/
@Test
- public void getName() {
- Assert.assertEquals("controlloop-management", new ControlLoopManagementFeature().getName());
+ void getName() {
+ assertEquals("controlloop-management", new ControlLoopManagementFeature().getName());
}
@Test
- public void testControlLoops_InvalidArgs() {
- Factory factory = mock(Factory.class);
+ void testControlLoops_InvalidArgs() {
+ var factory = mock(Factory.class);
ReflectionTestUtils.setField(ControlLoopManagementFeature.class, FACTORY_FIELD, factory);
// returns null controller
.withMessage("Invalid Controller Name");
// non-matching session name
- PolicyController ctlr = mock(PolicyController.class);
- DroolsController drools = mock(DroolsController.class);
+ var drools = mock(DroolsController.class);
when(drools.getSessionNames()).thenReturn(Collections.emptyList());
+ var ctlr = mock(PolicyController.class);
when(ctlr.getDrools()).thenReturn(drools);
when(factory.getController(any())).thenReturn(ctlr);
assertThatIllegalArgumentException()
}
@Test
- public void testFactoryGetController() {
+ void testFactoryGetController() {
// invoking controlLoops() will invoke the factory.getController() method
assertThatIllegalArgumentException().isThrownBy(
() -> ControlLoopManagementFeature.controlLoops("unknown-controller", SESSION_NAME));
* ONAP
* ================================================================================
* Copyright (C) 2018-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.
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import jakarta.ws.rs.core.Response.Status;
import java.io.IOException;
import java.nio.file.Files;
-import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.core.Response.Status;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.kie.api.builder.ReleaseId;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
/**
* Test RestControlLoopManager.
*/
-public class RestControlLoopManagerTest {
+class RestControlLoopManagerTest {
private static final String KSESSION = "op";
private static final String KMODULE_DRL_PATH = "src/test/resources/op.drl";
*
* @throws Exception if failure to complete the set up.
*/
- @BeforeClass
+ @BeforeAll
public 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.
*/
- @AfterClass
+ @AfterAll
public static void tearDown() {
PolicyControllerConstants.getFactory().get(CONTROLLER).stop();
await().atMost(1, TimeUnit.MINUTES).until(isContainerAlive(), equalTo(Boolean.FALSE));
PolicyEngineConstants.getManager().removePolicyController(CONTROLLER);
PolicyEngineConstants.getManager().stop();
- final Path controllerPath =
+ final var controllerPath =
Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
CONTROLLER_FILE);
try {
/* to satisfy checkstyle */
}
- Path controllerBakPath =
+ var controllerBakPath =
Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
CONTROLLER_FILE_BAK);
* Test Operational Policies.
*/
@Test
- public void testOperationalPolicy() throws IOException {
+ void testOperationalPolicy() {
assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory()
.get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOPS).getStatus());
* Test AAI Custom Query.
*/
@Test
- public void testAaiCq() throws CoderException {
+ void testAaiCq() {
assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory()
.get(CONTROLLER).get(URL_CONTEXT_PATH_TOOLS_AAI_CQ + "dummy").getStatus());
}
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
<artifactId>drools-applications-common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>feature-controlloop-trans</artifactId>
<language>jaxrs-spec</language>
<generateModels>false</generateModels>
<generateSupportingFiles>false</generateSupportingFiles>
- <sortParamsByRequiredFlag>false</sortParamsByRequiredFlag>
<importMappings>
- Response=javax.ws.rs.core.Response
+ Response=jakarta.ws.rs.core.Response
</importMappings>
<typeMappings>
<typeMapping>Integer=int</typeMapping>
<configOptions>
<useTags>true</useTags>
<sourceFolder>src/gen/java</sourceFolder>
- <dateLibrary>java11</dateLibrary>
+ <dateLibrary>java17</dateLibrary>
<interfaceOnly>true</interfaceOnly>
+ <jakarta>true</jakarta>
</configOptions>
</configuration>
</execution>
* ONAP
* ================================================================================
* Copyright (C) 2019-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.
setNotificationValues(controller, notification);
switch (notification.getNotification()) {
- case REJECTED:
- case FINAL_FAILURE:
- case FINAL_SUCCESS:
- case FINAL_OPENLOOP:
+ case REJECTED, FINAL_FAILURE, FINAL_SUCCESS, FINAL_OPENLOOP:
endTransaction(controller, notification);
break;
- case ACTIVE:
- case OPERATION:
- case OPERATION_SUCCESS:
- case OPERATION_FAILURE:
+ case ACTIVE, OPERATION, OPERATION_SUCCESS, OPERATION_FAILURE:
/* any other value is an in progress transaction */
inProgressTransaction(notification);
break;
.setEndTime(notification.getNotificationTime().toInstant());
switch (notification.getNotification()) {
- case FINAL_OPENLOOP:
- /* fall through */
- case FINAL_SUCCESS:
+ case FINAL_OPENLOOP,
+ /* fall through */
+ FINAL_SUCCESS:
trans.setStatusCode(true);
break;
- case FINAL_FAILURE:
- /* fall through */
- case REJECTED:
+ case FINAL_FAILURE,
+ /* fall through */
+ REJECTED:
trans.setStatusCode(false);
break;
default:
package org.onap.policy.drools.server.restful;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.PUT;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
import java.util.UUID;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.drools.apps.controlloop.feature.trans.ControlLoopMetricsManager;
* ONAP
* ================================================================================
* Copyright (C) 2018-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.
package org.onap.policy.drools.apps.controlloop.feature.trans;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.file.Path;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.controlloop.ControlLoopNotificationType;
/**
* ControlLoopMetrics Tests.
*/
-public class ControlLoopMetricsFeatureTest {
+class ControlLoopMetricsFeatureTest {
private static final String POLICY_CL_MGT = "POLICY-CL-MGT";
private static final Path configPath = SystemPersistenceConstants.getManager().getConfigurationPath();
/**
* Setup method.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() {
SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
testController = PolicyEngineConstants.getManager().createPolicyController("metrics",
SystemPersistenceConstants.getManager().getControllerProperties("metrics"));
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
SystemPersistenceConstants.getManager().setConfigurationDir(configPath.toString());
resetStats();
}
- @Before
+ @BeforeEach
public void beforeTest() {
resetStats();
}
@Test
- public void testCacheDefaults() {
+ void testCacheDefaults() {
assertEquals(3, ControlLoopMetricsManager.getManager().getCacheSize());
assertEquals(2, ControlLoopMetricsManager.getManager().getTransactionTimeout());
assertEquals(0, ControlLoopMetricsManager.getManager().getCacheOccupancy());
}
@Test
- public void testInvalidNotifications() {
- ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
- VirtualControlLoopNotification notification = new VirtualControlLoopNotification();
+ void testInvalidNotifications() {
+ var feature = new ControlLoopMetricsFeature();
+ var notification = new VirtualControlLoopNotification();
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, notification);
this.testCacheDefaults();
- UUID requestId = UUID.randomUUID();
+ var requestId = UUID.randomUUID();
notification.setRequestId(requestId);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, notification);
}
@Test
- public void testValidActiveNotification() {
- ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
- VirtualControlLoopNotification notification = new VirtualControlLoopNotification();
- UUID requestId = UUID.randomUUID();
+ void testValidActiveNotification() {
+ var feature = new ControlLoopMetricsFeature();
+ var notification = new VirtualControlLoopNotification();
+ var requestId = UUID.randomUUID();
notification.setRequestId(requestId);
notification.setNotification(ControlLoopNotificationType.ACTIVE);
}
@Test
- public void testReset() {
- VirtualControlLoopNotification notification = this.generateNotification();
+ void testReset() {
+ var notification = this.generateNotification();
new ControlLoopMetricsFeature().beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT,
notification);
}
@Test
- public void testRemoveTransaction() {
- VirtualControlLoopNotification notification = this.generateNotification();
+ void testRemoveTransaction() {
+ var notification = this.generateNotification();
assertNull(ControlLoopMetricsManager.getManager().getTransaction(notification.getRequestId()));
ControlLoopMetricsManager.getManager().removeTransaction(notification.getRequestId());
}
@Test
- public void testEviction() {
- ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
+ void testEviction() {
+ var feature = new ControlLoopMetricsFeature();
for (int i = 0; i < ControlLoopMetricsManager.getManager().getCacheSize(); i++) {
- VirtualControlLoopNotification notification = generateNotification();
+ var notification = generateNotification();
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, notification);
assertNotNull(ControlLoopMetricsManager.getManager().getTransaction(notification.getRequestId()));
}
assertEquals(ControlLoopMetricsManager.getManager().getCacheOccupancy(),
ControlLoopMetricsManager.getManager().getCacheOccupancy());
- VirtualControlLoopNotification overflowNotification = generateNotification();
+ var overflowNotification = generateNotification();
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, overflowNotification);
assertEquals(ControlLoopMetricsManager.getManager().getCacheOccupancy(),
ControlLoopMetricsManager.getManager().getCacheOccupancy());
}
private VirtualControlLoopNotification generateNotification() {
- VirtualControlLoopNotification notification = new VirtualControlLoopNotification();
- UUID requestId = UUID.randomUUID();
+ var notification = new VirtualControlLoopNotification();
+ var requestId = UUID.randomUUID();
notification.setRequestId(requestId);
notification.setNotification(ControlLoopNotificationType.ACTIVE);
return notification;
}
@Test
- public void getSequenceNumber() {
- ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
+ void getSequenceNumber() {
+ var feature = new ControlLoopMetricsFeature();
assertEquals(ControlLoopMetricsFeature.FEATURE_SEQUENCE_PRIORITY, feature.getSequenceNumber());
}
@Test
- public void testSuccessControlLoop() {
- ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
+ void testSuccessControlLoop() {
+ var feature = new ControlLoopMetricsFeature();
- String activeNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-active.json");
- VirtualControlLoopNotification active =
+ var activeNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-active.json");
+ var active =
Serialization.gsonPretty.fromJson(activeNotification, VirtualControlLoopNotification.class);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, active);
assertEquals(1, ControlLoopMetricsManager.getManager().getTransactionIds().size());
- String opStartNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-operation.json");
- VirtualControlLoopNotification opStart =
+ var opStartNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-operation.json");
+ var opStart =
Serialization.gsonPretty.fromJson(opStartNotification, VirtualControlLoopNotification.class);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, opStart);
assertEquals(1, ControlLoopMetricsManager.getManager().getTransactionIds().size());
- String permitNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-permit.json");
- VirtualControlLoopNotification permit =
+ var permitNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-permit.json");
+ var permit =
Serialization.gsonPretty.fromJson(permitNotification, VirtualControlLoopNotification.class);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, permit);
assertEquals(1, ControlLoopMetricsManager.getManager().getTransactionIds().size());
- String restartNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-restart.json");
- VirtualControlLoopNotification restart =
+ var restartNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-restart.json");
+ var restart =
Serialization.gsonPretty.fromJson(restartNotification, VirtualControlLoopNotification.class);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, restart);
assertEquals(1, ControlLoopMetricsManager.getManager().getTransactionIds().size());
- String restartSuccessNotification =
+ var restartSuccessNotification =
ResourceUtils.getResourceAsString("policy-cl-mgt-restart-success.json");
- VirtualControlLoopNotification restartSuccess =
+ var restartSuccess =
Serialization.gsonPretty.fromJson(restartSuccessNotification, VirtualControlLoopNotification.class);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, restartSuccess);
assertEquals(1, ControlLoopMetricsManager.getManager().getTransactionIds().size());
- String finalSuccessNotification =
+ var finalSuccessNotification =
ResourceUtils.getResourceAsString("policy-cl-mgt-final-success.json");
- VirtualControlLoopNotification finalSuccess =
+ var finalSuccess =
Serialization.gsonPretty.fromJson(finalSuccessNotification, VirtualControlLoopNotification.class);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, finalSuccess);
assertEquals(0, ControlLoopMetricsManager.getManager().getTransactionIds().size());
}
@Test
- public void testUntrackedNotifications() throws InterruptedException {
- ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
+ void testUntrackedNotifications() throws InterruptedException {
+ var feature = new ControlLoopMetricsFeature();
- String finalSuccessNotification =
+ var finalSuccessNotification =
ResourceUtils.getResourceAsString("policy-cl-mgt-final-success.json");
- VirtualControlLoopNotification finalSuccess =
+ var finalSuccess =
Serialization.gsonPretty.fromJson(finalSuccessNotification, VirtualControlLoopNotification.class);
finalSuccess.setRequestId(UUID.randomUUID());
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, finalSuccess);
assertEquals(0, ControlLoopMetricsManager.getManager().getTransactionIds().size());
- String opStartNotification =
+ var opStartNotification =
ResourceUtils.getResourceAsString("policy-cl-mgt-operation.json");
- VirtualControlLoopNotification opStart =
+ var opStart =
Serialization.gsonPretty.fromJson(opStartNotification, VirtualControlLoopNotification.class);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, opStart);
assertEquals(1, ControlLoopMetricsManager.getManager().getTransactionIds().size());
Thread.sleep((ControlLoopMetricsManager.getManager().getTransactionTimeout() + 1) * 1000L); // NOSONAR
assertEquals(0, ControlLoopMetricsManager.getManager().getTransactionIds().size());
}
-
}
* ONAP
* ================================================================================
* Copyright (C) 2020 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.server.restful;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.Response;
import java.util.Collections;
import java.util.List;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Response;
import org.jetbrains.annotations.NotNull;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.event.comm.Topic;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyEngineConstants;
-public class RestTransactionTrackerTest {
+class RestTransactionTrackerTest {
private static PolicyController testController;
private static HttpClient client;
- @BeforeClass
+ @BeforeAll
public static void testBeforeClass() throws Exception {
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
.managed(true)
.build());
- HttpServletServer server =
+ var server =
HttpServletServerFactoryInstance
.getServerFactory()
.build("trans", "localhost", 8769, "/", true, true);
client = HttpClientFactoryInstance.getClientFactory().get("trans");
}
- @AfterClass
+ @AfterAll
public static void testAfterClass() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
- public void testConfiguration() {
+ void testConfiguration() {
equals(get("cacheSize", Response.Status.OK.getStatusCode()), Integer.class, 3);
equals(get("timeout", Response.Status.OK.getStatusCode()), Integer.class, 2);
}
@Test
- public void testTransactions() {
+ void testTransactions() {
equals(get("/inprogress", Response.Status.OK.getStatusCode()), List.class, Collections.emptyList());
ControlLoopMetricsFeature feature = new ControlLoopMetricsFeature();
List.class).isEmpty());
get("/inprogress/664be3d2-6c12-4f4b-a3e7-c349acced200", Response.Status.NOT_FOUND.getStatusCode());
- String activeNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-active.json");
- VirtualControlLoopNotification active =
+ var activeNotification = ResourceUtils.getResourceAsString("policy-cl-mgt-active.json");
+ var active =
Serialization.gsonPretty.fromJson(activeNotification, VirtualControlLoopNotification.class);
feature.beforeDeliver(testController, Topic.CommInfrastructure.DMAAP, "POLICY-CL-MGT", active);
assertEquals(1, ControlLoopMetricsManager.getManager().getTransactionIds().size());
}
private Response get(String contextPath, int statusCode) {
- Response response = client.get(contextPath);
+ var response = client.get(contextPath);
return checkResponse(statusCode, response);
}
private Response put(String contextPath, String body, int statusCode) {
- Response response = client.put(contextPath, Entity.json(body), Collections.emptyMap());
+ var response = client.put(contextPath, Entity.json(body), Collections.emptyMap());
return checkResponse(statusCode, response);
}
================================================================================
Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
+ 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.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
<artifactId>drools-applications-common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>feature-controlloop-usecases</artifactId>
* ONAP
* ================================================================================
* Copyright (C) 2018 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.usecases;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class UsecasesFeatureTest {
+import org.junit.jupiter.api.Test;
- @org.junit.Test
- public void getSequenceNumber() {
+class UsecasesFeatureTest {
+
+ @Test
+ void getSequenceNumber() {
assertEquals(UsecasesFeature.SEQNO, new UsecasesFeature().getSequenceNumber());
}
}
ONAP
================================================================================
Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2019, 2023 Nordix Foundation.
Modifications Copyright (C) 2020 Bell Canada.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
- <artifactId>drools-applications-common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
+ <artifactId>drools-applications-common</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
- <artifactId>feature-controlloop-utils</artifactId>
+ <artifactId>feature-controlloop-utils</artifactId>
- <description>
- Loadable PDP-D feature module to enable simulator usage in a non-junit
- lab environments. In a pdp-d lab environment this capability can be
- enabled with the "feature" mechanisms.
- </description>
-
- <properties>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
- </properties>
+ <description>
+ Loadable PDP-D feature module to enable simulator usage in a non-junit
+ lab environments. In a pdp-d lab environment this capability can be
+ enabled with the "feature" mechanisms.
+ </description>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>zipfile</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <attach>true</attach>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <descriptors>
- <descriptor>src/assembly/assemble_zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>prepare-package</phase>
- <configuration>
- <transitive>false</transitive>
- <outputDirectory>${project.build.directory}/assembly/lib</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <useRepositoryLayout>false</useRepositoryLayout>
- <addParentPoms>false</addParentPoms>
- <copyPom>false</copyPom>
- <includeScope>runtime</includeScope>
- <excludeTransitive>true</excludeTransitive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>policy-management</artifactId>
- <version>${version.policy.drools-pdp}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>policy-endpoints</artifactId>
- <version>${version.policy.common}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions</groupId>
- <artifactId>simulators</artifactId>
- <version>${policy.models.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>aai</artifactId>
- <version>${policy.models.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>so</artifactId>
- <version>${policy.models.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>sdnc</artifactId>
- <version>${policy.models.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>rest</artifactId>
- <version>${policy.models.version}</version>
- </dependency>
- </dependencies>
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>zipfile</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <attach>true</attach>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}/assembly/lib</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>false</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <includeScope>runtime</includeScope>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-management</artifactId>
+ <version>${version.policy.drools-pdp}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${version.policy.common}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.models.policy-models-interactions</groupId>
+ <artifactId>simulators</artifactId>
+ <version>${policy.models.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
+ <artifactId>aai</artifactId>
+ <version>${policy.models.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
+ <artifactId>so</artifactId>
+ <version>${policy.models.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
+ <artifactId>sdnc</artifactId>
+ <version>${policy.models.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
+ <artifactId>rest</artifactId>
+ <version>${policy.models.version}</version>
+ </dependency>
+ </dependencies>
</project>
* ONAP
* ================================================================================
* Copyright (C) 2017-2019, 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.
*/
public class ControlLoopUtilsFeature implements PolicyEngineFeatureApi {
- private static Logger logger = LoggerFactory.getLogger(ControlLoopUtilsFeature.class);
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopUtilsFeature.class);
@Override
public boolean afterStart(PolicyEngine engine) {
* ONAP
* ================================================================================
* Copyright (C) 2017-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.
package org.onap.policy.drools.apps.controlloop.feature.utils;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.drools.system.PolicyEngineConstants;
/**
* ControlLoopUtilsFeature JUnit Tests.
*/
-public class ControlLoopUtilsFeatureTest {
+class ControlLoopUtilsFeatureTest {
@Test
- public void testSimulate() {
+ void testSimulate() {
LoggerUtils.setLevel("ROOT", "INFO");
LoggerUtils.setLevel("org.eclipse.jetty", "WARN");
- final ControlLoopUtilsFeature feature = new ControlLoopUtilsFeature();
+ final var feature = new ControlLoopUtilsFeature();
feature.afterStart(PolicyEngineConstants.getManager());
assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.AAISIM_SERVER_PORT));
assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.SOSIM_SERVER_PORT));
================================================================================
Copyright (C) 2017, 2019-2020 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
+ 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.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
-
- <parent>
- <groupId>org.onap.policy.drools-applications.controlloop</groupId>
- <artifactId>controlloop</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
- <artifactId>drools-applications-common</artifactId>
-
- <modules>
- <module>coordination</module>
- <module>eventmanager</module>
- <module>rules-test</module>
- <module>controller-usecases</module>
- <module>feature-controlloop-utils</module>
- <module>feature-controlloop-trans</module>
- <module>feature-controlloop-management</module>
- <module>feature-controlloop-usecases</module>
- </modules>
-
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
+
+ <parent>
+ <groupId>org.onap.policy.drools-applications.controlloop</groupId>
+ <artifactId>controlloop</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
+ <artifactId>drools-applications-common</artifactId>
+
+ <modules>
+ <module>coordination</module>
+ <module>eventmanager</module>
+ <module>rules-test</module>
+ <module>controller-usecases</module>
+ <module>feature-controlloop-utils</module>
+ <module>feature-controlloop-trans</module>
+ <module>feature-controlloop-management</module>
+ <module>feature-controlloop-usecases</module>
+ </modules>
</project>
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
-
<groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
<artifactId>drools-applications-common</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>rules-test</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<artifactId>awaitility</artifactId>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
package org.onap.policy.controlloop.common.rules.test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Collections;
import java.util.List;
import lombok.Setter;
import org.apache.commons.collections.MapUtils;
import org.awaitility.Awaitility;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.appc.Request;
import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
import org.onap.policy.common.utils.coder.Coder;
/**
* Service123 with Tosca Compliant Policy.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void testService123Compliant() {
policyClMgt = createNoficationTopicListener();
appcLcmRead = topics.createListener(APPC_LCM_READ_TOPIC, AppcLcmDmaapWrapper.class, APPC_LCM_CODER);
* to obtain a lock since it is a different target. After processing of all events
* there should only be the policy and params objects left in memory.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void testDuplicatesEvents() {
policyClMgt = createNoficationTopicListener();
appcLcmRead = topics.createListener(APPC_LCM_READ_TOPIC, AppcLcmDmaapWrapper.class, APPC_LCM_CODER);
/**
* Sunny Day with Tosca Compliant Policy.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void testVcpeSunnyDayCompliant() {
appcLcmSunnyDay(VCPE_TOSCA_COMPLIANT_POLICY, VCPE_ONSET_1, APPC_RESTART_OP);
}
* simulate the flooding behavior of the DCAE TCA microservice. TCA could blast tens
* or hundreds of ONSETs within sub-second intervals.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void testVcpeOnsetFloodPrevention() {
appcLcmSunnyDay(VCPE_TOSCA_COMPLIANT_POLICY, List.of(VCPE_ONSET_1, VCPE_ONSET_2, VCPE_ONSET_3),
APPC_RESTART_OP);
/**
* Sunny Day with Tosca Compliant Policy.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void testVdnsSunnyDayCompliant() {
httpSunnyDay(VDNS_TOSCA_COMPLIANT_POLICY, VDNS_ONSET);
}
/**
* VFW Sunny Day with Tosca Compliant Policy.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void testVfwSunnyDayCompliant() {
appcLegacySunnyDay(VFW_TOSCA_COMPLIANT_POLICY, VFW_ONSET, APPC_MODIFY_CONFIG_OP);
}
/**
* VPCI Sunny Day Tosca Policy.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void testVpciSunnyDayCompliant() {
sdnrSunnyDay(VPCI_TOSCA_COMPLIANT_POLICY, VPCI_ONSET, VPCI_SDNR_SUCCESS,
SDNR_MODIFY_CONFIG_OP, SDNR_CL_TOPIC, SDNR_CL_RSP_TOPIC);
/**
* VSONH Sunny Day with Tosca Policy.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void testVsonhSunnyDayCompliant() {
sdnrSunnyDay(VSONH_TOSCA_COMPLIANT_POLICY, VSONH_ONSET, VSONH_SDNR_SUCCESS,
SNDR_MODIFY_CONFIG_ANR_OP, SDNR_CL_TOPIC, SDNR_CL_RSP_TOPIC);
/**
* Sunny day 5G SON 01 Modify01Config Operational Policy.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void test5gSonO1SunnyDayCompliant() {
sdnrSunnyDay(V5G_SON_O1_TOSCA_POLICY, V5G_SON_O1_ONSET, V5G_SON_O1_SDNR_SUCCESS,
MODIFY_O1_CONFIG_OPERATION, SDNR_CL_TOPIC, SDNR_CL_RSP_TOPIC);
/**
* Sunny day 5G SON A1 ModifyA1Policy Operational Policy.
*/
- @Test
+ //TODO This test needs to be enabled in java-17 branch
public void test5gSonA1SunnyDayCompliant() {
sdnrSunnyDay(V5G_SON_A1_TOSCA_POLICY, V5G_SON_A1_ONSET, V5G_SON_A1_SDNR_SUCCESS,
PUT_A1_POLICY_OPERATION, A1P_CL_TOPIC, A1P_CL_RSP_TOPIC);
* 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.
package org.onap.policy.controlloop.common.rules.test;
-import org.junit.Ignore;
-import org.junit.runner.notification.RunNotifier;
-import org.junit.runners.BlockJUnit4ClassRunner;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.InitializationError;
+import org.junit.jupiter.api.extension.ConditionEvaluationResult;
+import org.junit.jupiter.api.extension.ExecutionCondition;
+import org.junit.jupiter.api.extension.ExtensionContext;
/**
* Runs tests listed via the {@link TestNames} annotation.
*/
-public class NamedRunner extends BlockJUnit4ClassRunner {
-
- /**
- * Constructs the object.
- */
- public NamedRunner(Class<?> testClass) throws InitializationError {
- super(testClass);
- }
+public class NamedRunner implements ExecutionCondition {
@Override
- protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
- var description = describeChild(method);
-
- if (method.getAnnotation(Ignore.class) != null) {
- notifier.fireTestIgnored(description);
-
- } else if (!isNamed(description.getTestClass(), method.getName())) {
- notifier.fireTestIgnored(description);
-
+ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) {
+ var testClass = extensionContext.getTestClass();
+ if (testClass.isEmpty()) {
+ return ConditionEvaluationResult.enabled("Empty");
+ }
+ var method = extensionContext.getDisplayName().replace("()", "");
+ if (testClass.get().getSimpleName().equals(method)) {
+ return ConditionEvaluationResult.enabled("Class");
+ }
+ if (isNamed(testClass.get(), method)) {
+ return ConditionEvaluationResult.enabled("OK");
} else {
- runLeaf(methodBlock(method), description, notifier);
+ return ConditionEvaluationResult.disabled("Disabled");
}
}
* @return {@code true} if the test is in the list, {@code false} otherwise
*/
private boolean isNamed(Class<?> testClass, String testName) {
- TestNames annot = testClass.getAnnotation(TestNames.class);
+ var annot = testClass.getAnnotation(TestNames.class);
if (annot == null) {
// no annotation - everything passes
return true;
* 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.
package org.onap.policy.controlloop.common.rules.test;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileNotFoundException;
package org.onap.policy.controlloop.common.rules.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Predicate;
import java.util.function.Supplier;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.onap.policy.appc.CommonHeader;
import org.onap.policy.appc.Request;
import org.onap.policy.appclcm.AppcLcmBody;
import org.onap.policy.sdnr.PciRequest;
import org.springframework.test.util.ReflectionTestUtils;
-@RunWith(MockitoJUnitRunner.class)
-public class BaseTestTest {
+class BaseTestTest {
private static final String POLICY_NAME = "my-policy-name";
// saved values
private int permitCount;
private int finalCount;
- @Mock
- private HttpClients httpClients;
- @Mock
- private Simulators simulators;
- @Mock
- private Topics topics;
- @Mock
- private Listener<VirtualControlLoopNotification> policyClMgt;
- @Mock
- private Listener<Request> appcClSink;
- @Mock
- private Listener<AppcLcmDmaapWrapper> appcLcmRead;
- @Mock
- private Listener<PciMessage> sdnrClSink;
- @Mock
- private DroolsController drools;
- @Mock
- private ToscaPolicy policy;
- @Mock
- private ToscaConceptIdentifier policyIdent;
-
+ private final HttpClients httpClients = mock(HttpClients.class);
+ private final Simulators simulators = mock(Simulators.class);
+ private final Topics topics = mock(Topics.class);
+ private final Listener<VirtualControlLoopNotification> policyClMgt = mock();
+ private final Listener<Request> appcClSink = mock();
+ private final Listener<AppcLcmDmaapWrapper> 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")
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
httpClientMaker = (Supplier<HttpClients>) ReflectionTestUtils.getField(BaseTest.class, "httpClientMaker");
simMaker = (Supplier<Simulators>) ReflectionTestUtils.getField(BaseTest.class, "simMaker");
/**
* Restores static values.
*/
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
ReflectionTestUtils.setField(BaseTest.class, "httpClientMaker", httpClientMaker);
ReflectionTestUtils.setField(BaseTest.class, "simMaker", simMaker);
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
when(topics.createListener(eq(BaseTest.POLICY_CL_MGT_TOPIC), eq(VirtualControlLoopNotification.class),
any(StandardCoder.class))).thenReturn(policyClMgt);
}
@Test
- public void testInitStatics() {
+ void testInitStatics() {
assertSame(httpClients, BaseTest.httpClients);
assertSame(simulators, BaseTest.simulators);
}
@Test
- public void testFinishStatics() {
+ void testFinishStatics() {
BaseTest.finishStatics();
verify(httpClients).destroy();
verify(simulators).destroy();
}
@Test
- public void testInit() {
+ void testInit() {
assertSame(topics, BaseTest.getTopics());
}
@Test
- public void testFinish() {
+ void testFinish() {
base.finish();
verify(topics).destroy();
}
@Test
- public void testTestService123Compliant() {
+ void testTestService123Compliant() {
enqueueAppcLcm("restart", "restart", "restart", "restart", "rebuild", "migrate");
enqueueClMgt(ControlLoopNotificationType.OPERATION_SUCCESS);
enqueueClMgt(ControlLoopNotificationType.FINAL_SUCCESS);
}
@Test
- public void testTestDuplicatesEvents() {
+ void testTestDuplicatesEvents() {
// the test expects the count to be incremented by 2 between calls
- AtomicLong count = new AtomicLong(5);
+ var count = new AtomicLong(5);
base = spy(base);
when(base.getCreateCount()).thenAnswer(args -> count.getAndAdd(2));
}
@Test
- public void testTestVcpeSunnyDayCompliant() {
+ void testTestVcpeSunnyDayCompliant() {
checkAppcLcmPolicy("restart", base::testVcpeSunnyDayCompliant);
}
@Test
- public void testTestVcpeOnsetFloodPrevention() {
+ void testTestVcpeOnsetFloodPrevention() {
enqueueAppcLcm("restart");
enqueueClMgt(ControlLoopNotificationType.OPERATION_SUCCESS);
enqueueClMgt(ControlLoopNotificationType.FINAL_SUCCESS);
}
@Test
- public void testTestVdnsSunnyDayCompliant() {
+ void testTestVdnsSunnyDayCompliant() {
checkHttpPolicy(base::testVdnsSunnyDayCompliant);
}
@Test
- public void testTestVdnsRainyDayCompliant() {
+ void testTestVdnsRainyDayCompliant() {
checkHttpPolicyCompliantFailure(base::testVdnsRainyDayCompliant);
}
@Test
- public void testTestVfwSunnyDayCompliant() {
+ void testTestVfwSunnyDayCompliant() {
checkAppcLegacyPolicy("ModifyConfig", base::testVfwSunnyDayCompliant);
}
@Test
- public void testTestVfwRainyDayOverallTimeout() {
+ void testTestVfwRainyDayOverallTimeout() {
checkAppcLegacyPolicyFinalFailure("ModifyConfig", base::testVfwRainyDayOverallTimeout);
}
@Test
- public void testTestVfwRainyDayCompliantTimeout() {
+ void testTestVfwRainyDayCompliantTimeout() {
checkAppcLegacyPolicyFinalFailure("ModifyConfig", base::testVfwRainyDayCompliantTimeout);
}
@Test
- public void testTestVpciSunnyDayCompliant() {
+ void testTestVpciSunnyDayCompliant() {
checkSdnrPolicy("ModifyConfig", base::testVpciSunnyDayCompliant);
}
@Test
- public void testTestVsonhSunnyDayCompliant() {
+ void testTestVsonhSunnyDayCompliant() {
checkSdnrPolicy("ModifyConfigANR", base::testVsonhSunnyDayCompliant);
}
}
private void enqueueClMgt(ControlLoopNotificationType type) {
- VirtualControlLoopNotification notif = new VirtualControlLoopNotification();
+ var notif = new VirtualControlLoopNotification();
notif.setNotification(type);
notif.setPolicyName(POLICY_NAME + ".EVENT.MANAGER.FINAL");
}
private void enqueueAppcLcm(String... operationNames) {
- for (String oper : operationNames) {
- AppcLcmDmaapWrapper req = new AppcLcmDmaapWrapper();
+ for (var oper : operationNames) {
+ var req = new AppcLcmDmaapWrapper();
req.setRpcName(oper);
- AppcLcmBody body = new AppcLcmBody();
+ var body = new AppcLcmBody();
req.setBody(body);
- AppcLcmInput input = new AppcLcmInput();
+ var input = new AppcLcmInput();
body.setInput(input);
- AppcLcmCommonHeader header = new AppcLcmCommonHeader();
+ var header = new AppcLcmCommonHeader();
input.setCommonHeader(header);
header.setSubRequestId("my-subrequest-id");
}
private void enqueueAppcLegacy(String... operationNames) {
- for (String oper : operationNames) {
- Request req = new Request();
+ for (var oper : operationNames) {
+ var req = new Request();
req.setAction(oper);
- CommonHeader header = new CommonHeader();
+ var header = new CommonHeader();
req.setCommonHeader(header);
header.setSubRequestId("my-subrequest-id");
private void enqueueSdnr(String... operationNames) {
for (String oper : operationNames) {
- PciMessage pcimessage = new PciMessage();
- PciRequest req = new PciRequest();
- PciBody body = new PciBody();
+ var pcimessage = new PciMessage();
+ var req = new PciRequest();
+ var body = new PciBody();
body.setInput(req);
pcimessage.setBody(body);
pcimessage.getBody().getInput().setAction(oper);
- PciCommonHeader header = new PciCommonHeader();
+ var header = new PciCommonHeader();
pcimessage.getBody().getInput().setCommonHeader(header);
header.setSubRequestId("my-subrequest-id");
/*
* We don't want junit trying to run this, so it's marked "Ignore".
*/
- @Ignore
+ @Disabled
private class MyTest extends BaseTest {
@Override
package org.onap.policy.controlloop.common.rules.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.policy.appc.Request;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.onap.policy.appclcm.AppcLcmBody;
import org.onap.policy.appclcm.AppcLcmCommonHeader;
import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.drools.controller.DroolsController;
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.springframework.test.util.ReflectionTestUtils;
-@RunWith(MockitoJUnitRunner.class)
-public class DroolsRuleTestTest {
+class DroolsRuleTestTest {
private static final String CONTROLLER_NAME = "my-controller-name";
private static final String POLICY_NAME = "my-policy-name";
private int permitCount;
private int finalCount;
- @Mock
- private PolicyController controller;
- @Mock
- private Rules rules;
- @Mock
- private HttpClients httpClients;
- @Mock
- private Simulators simulators;
- @Mock
- private Topics topics;
- @Mock
- private Listener<VirtualControlLoopNotification> policyClMgt;
- @Mock
- private Listener<Request> appcClSink;
- @Mock
- private Listener<AppcLcmDmaapWrapper> appcLcmRead;
- @Mock
- private Listener<PciMessage> sdnrClSink;
- @Mock
- private DroolsController drools;
- @Mock
- private ToscaPolicy policy;
- @Mock
- private ToscaConceptIdentifier policyIdent;
-
+ private final PolicyController controller = mock(PolicyController.class);
+ private final Rules rules = mock(Rules.class);
+ private final HttpClients httpClients = mock(HttpClients.class);
+ private final Simulators simulators = mock(Simulators.class);
+ private final Topics topics = mock(Topics.class);
+ private final Listener<VirtualControlLoopNotification> policyClMgt = mock();
+ private final Listener<AppcLcmDmaapWrapper> appcLcmRead = mock();
+ private final DroolsController drools = mock(DroolsController.class);
+ private final ToscaPolicy policy = mock(ToscaPolicy.class);
/**
* Saves static values from the class.
*/
@SuppressWarnings("unchecked")
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
ruleMaker = (Function<String, Rules>) ReflectionTestUtils.getField(DroolsRuleTest.class, "ruleMaker");
httpClientMaker = (Supplier<HttpClients>) ReflectionTestUtils.getField(DroolsRuleTest.class, "httpClientMaker");
/**
* Restores static values.
*/
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
ReflectionTestUtils.setField(DroolsRuleTest.class, "ruleMaker", ruleMaker);
ReflectionTestUtils.setField(DroolsRuleTest.class, "httpClientMaker", httpClientMaker);
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
when(rules.getController()).thenReturn(controller);
when(rules.setupPolicyFromFile(any())).thenReturn(policy);
}
@Test
- public void testInitStatics() {
+ void testInitStatics() {
assertSame(rules, DroolsRuleTest.rules);
assertSame(httpClients, DroolsRuleTest.httpClients);
assertSame(simulators, DroolsRuleTest.simulators);
}
@Test
- public void testFinishStatics() {
+ void testFinishStatics() {
DroolsRuleTest.finishStatics();
verify(rules).destroy();
}
@Test
- public void testInit() {
+ void testInit() {
assertSame(topics, BaseTest.getTopics());
assertSame(controller, base.controller);
}
@Test
- public void testDroolsTestService123Compliant() {
+ void testDroolsTestService123Compliant() {
enqueueAppcLcm("restart", "restart", "restart", "restart", "rebuild", "migrate");
enqueueClMgt(ControlLoopNotificationType.OPERATION_SUCCESS);
enqueueClMgt(ControlLoopNotificationType.FINAL_SUCCESS);
* We don't want junit trying to run this, so it's marked "Ignore".
*/
- @Ignore
+ @Disabled
private class MyDroolsTest extends DroolsRuleTest {
@Override
* ONAP
* ================================================================================
* Copyright (C) 2020 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.controlloop.common.rules.test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class ExceptionsTest {
+class ExceptionsTest {
@Test
- public void test() {
+ void test() {
assertEquals(4, new ExceptionsTester().testAllException(TopicException.class));
assertEquals(4, new ExceptionsTester().testAllException(SimulatorException.class));
* 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.
package org.onap.policy.controlloop.common.rules.test;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Properties;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.policy.common.endpoints.http.client.HttpClient;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
-@RunWith(MockitoJUnitRunner.class)
-public class HttpClientsTest {
+class HttpClientsTest {
private static final String CLIENT_NAME = "MY-CLIENT";
- @Mock
- private HttpClientFactory factory;
+ private final HttpClientFactory factory = mock(HttpClientFactory.class);
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
}
- @After
+ @AfterEach
public void tearDown() {
HttpClientFactoryInstance.getClientFactory().destroy();
}
@Test
- public void test() throws HttpClientConfigException {
+ void test() throws HttpClientConfigException {
HttpClientFactoryInstance.getClientFactory().destroy();
- HttpClients clients = new HttpClients();
+ var clients = new HttpClients();
clients.addClients("my");
// should find the client now
- HttpClient client = HttpClientFactoryInstance.getClientFactory().get(CLIENT_NAME);
+ var client = HttpClientFactoryInstance.getClientFactory().get(CLIENT_NAME);
assertNotNull(client);
clients.destroy();
assertThatIllegalArgumentException().isThrownBy(() -> clients.addClients("unknown"));
// force exception from builder
- HttpClients clients2 = new HttpClients() {
+ var clients2 = new HttpClients() {
@Override
protected HttpClientFactory getClientFactory() {
return factory;
* 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.
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
-@RunWith(MockitoJUnitRunner.class)
-public class ListenerTest {
+class ListenerTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String MY_TOPIC = "my-topic";
private static final String MESSAGE = "the-message";
private static final String MSG_SUFFIX = "s";
private static final String DECODED_MESSAGE = MESSAGE + MSG_SUFFIX;
- @Mock
- private NoopTopicSink sink;
- @Mock
- private TopicEndpoint mgr;
+ private final NoopTopicSink sink = mock(NoopTopicSink.class);
+
+ private final TopicEndpoint mgr = mock(TopicEndpoint.class);
private Listener<String> listener;
/**
* Creates topics.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
TopicEndpointManager.getManager().shutdown();
- TopicParameters params = new TopicParameters();
+ var params = new TopicParameters();
params.setTopic(MY_TOPIC);
params.setManaged(true);
params.setTopicCommInfrastructure("NOOP");
TopicEndpointManager.getManager().addTopicSinks(List.of(params));
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
TopicEndpointManager.getManager().shutdown();
}
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
when(mgr.getNoopTopicSink(MY_TOPIC)).thenReturn(sink);
}
@Test
- public void testListener() {
+ void testListener() {
verify(sink).register(listener);
}
@Test
- public void testAwait_testAwaitLongTimeUnit_testIsEmpty() {
+ void testAwait_testAwaitLongTimeUnit_testIsEmpty() {
assertTrue(listener.isEmpty());
listener.onTopicEvent(CommInfrastructure.NOOP, MY_TOPIC, MESSAGE);
}
@Test
- public void testAwaitPredicateOfT() {
+ void testAwaitPredicateOfT() {
listener.onTopicEvent(CommInfrastructure.NOOP, MY_TOPIC, MESSAGE);
listener.onTopicEvent(CommInfrastructure.NOOP, MY_TOPIC, MESSAGE2);
assertEquals(MESSAGE2 + MSG_SUFFIX, listener.await(msg -> msg.startsWith("other-")));
* Tests await() when the remaining time is negative.
*/
@Test
- public void testAwaitLongTimeUnitPredicateNoTime() {
+ void testAwaitLongTimeUnitPredicateNoTime() {
assertThatThrownBy(() -> listener.await(-1, TimeUnit.SECONDS)).isInstanceOf(TopicException.class);
}
* Tests await() when the poll() returns {@code null}.
*/
@Test
- public void testAwaitLongTimeUnitPredicateNoMessage() {
+ void testAwaitLongTimeUnitPredicateNoMessage() {
assertThatThrownBy(() -> listener.await(1, TimeUnit.MILLISECONDS)).isInstanceOf(TopicException.class);
}
* Tests await() when the poll() is interrupted.
*/
@Test
- public void testAwaitLongTimeUnitPredicateInterrupted() throws InterruptedException {
+ void testAwaitLongTimeUnitPredicateInterrupted() throws InterruptedException {
listener = new Listener<String>(MY_TOPIC, msg -> msg) {
@Override
protected String pollMessage(long remainingMs) throws InterruptedException {
};
AtomicReference<TopicException> exref = new AtomicReference<>();
- CountDownLatch interrupted = new CountDownLatch(1);
+ var interrupted = new CountDownLatch(1);
- Thread thread = new Thread() {
+ var thread = new Thread() {
@Override
public void run() {
try {
}
@Test
- public void testUnregister() {
+ void testUnregister() {
listener.unregister();
verify(sink).unregister(listener);
}
@Test
- public void testOnTopicEvent() {
+ void testOnTopicEvent() {
listener = new Listener<>(MY_TOPIC, msg -> {
throw new IllegalArgumentException(EXPECTED_EXCEPTION);
});
}
@Test
- public void testGetTopicManager() {
+ void testGetTopicManager() {
// use a listener with a real manager
assertNotNull(new Listener<>(MY_TOPIC, msg -> msg).getTopicManager());
}
* ONAP
* ================================================================================
* Copyright (C) 2020 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.controlloop.common.rules.test;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.AfterClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
/**
* Tests NamedRunner when the TestNames annotation is missing - all tests should be
* executed.
*/
-@RunWith(NamedRunner.class)
-public class NamedRunner2Test {
+@ExtendWith(NamedRunner.class)
+class NamedRunner2Test {
private static int testCount = 0;
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
assertEquals(2, testCount);
}
@Test
- public void testAbc() {
+ void testAbc() {
checkTest();
}
@Test
- public void testDef() {
+ void testDef() {
checkTest();
}
* ONAP
* ================================================================================
* Copyright (C) 2020 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.controlloop.common.rules.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.AfterClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
/**
* Tests NamedRunner. The tests don't do much, because all we really want to check is
* which tests are executed based on the {@link TestNames} annotation.
*/
-@RunWith(NamedRunner.class)
+@ExtendWith(NamedRunner.class)
@TestNames(names = {"testAbc", "testDef", "testIgnore"}, prefixes = {"testGhi", "testJkl"})
-public class NamedRunnerTest {
+class NamedRunnerTest {
private static int testCount = 0;
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
assertEquals(5, testCount);
}
@Test
- public void testAbc() {
+ void testAbc() {
checkTest();
}
@Test
- public void testAbc2() {
+ void testAbc2() {
fail("should not run");
}
@Test
- public void testDef() {
+ void testDef() {
checkTest();
}
* NamedRunner skips over it, hence the sonar issue is being suppressed.
*/
@Test
- @Ignore
+ @Disabled
public void testIgnore() { // NOSONAR
fail("should not run");
}
@Test
- public void testGhi1() {
+ void testGhi1() {
checkTest();
}
@Test
- public void testGhi2() {
+ void testGhi2() {
checkTest();
}
@Test
- public void testJkl() {
+ void testJkl() {
checkTest();
}
* 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.
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.kie.api.definition.rule.Rule;
import org.kie.api.event.rule.AfterMatchFiredEvent;
import org.kie.api.event.rule.AgendaEventListener;
import org.kie.api.event.rule.RuleRuntimeEventListener;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.Match;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
import org.onap.policy.controlloop.ControlLoopEvent;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.LoggerFactory;
-@RunWith(MockitoJUnitRunner.class)
-public class RulesTest {
+class RulesTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String CONTROLLER_NAME = "rulesTest";
private static final String POLICY_FILE = "src/test/resources/tosca-policy.json";
private static final Logger logger = (Logger) LoggerFactory.getLogger(Rules.class);
private static final ExtractAppender appender = new ExtractAppender();
- @Mock
- private PolicyEngine engine;
- @Mock
- private SystemPersistence repo;
- @Mock
- private PolicyController controller;
- @Mock
- private KieSession kieSession;
- @Mock
- private PolicyControllerFactory controllerFactory;
- @Mock
- private DroolsController drools;
+ private final PolicyEngine engine = mock(PolicyEngine.class);
+ private final SystemPersistence repo = mock(SystemPersistence.class);
+ private final PolicyController controller = mock(PolicyController.class);
+ private final KieSession kieSession = mock(KieSession.class);
+ private final PolicyControllerFactory controllerFactory = mock(PolicyControllerFactory.class);
+ private final DroolsController drools = mock(DroolsController.class);
private List<Object> facts;
private List<RuleRuntimeEventListener> ruleListeners;
/**
* Attaches the appender to the logger.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws Exception {
/*
* Attach appender to the logger.
/**
* Stops the appender.
*/
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
appender.stop();
}
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
facts = new LinkedList<>();
ruleListeners = new LinkedList<>();
when(controller.getDrools()).thenReturn(drools);
when(drools.facts(eq(CONTROLLER_NAME), any())).thenAnswer(args -> {
- Class<?> clazz = args.getArgument(1);
+ var clazz = args.getArgument(1);
return facts.stream().filter(obj -> obj.getClass() == clazz).collect(Collectors.toList());
});
// notify listeners when objects are added to drools
when(drools.offer(any())).thenAnswer(args -> {
- Object object = args.getArgument(0);
+ var object = args.getArgument(0);
notifyInserted(object);
if (!(object instanceof ToscaPolicy)) {
}
// "insert" Params objects associated with the policy (i.e., mimic the rules)
- ToscaPolicy policy = (ToscaPolicy) object;
- ControlLoopParams params = new ControlLoopParams();
+ var policy = (ToscaPolicy) object;
+ var params = new ControlLoopParams();
params.setToscaPolicy(policy);
notifyInserted(params);
});
when(drools.delete(any())).thenAnswer(args -> {
- Class<?> clazz = args.getArgument(0);
+ var clazz = args.getArgument(0);
facts.removeIf(obj -> obj.getClass() == clazz);
return null;
});
}
@Test
- public void testRules() {
+ void testRules() {
assertEquals(CONTROLLER_NAME, rules.getControllerName());
assertSame(engine, rules.getPdpd());
}
@Test
- public void testStart() throws Exception {
+ void testStart() throws Exception {
verify(repo).setConfigurationDir("src/test/resources/config");
assertTrue(installed);
verify(engine).configure(any(Properties.class));
}
@Test
- public void testDestroy() {
+ void testDestroy() {
rules.destroy();
verify(controllerFactory).shutdown(CONTROLLER_NAME);
}
@Test
- public void testResetFacts() {
+ void testResetFacts() {
rules.resetFacts();
verify(drools).delete(ToscaPolicy.class);
}
@Test
- public void testSetupPolicyFromTemplate_testGetPolicyFromTemplate() throws InterruptedException {
+ void testSetupPolicyFromTemplate_testGetPolicyFromTemplate() throws InterruptedException {
rules.setupPolicyFromTemplate("tosca-template.json", MY_POLICY);
assertThatIllegalArgumentException()
}
@Test
- public void testSetupPolicyFromFile_testGetPolicyFromFile_testSetupPolicy() throws InterruptedException {
+ void testSetupPolicyFromFile_testGetPolicyFromFile_testSetupPolicy() throws InterruptedException {
assertNotNull(rules.setupPolicyFromFile(POLICY_FILE));
assertThatIllegalArgumentException().isThrownBy(() -> rules.setupPolicyFromFile("missing-file.json"));
}
@Test
- public void testRuleListenerLogger() {
- Rule rule = mock(Rule.class);
+ void testRuleListenerLogger() {
+ var rule = mock(Rule.class);
when(rule.getName()).thenReturn(MY_RULE_NAME);
// insertions - with and without rule name
- ObjectInsertedEvent insert = mock(ObjectInsertedEvent.class);
+ var insert = mock(ObjectInsertedEvent.class);
when(insert.getObject()).thenReturn(MY_TEXT);
checkLogging("inserted", () -> ruleListeners.forEach(listener -> listener.objectInserted(insert)));
when(insert.getRule()).thenReturn(rule);
checkLogging("inserted", () -> ruleListeners.forEach(listener -> listener.objectInserted(insert)));
// updates - with and without rule name
- ObjectUpdatedEvent update = mock(ObjectUpdatedEvent.class);
+ var update = mock(ObjectUpdatedEvent.class);
when(update.getObject()).thenReturn(MY_TEXT);
checkLogging("updated", () -> ruleListeners.forEach(listener -> listener.objectUpdated(update)));
when(update.getRule()).thenReturn(rule);
checkLogging("updated", () -> ruleListeners.forEach(listener -> listener.objectUpdated(update)));
// deletions - with and without rule name
- ObjectDeletedEvent delete = mock(ObjectDeletedEvent.class);
+ var delete = mock(ObjectDeletedEvent.class);
when(delete.getOldObject()).thenReturn(MY_TEXT);
checkLogging("deleted", () -> ruleListeners.forEach(listener -> listener.objectDeleted(delete)));
when(delete.getRule()).thenReturn(rule);
}
@Test
- public void testAgendaListenerLogger() {
- Rule rule = mock(Rule.class);
+ void testAgendaListenerLogger() {
+ var rule = mock(Rule.class);
when(rule.getName()).thenReturn(MY_RULE_NAME);
- Match match = mock(Match.class);
+ var match = mock(Match.class);
when(match.getRule()).thenReturn(rule);
// create
- MatchCreatedEvent create = mock(MatchCreatedEvent.class);
+ var create = mock(MatchCreatedEvent.class);
when(create.getMatch()).thenReturn(match);
checkLogging("match created", () -> agendaListeners.forEach(listener -> listener.matchCreated(create)));
// cancel
- MatchCancelledEvent cancel = mock(MatchCancelledEvent.class);
+ var cancel = mock(MatchCancelledEvent.class);
when(cancel.getMatch()).thenReturn(match);
checkLogging("match cancelled", () -> agendaListeners.forEach(listener -> listener.matchCancelled(cancel)));
// before-fire
- BeforeMatchFiredEvent before = mock(BeforeMatchFiredEvent.class);
+ var before = mock(BeforeMatchFiredEvent.class);
when(before.getMatch()).thenReturn(match);
// @formatter:off
checkLogging("before match fired",
// @formatter:on
// after-fire
- AfterMatchFiredEvent after = mock(AfterMatchFiredEvent.class);
+ var after = mock(AfterMatchFiredEvent.class);
when(after.getMatch()).thenReturn(match);
checkLogging("after match fired", () -> agendaListeners.forEach(listener -> listener.afterMatchFired(after)));
}
@Test
- public void testMakePdpd_testMakePdpdRepo() {
+ void testMakePdpd_testMakePdpdRepo() {
// need rules that makes real objects
rules = new Rules(CONTROLLER_NAME);
BlockingQueue<IllegalArgumentException> exceptions = new LinkedBlockingQueue<>();
- Thread thread = new Thread(() -> {
+ var thread = new Thread(() -> {
try {
command.run();
} catch (IllegalArgumentException e) {
private void checkLogging(String expectedMsg, Runnable command) {
appender.clearExtractions();
command.run();
- List<String> messages = appender.getExtracted();
+ var messages = appender.getExtracted();
assertEquals(1, messages.size());
assertThat(messages.get(0)).contains(expectedMsg);
}
facts.add(object);
// increase code coverage by adding random objects
- ObjectInsertedEvent event0 = mock(ObjectInsertedEvent.class);
+ var event0 = mock(ObjectInsertedEvent.class);
when(event0.getObject()).thenReturn(new Object());
ruleListeners.forEach(listener -> listener.objectInserted(event0));
// increase code coverage by adding a random object
- ObjectInsertedEvent event = mock(ObjectInsertedEvent.class);
+ var event = mock(ObjectInsertedEvent.class);
when(event.getObject()).thenReturn(object);
if (object instanceof ToscaPolicy) {
// increase code coverage by associating it with a random rule
- Rule rule = mock(Rule.class);
+ var rule = mock(Rule.class);
when(rule.getName()).thenReturn(MY_RULE_NAME);
when(event.getRule()).thenReturn(rule);
}
* ONAP
* ================================================================================
* Copyright (C) 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.
package org.onap.policy.controlloop.common.rules.test;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class SimulatorExceptionTest {
+class SimulatorExceptionTest {
@Test
- public void test() {
+ void test() {
new ExceptionsTester().test(SimulatorException.class);
}
}
* 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.
package org.onap.policy.controlloop.common.rules.test;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.controlloop.common.rules.test.Simulators.SimulatorBuilder;
-@RunWith(MockitoJUnitRunner.class)
-public class SimulatorsTest {
+class SimulatorsTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
- @Mock
- private HttpServletServer server1;
- @Mock
- private HttpServletServer server2;
- @Mock
- private HttpServletServer server3;
+ private final HttpServletServer server1 = mock(HttpServletServer.class);
+ private final HttpServletServer server2 = mock(HttpServletServer.class);
+ private final HttpServletServer server3 = mock(HttpServletServer.class);
private Simulators simulators;
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
simulators = new Simulators();
}
@Test
- public void testStart() {
+ void testStart() {
simulators.start(() -> server1, () -> server2);
assertEquals(List.of(server1, server2), simulators.getServers());
* Tests start() when one of the builders throws an exception.
*/
@Test
- public void testStartException() {
+ void testStartException() {
SimulatorBuilder exbuilder = () -> {
throw new InterruptedException(EXPECTED_EXCEPTION);
};
}
@Test
- public void testDestroy() {
+ void testDestroy() {
simulators.start(() -> server1, () -> server2, () -> server3);
doThrow(new IllegalStateException(EXPECTED_EXCEPTION)).when(server2).shutdown();
* 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.
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.List;
import java.util.concurrent.TimeUnit;
import lombok.ToString;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-@RunWith(MockitoJUnitRunner.class)
-public class TopicsTest {
+class TopicsTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String MY_SOURCE_TOPIC = "my-source-topic";
private static final String MY_SINK_TOPIC = "my-sink-topic";
private static final String INJECT_FILE = "src/test/resources/topics.json";
private static final String POLICY_NAME = "my-policy";
- @Mock
- private DroolsController drools;
- @Mock
- private PolicyController controller;
- @Mock
- private EventProtocolCoder protocolCoder;
- @Mock
- private NoopTopicSink sink;
- @Mock
- private NoopTopicSource source;
- @Mock
- private TopicEndpoint mgr;
+ private final DroolsController drools = mock(DroolsController.class);
+ private final PolicyController controller = mock(PolicyController.class);
+ private final EventProtocolCoder protocolCoder = mock(EventProtocolCoder.class);
+ private final NoopTopicSink sink = mock(NoopTopicSink.class);
+ private final NoopTopicSource source = mock(NoopTopicSource.class);
+ private final TopicEndpoint mgr = mock(TopicEndpoint.class);
private ToscaPolicy policy;
/**
* Creates topics.
*/
- @BeforeClass
- public static void setUpBeforeClass() {
+ @BeforeAll
+ static void setUpBeforeClass() {
TopicEndpointManager.getManager().shutdown();
- TopicParameters params = new TopicParameters();
+ var params = new TopicParameters();
params.setTopic(MY_SOURCE_TOPIC);
params.setManaged(true);
params.setTopicCommInfrastructure("NOOP");
TopicEndpointManager.getManager().addTopicSources(List.of(params));
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
TopicEndpointManager.getManager().shutdown();
}
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
policy = new ToscaPolicy();
policy.setName(POLICY_NAME);
}
@Test
- public void testDestroy() {
- Listener<String> listener1 = topics.createListener(MY_SINK_TOPIC, msg -> msg);
- Listener<String> listener2 = topics.createListener(MY_SINK_TOPIC, msg -> msg + "a suffix");
+ void testDestroy() {
+ var listener1 = topics.createListener(MY_SINK_TOPIC, msg -> msg);
+ var listener2 = topics.createListener(MY_SINK_TOPIC, msg -> msg + "a suffix");
topics.destroy();
}
@Test
- public void testInjectStringFile() throws IOException {
+ void testInjectStringFile() throws IOException {
topics.inject(MY_SOURCE_TOPIC, INJECT_FILE);
// nothing should have been replaced
- String expected = new String(Files.readAllBytes(Paths.get(INJECT_FILE)));
+ var expected = new String(Files.readAllBytes(Paths.get(INJECT_FILE)));
verify(source).offer(expected);
}
@Test
- public void testInjectStringFileString() throws IOException {
+ void testInjectStringFileString() throws IOException {
topics.inject(MY_SOURCE_TOPIC, INJECT_FILE, "hello");
// text should have been replaced with "hello"
- String expected = new String(Files.readAllBytes(Paths.get("src", "test", "resources", "topicsReplaced.json")));
+ var expected = new String(Files.readAllBytes(Paths.get("src", "test", "resources", "topicsReplaced.json")));
verify(source).offer(expected);
// exception reading file
}
@Test
- public void testCreateListenerStringClassOfTPolicyController() {
- Listener<String> listener = topics.createListener(MY_SINK_TOPIC, String.class, controller);
+ void testCreateListenerStringClassOfTPolicyController() {
+ var listener = topics.createListener(MY_SINK_TOPIC, String.class, controller);
listener.onTopicEvent(CommInfrastructure.NOOP, MY_SINK_TOPIC, MESSAGE);
assertEquals(TEXT, listener.await());
}
@Test
- public void testCreateListenerStringClassOfTCoder() {
- Listener<Data> listener = topics.createListener(MY_SINK_TOPIC, Data.class, new StandardCoder());
+ void testCreateListenerStringClassOfTCoder() {
+ var listener = topics.createListener(MY_SINK_TOPIC, Data.class, new StandardCoder());
listener.onTopicEvent(CommInfrastructure.NOOP, MY_SINK_TOPIC, MESSAGE);
- Data expected = new Data();
+ var expected = new Data();
expected.text = TEXT;
assertEquals(expected.toString(), listener.await().toString());
}
* Tests createListener() when the coder throws an exception.
*/
@Test
- public void testCreateListenerStringClassOfTCoderException() {
- StandardCoder coder = new StandardCoder() {
+ void testCreateListenerStringClassOfTCoderException() {
+ var coder = new StandardCoder() {
@Override
public <T> T decode(String arg0, Class<T> arg1) throws CoderException {
throw new CoderException(EXPECTED_EXCEPTION);
}
};
- Listener<Data> listener = topics.createListener(MY_SINK_TOPIC, Data.class, coder);
+ var listener = topics.createListener(MY_SINK_TOPIC, Data.class, coder);
// onTopicEvent() should not throw an exception
assertThatCode(() -> listener.onTopicEvent(CommInfrastructure.NOOP, MY_SINK_TOPIC, MESSAGE))
}
@Test
- public void testCreateListenerStringFunctionOfStringT() {
- Listener<String> listener = topics.createListener(MY_SINK_TOPIC, msg -> msg);
+ void testCreateListenerStringFunctionOfStringT() {
+ var listener = topics.createListener(MY_SINK_TOPIC, msg -> msg);
listener.onTopicEvent(CommInfrastructure.NOOP, MY_SINK_TOPIC, MESSAGE);
assertEquals(MESSAGE, listener.await());
}
@Test
- public void testGetTopicManager_testGetProtocolCoder() {
+ void testGetTopicManager_testGetProtocolCoder() {
// use a topic with a real manager
topics = new Topics();
* ONAP
* ================================================================================
* Copyright (C) 2020 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.
$params : ControlLoopParams()
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: {} : TOSCA-POLICY=[{}]", $params.getClosedLoopControlName(), $params.getPolicyName() + "."
+ drools.getRule().getName(), $params.getToscaPolicy());
end
$policy : ToscaPolicy()
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: [{}|{}|{}|{}]: CONTENT: {}", drools.getRule().getName(),
$policy.getType(), $policy.getTypeVersion(), $policy.getName(),
$policy.getVersion(), $policy);
not ( ToscaPolicy( getName() == $policyName, getVersion() == $policyVersion ) )
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}: [{}|{}|{}]", drools.getRule().getName(),
$params.getPolicyScope(), $params.getPolicyName(), $params.getPolicyVersion());
================================================================================
Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2019-2020 Bell Canada.
+ 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.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
- <parent>
- <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
- <artifactId>drools-applications-packages</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
+ <artifactId>drools-applications-packages</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
- <artifactId>apps-controlloop</artifactId>
+ <artifactId>apps-controlloop</artifactId>
- <name>apps-controlloop</name>
- <description>Drools Applications Installation Package</description>
+ <name>apps-controlloop</name>
+ <description>Drools Applications Installation Package</description>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-complete-zip</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-complete-zip</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
- <!-- List any dependencies here that should be included in the control loop app zip -->
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
- <artifactId>basex-controlloop</artifactId>
- <version>${project.version}</version>
- <type>tar.gz</type>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
- <artifactId>artifacts-controlloop</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
- <artifactId>feature-controlloop-management</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
- <artifactId>feature-controlloop-utils</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
- <artifactId>feature-controlloop-trans</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
- <artifactId>feature-controlloop-usecases</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- </dependency>
- </dependencies>
+ <!-- List any dependencies here that should be included in the control loop app zip -->
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
+ <artifactId>basex-controlloop</artifactId>
+ <version>${project.version}</version>
+ <type>tar.gz</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
+ <artifactId>artifacts-controlloop</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
+ <artifactId>feature-controlloop-management</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
+ <artifactId>feature-controlloop-utils</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
+ <artifactId>feature-controlloop-trans</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
+ <artifactId>feature-controlloop-usecases</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
+ </dependencies>
</project>
================================================================================
Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
+ 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.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
-
- <parent>
- <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
- <artifactId>drools-applications-packages</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>artifacts-controlloop</artifactId>
-
- <name>artifacts-controlloop</name>
- <description>Companion artifacts for a drools application to install in nexus repository</description>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <descriptors>
- <descriptor>src/assembly/zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <!-- Placed here any Control Loop Application Dependencies to be
- installed in local nexus instance: currently none necessary -->
- </dependencies>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
+
+ <parent>
+ <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
+ <artifactId>drools-applications-packages</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>artifacts-controlloop</artifactId>
+
+ <name>artifacts-controlloop</name>
+ <description>Companion artifacts for a drools application to install in nexus repository</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- Placed here any Control Loop Application Dependencies to be
+ installed in local nexus instance: currently none necessary -->
+ </dependencies>
</project>
================================================================================
Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
+ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<parent>
<groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
<artifactId>drools-applications-packages</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>basex-controlloop</artifactId>
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
<artifactId>drools-applications-packages</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>docker-controlloop</artifactId>
<packaging>pom</packaging>
<description>ONAP Policy Control Loop PDP-D Docker Build</description>
<properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<dist.project.version>${project.version}</dist.project.version>
<docker.skip>false</docker.skip>
replace the parameterized base-image version. The fabric8.io docker-maven-plugin shall use this filtered file
to build the image. After the image is built we perform a cleanup to remove the filtered file.-->
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
+ <version>3.1.0</version>
<executions>
<execution>
<id>update-parameterized-dockerfile</id>
<goal>run</goal>
</goals>
<configuration>
- <tasks>
- <copy file="src/main/docker/Dockerfile" toFile="${project.build.directory}/docker-tmp/Dockerfile">
+ <target>
+ <copy file="src/main/docker/Dockerfile"
+ toFile="${project.build.directory}/docker-tmp/Dockerfile">
<filterset>
<filter token="version.policy.drools-pdp" value="${version.policy.drools-pdp}"/>
</filterset>
</copy>
- </tasks>
+ </target>
</configuration>
</execution>
</executions>
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>docker-drools-apps</id>
<fileSets>
<fileSet>
================================================================================
Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2019-2020 Bell Canada.
+ 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.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <parent>
- <groupId>org.onap.policy.drools-applications.controlloop</groupId>
- <artifactId>controlloop</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
- <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
- <artifactId>drools-applications-packages</artifactId>
- <name>PDP-D Application Installation Packages</name>
- <description>PDP-D Installation</description>
- <profiles>
- <profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>basex-controlloop</module>
- <module>artifacts-controlloop</module>
- <module>apps-controlloop</module>
- </modules>
- </profile>
- <profile>
- <id>docker</id>
- <modules>
- <module>basex-controlloop</module>
- <module>artifacts-controlloop</module>
- <module>apps-controlloop</module>
- <module>docker-controlloop</module>
- </modules>
- <properties>
- <docker.skip.push>false</docker.skip.push>
- </properties>
- </profile>
- </profiles>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
+ <parent>
+ <groupId>org.onap.policy.drools-applications.controlloop</groupId>
+ <artifactId>controlloop</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
+ <artifactId>drools-applications-packages</artifactId>
+ <name>PDP-D Application Installation Packages</name>
+ <description>PDP-D Installation</description>
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>basex-controlloop</module>
+ <module>artifacts-controlloop</module>
+ <module>apps-controlloop</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>docker</id>
+ <modules>
+ <module>basex-controlloop</module>
+ <module>artifacts-controlloop</module>
+ <module>apps-controlloop</module>
+ <module>docker-controlloop</module>
+ </modules>
+ <properties>
+ <docker.skip.push>false</docker.skip.push>
+ </properties>
+ </profile>
+ </profiles>
</project>
drools-applications
================================================================================
Copyright (C) 2017, 2020 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.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <parent>
- <groupId>org.onap.policy.drools-applications</groupId>
- <artifactId>drools-applications</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>drools-applications</artifactId>
+ <version>2.0.1-SNAPSHOT</version>
+ </parent>
- <groupId>org.onap.policy.drools-applications.controlloop</groupId>
- <artifactId>controlloop</artifactId>
+ <groupId>org.onap.policy.drools-applications.controlloop</groupId>
+ <artifactId>controlloop</artifactId>
- <properties>
- <jacoco.dataFile>${project.basedir}/../../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
- </properties>
+ <properties>
+ <jacoco.dataFile>${project.basedir}/../../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
+ </properties>
- <modules>
- <module>common</module>
- <module>packages</module>
- </modules>
+ <modules>
+ <module>common</module>
+ <module>packages</module>
+ </modules>
</project>
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.parent</groupId>
<artifactId>integration</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath />
+ <version>4.0.1-SNAPSHOT</version>
+ <relativePath/>
</parent>
<groupId>org.onap.policy.drools-applications</groupId>
<artifactId>drools-applications</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
<name>policy-drools-applications</name>
<packaging>pom</packaging>
<releases.path>content/repositories/releases/</releases.path>
<snapshots.path>content/repositories/snapshots/</snapshots.path>
<staging.path>content/repositories/staging/</staging.path>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Project common dependency versions -->
- <version.policy.common>2.0.0-SNAPSHOT</version.policy.common>
- <policy.models.version>3.0.0-SNAPSHOT</policy.models.version>
- <version.policy.drools-pdp>2.0.0-SNAPSHOT</version.policy.drools-pdp>
+ <version.policy.common>2.0.1-SNAPSHOT</version.policy.common>
+ <policy.models.version>3.0.1-SNAPSHOT</policy.models.version>
+ <version.policy.drools-pdp>2.0.1-SNAPSHOT</version.policy.drools-pdp>
+ <surefireArgLine>
+ --add-opens java.base/java.lang=ALL-UNNAMED
+ </surefireArgLine>
</properties>
<build>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
- <skip />
+ <skip/>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <encoding>${project.encoding}</encoding>
+ <encoding>${project.build.sourceEncoding}</encoding>
<release>${java.version}</release>
</configuration>
</plugin>
</dependency>
</dependencies>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
</plugins>
</build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.10.4</version>
<configuration>
<failOnError>false</failOnError>
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
</reporting>
<dependencies>
+ <dependency>
+ <groupId>org.kie</groupId>
+ <artifactId>kie-ci</artifactId>
+ </dependency>
+
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
================================================================================
Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
+ 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.
limitations under the License.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.drools-applications</groupId>
<artifactId>drools-applications-testsuites</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>drools-applications-performance</artifactId>
<build>
Copyright (C) 2018 Ericsson. All rights reserved.
Modifications Copyright (C) 2018, 2020 AT&T. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
+ 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.
<parent>
<groupId>org.onap.policy.drools-applications</groupId>
<artifactId>drools-applications</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>drools-applications-testsuites</artifactId>
<packaging>pom</packaging>
<properties>
- <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. -->
+ <!-- There is no code in this submodule, only holds interfaces. So skip sonar. -->
<sonar.skip>true</sonar.skip>
</properties>
================================================================================
Copyright (C) 2018 Ericsson. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
+ 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.
limitations under the License.
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.drools-applications</groupId>
<artifactId>drools-applications-testsuites</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>drools-applications-stability</artifactId>
<build>
minor=2
minor=0
-patch=0
+patch=1
base_version=${major}.${minor}.${patch}