summaryrefslogtreecommitdiffstats
path: root/controlloop/common/controller-usecases
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/controller-usecases')
-rw-r--r--controlloop/common/controller-usecases/pom.xml17
-rw-r--r--controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java3
-rw-r--r--controlloop/common/controller-usecases/src/main/resources/usecases.drl51
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java24
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java66
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java34
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java140
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiCqStep2Test.java55
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetPnfStep2Test.java55
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetTenantStep2Test.java59
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GetTargetEntityStep2Test.java40
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GuardStep2Test.java72
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/LockStep2Test.java42
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java124
14 files changed, 356 insertions, 426 deletions
diff --git a/controlloop/common/controller-usecases/pom.xml b/controlloop/common/controller-usecases/pom.xml
index cbff5b626..7cb1fe1e6 100644
--- a/controlloop/common/controller-usecases/pom.xml
+++ b/controlloop/common/controller-usecases/pom.xml
@@ -20,13 +20,14 @@
============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>
@@ -40,6 +41,7 @@
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
+ <version>${version.drools}</version>
<extensions>true</extensions>
</plugin>
</plugins>
@@ -195,6 +197,15 @@
<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>
@@ -231,7 +242,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
index 4d2dfa303..8d09b1c40 100644
--- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
+++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
@@ -252,8 +252,7 @@ public class UsecasesEventManager extends ClEventManagerWithEvent<Step2> impleme
throw new ControlLoopException("The Target type is null");
}
switch (event.getTargetType()) {
- case VM:
- case VNF:
+ case VM, VNF:
validateAaiVmVnfData(eventAai);
return;
case PNF:
diff --git a/controlloop/common/controller-usecases/src/main/resources/usecases.drl b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
index 0e1f7de66..c10b8d0c9 100644
--- a/controlloop/common/controller-usecases/src/main/resources/usecases.drl
+++ b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +61,7 @@ rule "CREATE.EVENT.SERVICES"
not (EventManagerServices())
then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackageName());
logger.info("{}", drools.getRule().getName());
try {
@@ -81,7 +82,7 @@ rule "INSERT.PARAMS"
$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
@@ -96,7 +97,7 @@ rule "NEW.TOSCA.POLICY"
$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);
@@ -116,7 +117,7 @@ rule "REMOVE.PARAMS"
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());
@@ -138,7 +139,7 @@ rule "EVENT"
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);
@@ -231,7 +232,7 @@ rule "EVENT.MANAGER.NEW.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);
@@ -286,7 +287,7 @@ rule "EVENT.MANAGER.LOAD.NEXT.POLICY"
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);
@@ -324,7 +325,7 @@ rule "EVENT.MANAGER.PREPROCESS"
!$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);
@@ -368,7 +369,7 @@ rule "EVENT.MANAGER.ACCEPT"
$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);
@@ -408,7 +409,7 @@ rule "EVENT.MANAGER.EXECUTE.STEP"
$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);
@@ -470,7 +471,7 @@ rule "EVENT.MANAGER.GENERATE.SDNR.NOTIFICATION"
$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);
@@ -506,7 +507,7 @@ rule "EVENT.MANAGER.PROCESS.GUARD.OUTCOME"
$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);
@@ -562,7 +563,7 @@ rule "EVENT.MANAGER.PROCESS.POLICY.STARTED"
$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);
@@ -614,7 +615,7 @@ rule "EVENT.MANAGER.PROCESS.PREPROCESSOR.STARTED"
$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);
@@ -654,7 +655,7 @@ rule "EVENT.MANAGER.PROCESS.POLICY.SUCCESS"
$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);
@@ -715,7 +716,7 @@ rule "EVENT.MANAGER.PROCESS.FINAL.FAILURE.ACCEPTED"
$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);
@@ -740,7 +741,7 @@ rule "EVENT.MANAGER.PROCESS.FINAL.FAILURE.ACCEPTED"
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();
@@ -780,7 +781,7 @@ rule "EVENT.MANAGER.PROCESS.FINAL.FAILURE.REJECTED"
$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);
@@ -799,7 +800,7 @@ rule "EVENT.MANAGER.PROCESS.FINAL.FAILURE.REJECTED"
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());
@@ -834,7 +835,7 @@ rule "EVENT.MANAGER.PROCESS.POLICY.FAILURE"
$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);
@@ -883,7 +884,7 @@ rule "EVENT.MANAGER.DISCARD.OUTCOME"
$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);
@@ -931,7 +932,7 @@ rule "EVENT.MANAGER.ABORT"
$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);
@@ -990,7 +991,7 @@ rule "EVENT.MANAGER.FINAL"
!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);
@@ -1003,7 +1004,7 @@ rule "EVENT.MANAGER.FINAL"
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) {
@@ -1054,7 +1055,7 @@ rule "EVENT.CLEANUP"
$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);
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java
index 5077f8fb8..625a1a0f1 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +21,11 @@
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;
@@ -39,17 +40,16 @@ import org.onap.policy.simulators.Util;
* <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);
@@ -64,7 +64,7 @@ public class UsecasesTest extends DroolsRuleTest {
/**
* Cleans up statics.
*/
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
finishStatics();
}
@@ -72,7 +72,7 @@ public class UsecasesTest extends DroolsRuleTest {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
init();
}
@@ -80,7 +80,7 @@ public class UsecasesTest extends DroolsRuleTest {
/**
* Tears down.
*/
- @After
+ @AfterEach
public void tearDown() {
finish();
}
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java
index efb7e74d3..d4dbbe271 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,20 +24,18 @@ package org.onap.policy.drools.apps.controller.usecases;
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;
@@ -44,8 +43,7 @@ import org.onap.policy.controlloop.actorserviceprovider.TargetType;
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";
@@ -54,10 +52,8 @@ public class GetTargetEntityOperation2Test {
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;
@@ -66,7 +62,7 @@ public class GetTargetEntityOperation2Test {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
event = new VirtualControlLoopEvent();
event.setTarget("pnf.pnf-name");
@@ -83,7 +79,7 @@ public class GetTargetEntityOperation2Test {
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// already have the data - no properties needed
assertThat(oper.getPropertyNames()).isEmpty();
@@ -97,7 +93,7 @@ public class GetTargetEntityOperation2Test {
}
@Test
- public void testStart() {
+ void testStart() {
assertThatThrownBy(() -> oper.start()).isInstanceOf(UnsupportedOperationException.class)
.hasMessage("cannot start get-target-entity operation");
}
@@ -106,7 +102,7 @@ public class GetTargetEntityOperation2Test {
* Tests detmTarget() when the target has already been determined.
*/
@Test
- public void testDetmTargetRepeat() {
+ void testDetmTargetRepeat() {
remakeWithoutData();
assertFalse(oper.getPropertyNames().isEmpty());
@@ -122,7 +118,7 @@ public class GetTargetEntityOperation2Test {
* Tests detmTarget() when the target type is {@code null}.
*/
@Test
- public void testDetmTargetNullType() {
+ void testDetmTargetNullType() {
remakeWithoutData();
when(params.getTargetType()).thenReturn(null);
@@ -134,7 +130,7 @@ public class GetTargetEntityOperation2Test {
* 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();
@@ -145,7 +141,7 @@ public class GetTargetEntityOperation2Test {
* 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();
@@ -157,7 +153,7 @@ public class GetTargetEntityOperation2Test {
* provided.
*/
@Test
- public void testDetmTargetVfModule() {
+ void testDetmTargetVfModule() {
when(params.getTargetType()).thenReturn(TargetType.VFMODULE);
enrichTarget(VSERVER_NAME);
assertThat(oper.getPropertyNames()).isEmpty();
@@ -168,7 +164,7 @@ public class GetTargetEntityOperation2Test {
* 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())
@@ -176,7 +172,7 @@ public class GetTargetEntityOperation2Test {
}
@Test
- public void testDetmPnfTargetPnf() {
+ void testDetmPnfTargetPnf() {
assertThat(oper.getPropertyNames()).isEmpty();
verifyTarget(MY_PNF);
}
@@ -185,7 +181,7 @@ public class GetTargetEntityOperation2Test {
* 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");
@@ -195,7 +191,7 @@ public class GetTargetEntityOperation2Test {
* 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");
@@ -205,7 +201,7 @@ public class GetTargetEntityOperation2Test {
* 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");
@@ -215,7 +211,7 @@ public class GetTargetEntityOperation2Test {
* 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();
@@ -226,7 +222,7 @@ public class GetTargetEntityOperation2Test {
* 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();
@@ -238,7 +234,7 @@ public class GetTargetEntityOperation2Test {
* 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);
@@ -253,7 +249,7 @@ public class GetTargetEntityOperation2Test {
* 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");
@@ -265,7 +261,7 @@ public class GetTargetEntityOperation2Test {
* 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())
@@ -276,7 +272,7 @@ public class GetTargetEntityOperation2Test {
* 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));
@@ -288,14 +284,14 @@ public class GetTargetEntityOperation2Test {
* 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
@@ -308,7 +304,7 @@ public class GetTargetEntityOperation2Test {
}
@Test
- public void testGetActorName_testGetName() {
+ void testGetActorName_testGetName() {
assertEquals(MY_ACTOR, oper.getActorName());
assertEquals(MY_OPERATION, oper.getName());
}
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java
index 3208d4c53..f0348ac9a 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,20 +23,18 @@ package org.onap.policy.drools.apps.controller.usecases;
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;
@@ -43,17 +42,14 @@ 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 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;
@@ -63,7 +59,7 @@ public class LockOperation2Test {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
event = new VirtualControlLoopEvent();
event.setTarget("pnf.pnf-name");
@@ -83,12 +79,12 @@ public class LockOperation2Test {
}
@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");
@@ -98,7 +94,7 @@ public class LockOperation2Test {
}
@Test
- public void testSetProperty() {
+ void testSetProperty() {
oper.setProperty("unknown-property", "some data");
assertNull(oper.getTargetEntity());
@@ -107,7 +103,7 @@ public class LockOperation2Test {
}
@Test
- public void testGetActorName_testGetName() {
+ void testGetActorName_testGetName() {
assertEquals(MY_ACTOR, oper.getActorName());
assertEquals(MY_OPERATION, oper.getName());
}
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java
index 07d168a05..3b6463819 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java
@@ -3,6 +3,7 @@
* 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.
@@ -23,19 +24,19 @@ package org.onap.policy.drools.apps.controller.usecases;
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;
@@ -43,18 +44,14 @@ import java.util.UUID;
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;
@@ -85,8 +82,7 @@ import org.onap.policy.sdnr.PciBody;
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";
@@ -100,28 +96,17 @@ public class UsecasesEventManagerTest {
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;
@@ -132,7 +117,7 @@ public class UsecasesEventManagerTest {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() throws ControlLoopException, CoderException {
when(services.getDataManager()).thenReturn(dataMgr);
@@ -160,11 +145,11 @@ public class UsecasesEventManagerTest {
}
@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))
@@ -211,7 +196,7 @@ public class UsecasesEventManagerTest {
}
@Test
- public void testLoadPreprocessorSteps() {
+ void testLoadPreprocessorSteps() {
stepa = new Step2(mgr, ControlLoopOperationParams.builder().build(), event) {
@Override
public List<String> getPropertyNames() {
@@ -229,7 +214,7 @@ public class UsecasesEventManagerTest {
mgr.loadPreprocessorSteps();
- Deque<Step2> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
Step2 lockStep = steps.poll();
assertNotNull(lockStep);
@@ -245,11 +230,11 @@ public class UsecasesEventManagerTest {
* 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);
@@ -265,13 +250,13 @@ public class UsecasesEventManagerTest {
* 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());
@@ -283,14 +268,14 @@ public class UsecasesEventManagerTest {
* 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());
@@ -302,7 +287,7 @@ public class UsecasesEventManagerTest {
* 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);
@@ -310,7 +295,7 @@ public class UsecasesEventManagerTest {
setTargetEntity();
mgr.loadPreprocessorSteps();
- Deque<Step2> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
assertThat(steps.poll()).isInstanceOf(AaiGetTenantStep2.class);
assertSame(stepa, steps.poll());
@@ -322,7 +307,7 @@ public class UsecasesEventManagerTest {
* 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) {
@@ -342,7 +327,7 @@ public class UsecasesEventManagerTest {
}
};
- Deque<Step2> steps = mgr.getSteps();
+ var steps = mgr.getSteps();
steps.add(stepa);
steps.add(stepb);
@@ -363,8 +348,8 @@ public class UsecasesEventManagerTest {
}
@Test
- public void testIsAbort() {
- OperationOutcome outcome = makeCompletedOutcome();
+ void testIsAbort() {
+ var outcome = makeCompletedOutcome();
outcome.setResult(OperationResult.FAILURE);
// closed loop timeout
@@ -381,9 +366,9 @@ public class UsecasesEventManagerTest {
}
@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());
@@ -393,8 +378,8 @@ public class UsecasesEventManagerTest {
}
@Test
- public void testMakeControlLoopResponse() {
- final OperationOutcome outcome = new OperationOutcome();
+ void testMakeControlLoopResponse() {
+ final var outcome = new OperationOutcome();
// no message - should return null
checkResp(outcome, null);
@@ -406,13 +391,13 @@ public class UsecasesEventManagerTest {
/*
* 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");
@@ -437,7 +422,7 @@ public class UsecasesEventManagerTest {
}
@Test
- public void testCheckEventSyntax() {
+ void testCheckEventSyntax() {
/*
* only need to check one success and one failure from the super class method
*/
@@ -459,7 +444,7 @@ public class UsecasesEventManagerTest {
}
@Test
- public void testValidateStatus() {
+ void testValidateStatus() {
/*
* only need to check one success and one failure from the super class method
*/
@@ -472,7 +457,7 @@ public class UsecasesEventManagerTest {
}
@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");
@@ -511,7 +496,7 @@ public class UsecasesEventManagerTest {
}
@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();
@@ -528,7 +513,7 @@ public class UsecasesEventManagerTest {
}
@Test
- public void testValidateAaiPnfData() {
+ void testValidateAaiPnfData() {
event.setTargetType(ControlLoopTargetType.PNF);
event.setAai(Map.of(UsecasesConstants.PNF_NAME, MY_TARGET));
assertThatCode(() -> mgr.checkEventSyntax(event)).doesNotThrowAnyException();
@@ -539,8 +524,8 @@ public class UsecasesEventManagerTest {
}
@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))
@@ -556,8 +541,8 @@ public class UsecasesEventManagerTest {
}
@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();
@@ -575,10 +560,10 @@ public class UsecasesEventManagerTest {
}
@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);
@@ -600,8 +585,7 @@ public class UsecasesEventManagerTest {
}
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);
@@ -631,14 +615,14 @@ public class UsecasesEventManagerTest {
}
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);
@@ -650,7 +634,7 @@ public class UsecasesEventManagerTest {
}
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());
@@ -680,7 +664,7 @@ public class UsecasesEventManagerTest {
@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);
}
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiCqStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiCqStep2Test.java
index 3c629591d..1f2d771cb 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiCqStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiCqStep2Test.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,22 +21,20 @@
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;
@@ -48,24 +47,16 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
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;
@@ -74,7 +65,7 @@ public class AaiCqStep2Test {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
future = new CompletableFuture<>();
@@ -92,7 +83,7 @@ public class AaiCqStep2Test {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiActor.NAME, step.getActorName());
assertEquals(AaiCustomQueryOperation.NAME, step.getOperationName());
assertSame(stepContext, step.stepContext);
@@ -100,7 +91,7 @@ public class AaiCqStep2Test {
}
@Test
- public void testStart() {
+ void testStart() {
step.init();
assertTrue(step.start(100));
verify(policyOperation).start();
@@ -110,7 +101,7 @@ public class AaiCqStep2Test {
* 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();
@@ -119,9 +110,9 @@ public class AaiCqStep2Test {
}
@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);
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetPnfStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetPnfStep2Test.java
index 897650fb3..8f2559933 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetPnfStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetPnfStep2Test.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,22 +21,20 @@
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;
@@ -49,25 +48,17 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
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;
@@ -76,7 +67,7 @@ public class AaiGetPnfStep2Test {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
future = new CompletableFuture<>();
@@ -95,7 +86,7 @@ public class AaiGetPnfStep2Test {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiActor.NAME, step.getActorName());
assertEquals(AaiGetPnfOperation.NAME, step.getOperationName());
assertSame(stepContext, step.stepContext);
@@ -103,7 +94,7 @@ public class AaiGetPnfStep2Test {
}
@Test
- public void testStart() {
+ void testStart() {
step.init();
assertTrue(step.start(100));
verify(policyOperation).start();
@@ -113,7 +104,7 @@ public class AaiGetPnfStep2Test {
* 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();
@@ -122,9 +113,9 @@ public class AaiGetPnfStep2Test {
}
@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);
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetTenantStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetTenantStep2Test.java
index bccfbb3be..9d95b0b68 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetTenantStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/AaiGetTenantStep2Test.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +23,12 @@ package org.onap.policy.drools.apps.controller.usecases.step;
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;
@@ -34,11 +36,8 @@ 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;
@@ -52,25 +51,17 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
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;
@@ -79,7 +70,7 @@ public class AaiGetTenantStep2Test {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
future = new CompletableFuture<>();
@@ -99,7 +90,7 @@ public class AaiGetTenantStep2Test {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(AaiActor.NAME, step.getActorName());
assertEquals(AaiGetTenantOperation.NAME, step.getOperationName());
assertSame(stepContext, step.stepContext);
@@ -117,12 +108,12 @@ public class AaiGetTenantStep2Test {
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(step.getPropertyNames()).isEmpty();
}
@Test
- public void testSetProperties() {
+ void testSetProperties() {
step.init();
step.setProperties();
@@ -131,7 +122,7 @@ public class AaiGetTenantStep2Test {
}
@Test
- public void testStart() {
+ void testStart() {
step.init();
assertTrue(step.start(100));
verify(policyOperation).start();
@@ -141,7 +132,7 @@ public class AaiGetTenantStep2Test {
* 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();
@@ -150,9 +141,9 @@ public class AaiGetTenantStep2Test {
}
@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);
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GetTargetEntityStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GetTargetEntityStep2Test.java
index ff9a38a81..a975e0bb3 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GetTargetEntityStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GetTargetEntityStep2Test.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,32 +22,25 @@
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;
@@ -54,7 +48,7 @@ public class GetTargetEntityStep2Test {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder());
@@ -63,7 +57,7 @@ public class GetTargetEntityStep2Test {
}
@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);
@@ -71,13 +65,13 @@ public class GetTargetEntityStep2Test {
}
@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");
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GuardStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GuardStep2Test.java
index ffd88d54d..4d158def3 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GuardStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/GuardStep2Test.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,20 +23,18 @@ package org.onap.policy.drools.apps.controller.usecases.step;
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;
@@ -55,8 +54,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
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";
@@ -72,22 +70,16 @@ public class GuardStep2Test {
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;
@@ -96,7 +88,7 @@ public class GuardStep2Test {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
aai.put("vserver.vserver-name", MY_SERVERNAME);
when(event.getAai()).thenReturn(aai);
@@ -105,19 +97,19 @@ public class GuardStep2Test {
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);
@@ -135,7 +127,7 @@ public class GuardStep2Test {
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);
@@ -181,7 +173,7 @@ public class GuardStep2Test {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(XacmlActor.NAME, step.getActorName());
assertEquals(GuardOperation.NAME, step.getOperationName());
assertSame(stepContext, step.stepContext);
@@ -191,7 +183,7 @@ public class GuardStep2Test {
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(
@@ -203,13 +195,13 @@ public class GuardStep2Test {
}
@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())
@@ -225,13 +217,13 @@ public class GuardStep2Test {
}
@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)
@@ -242,7 +234,7 @@ public class GuardStep2Test {
}
@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);
}
@@ -251,7 +243,7 @@ public class GuardStep2Test {
* 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);
@@ -261,7 +253,7 @@ public class GuardStep2Test {
* 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
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/LockStep2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/LockStep2Test.java
index fd7efe7bf..29401081e 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/LockStep2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/LockStep2Test.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,20 +21,18 @@
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;
@@ -42,18 +41,13 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp
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;
@@ -63,7 +57,7 @@ public class LockStep2Test {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
future = new CompletableFuture<>();
@@ -86,7 +80,7 @@ public class LockStep2Test {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertEquals(ActorConstants.LOCK_ACTOR, step.getActorName());
assertEquals(ActorConstants.LOCK_OPERATION, step.getOperationName());
assertSame(stepContext, step.stepContext);
@@ -94,20 +88,20 @@ public class LockStep2Test {
}
@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);
@@ -120,7 +114,7 @@ public class LockStep2Test {
* Tests start when the operation throws an exception.
*/
@Test
- public void testStartNoFuture() {
+ void testStartNoFuture() {
// start the operation
step.init();
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java
index d80484a2e..7a557c2af 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,10 +24,10 @@ package org.onap.policy.drools.apps.controller.usecases.step;
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;
@@ -43,11 +44,8 @@ import java.util.UUID;
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;
@@ -70,8 +68,7 @@ import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
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";
@@ -81,18 +78,12 @@ public class Step2Test {
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;
@@ -104,7 +95,7 @@ public class Step2Test {
/**
* Sets up.
*/
- @Before
+ @BeforeEach
public void setUp() {
// configure policy operation
when(actors.getActor(POLICY_ACTOR)).thenReturn(policyActor);
@@ -136,14 +127,14 @@ public class Step2Test {
}
@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);
@@ -154,7 +145,7 @@ public class Step2Test {
}
@Test
- public void testAcceptsEvent() {
+ void testAcceptsEvent() {
// it's a policy step, thus it accepts events
assertTrue(step.acceptsEvent());
@@ -165,12 +156,12 @@ public class Step2Test {
}
@Test
- public void testSuccess() {
+ void testSuccess() {
assertThatCode(() -> step.success(null)).doesNotThrowAnyException();
}
@Test
- public void testGetPropertyNames() {
+ void testGetPropertyNames() {
// empty property list
assertThat(step.getPropertyNames()).isEmpty();
@@ -180,11 +171,11 @@ public class Step2Test {
}
@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(
@@ -202,7 +193,7 @@ public class Step2Test {
* 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())
@@ -210,8 +201,8 @@ public class Step2Test {
}
@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));
@@ -224,8 +215,8 @@ public class Step2Test {
}
@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));
@@ -238,8 +229,8 @@ public class Step2Test {
}
@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));
@@ -253,9 +244,9 @@ public class Step2Test {
}
@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));
@@ -280,8 +271,8 @@ public class Step2Test {
}
@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));
@@ -294,12 +285,12 @@ public class Step2Test {
}
@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));
@@ -320,8 +311,8 @@ public class Step2Test {
}
@Test
- public void testGetVserver() {
- Vserver vserver = new Vserver();
+ void testGetVserver() {
+ var vserver = new Vserver();
when(aaicq.getVserver()).thenReturn(vserver);
assertSame(vserver, step.getVServer());
@@ -332,7 +323,7 @@ public class Step2Test {
}
@Test
- public void testGetTargetEntity() {
+ void testGetTargetEntity() {
when(stepContext.getProperty(OperationProperties.AAI_TARGET_ENTITY)).thenReturn(MY_TARGET);
assertEquals(MY_TARGET, step.getTargetEntity());
@@ -343,9 +334,9 @@ public class Step2Test {
}
@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));
@@ -370,13 +361,13 @@ public class Step2Test {
}
@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));
@@ -393,10 +384,10 @@ public class Step2Test {
}
@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");
@@ -428,7 +419,7 @@ public class Step2Test {
}
@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");
@@ -468,7 +459,7 @@ public class Step2Test {
}
@Test
- public void testLoadEnrichment_testGetEnrichment() {
+ void testLoadEnrichment_testGetEnrichment() {
event.setAai(Map.of("bandwidth", "bandwidth-value"));
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.ENRICHMENT_BANDWIDTH));
@@ -481,7 +472,7 @@ public class Step2Test {
}
@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));
@@ -491,7 +482,7 @@ public class Step2Test {
}
@Test
- public void testLoadEventPayload_testGetEventPayload() {
+ void testLoadEventPayload_testGetEventPayload() {
event.setPayload("some-event-payload");
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.EVENT_PAYLOAD));
@@ -500,7 +491,7 @@ public class Step2Test {
}
@Test
- public void testLoadOptCdsGrpcAaiProperties() {
+ void testLoadOptCdsGrpcAaiProperties() {
when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES));
step.setProperties();
@@ -508,8 +499,8 @@ public class Step2Test {
}
@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));
@@ -522,7 +513,7 @@ public class Step2Test {
}
@Test
- public void testGetCustomQueryData() {
+ void testGetCustomQueryData() {
assertSame(aaicq, step.getCustomQueryData());
when(stepContext.getProperty(AaiCqResponse.CONTEXT_KEY)).thenReturn(null);
@@ -532,7 +523,7 @@ public class Step2Test {
}
@Test
- public void testVerifyNotNull() {
+ void testVerifyNotNull() {
assertThatCode(() -> step.verifyNotNull("verifyA", "verify-value-A")).doesNotThrowAnyException();
assertThatIllegalArgumentException().isThrownBy(() -> step.verifyNotNull("verifyB", null))
@@ -540,7 +531,7 @@ public class Step2Test {
}
@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));
@@ -555,5 +546,4 @@ public class Step2Test {
assertEquals("/and/more", Step2.stripPrefix("prefix/three/slashes/and/more", 3));
}
-
}