aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors')
-rw-r--r--models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java25
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java3
-rw-r--r--models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java17
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java51
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java90
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java17
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java29
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java12
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java258
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java7
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java4
12 files changed, 246 insertions, 271 deletions
diff --git a/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java b/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java
index 691674917..742c61de1 100644
--- a/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java
+++ b/models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,14 +29,11 @@ import static org.mockito.Mockito.verify;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import java.util.function.BiConsumer;
import org.onap.policy.common.message.bus.event.TopicSink;
import org.onap.policy.common.message.bus.event.TopicSource;
-import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.sdnr.PciBody;
import org.onap.policy.sdnr.PciMessage;
import org.onap.policy.sdnr.PciResponse;
@@ -59,7 +56,7 @@ public abstract class BasicA1pOperation extends BasicBidirectionalTopicOperation
/**
* Constructs the object.
*
- * @param actor actor name
+ * @param actor actor name
* @param operation operation name
*/
public BasicA1pOperation(String actor, String operation) {
@@ -101,7 +98,7 @@ public abstract class BasicA1pOperation extends BasicBidirectionalTopicOperation
* @param operation operation to run
*/
protected void verifyOperation(A1pOperation operation)
- throws InterruptedException, ExecutionException {
+ throws InterruptedException, ExecutionException {
CompletableFuture<OperationOutcome> future2 = operation.start();
executor.runAll(100);
@@ -117,20 +114,4 @@ public abstract class BasicA1pOperation extends BasicBidirectionalTopicOperation
assertEquals(OperationResult.SUCCESS, outcome.getResult());
}
- /**
- * Provides a response to the listener.
- *
- * @param listener listener to which to provide the response
- * @param code response code
- * @param description response description
- */
- protected void provideResponse(BiConsumer<String, StandardCoderObject> listener, int code, String description) {
- PciResponse response = new PciResponse();
-
- Status status = new Status();
- response.setStatus(status);
- status.setCode(code);
-
- provideResponse(listener, Util.translate("", response, String.class));
- }
}
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
index 7a101cb8d..8b81aad31 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,6 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java
index 6a893122f..862d8410a 100644
--- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java
+++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -122,7 +122,7 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio
assertFalse(future2.isDone());
verify(forwarder).register(any(), listenerCaptor.capture());
- provideResponse(listenerCaptor.getValue(), ResponseCode.SUCCESS.getValue(), MY_DESCRIPTION);
+ provideResponse(listenerCaptor.getValue(), ResponseCode.SUCCESS.getValue());
executor.runAll(100);
assertTrue(future2.isDone());
@@ -145,18 +145,17 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio
* Provides a response to the listener.
*
* @param listener listener to which to provide the response
- * @param code response code
- * @param description response description
+ * @param code response code
*/
- protected void provideResponse(BiConsumer<String, StandardCoderObject> listener, int code, String description) {
- Response response = new Response();
+ protected void provideResponse(BiConsumer<String, StandardCoderObject> listener, int code) {
+ Response response1 = new Response();
ResponseStatus status = new ResponseStatus();
- response.setStatus(status);
+ response1.setStatus(status);
status.setCode(code);
- status.setDescription(description);
+ status.setDescription(BasicAppcOperation.MY_DESCRIPTION);
- provideResponse(listener, Util.translate("", response, String.class));
+ provideResponse(listener, Util.translate("", response1, String.class));
}
@Override
diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
index 02feae122..3bf7c181f 100644
--- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
+++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,13 +65,12 @@ import org.onap.policy.simulators.AppcLcmTopicServer;
import org.onap.policy.simulators.TopicServer;
@ExtendWith(MockitoExtension.class)
- class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcLcmMessageWrapper> {
+class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcLcmMessageWrapper> {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String PAYLOAD_KEY1 = "key-A";
private static final String PAYLOAD_VALUE1 = "value-A";
private static final String MY_MESSAGE = "my-message";
- protected static final String MY_VNF = "my-vnf";
protected static final String RESOURCE_ID = "my-resource";
private static final int SUCCESS_CODE = 400;
@@ -79,12 +78,12 @@ import org.onap.policy.simulators.TopicServer;
private AppcLcmOperation oper;
@BeforeAll
- static void setUpBeforeClass() throws Exception {
+ static void setUpBeforeClass() throws Exception {
initBeforeClass(MY_SINK, MY_SOURCE);
}
@AfterAll
- static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
destroyAfterClass();
}
@@ -92,7 +91,7 @@ import org.onap.policy.simulators.TopicServer;
* Sets up.
*/
@BeforeEach
- void setUp() {
+ void setUp() {
super.setUpBasic();
response = makeResponse();
@@ -102,7 +101,7 @@ import org.onap.policy.simulators.TopicServer;
}
@AfterEach
- void tearDown() {
+ void tearDown() {
super.tearDownBasic();
}
@@ -115,9 +114,9 @@ import org.onap.policy.simulators.TopicServer;
* Tests "success" case with simulator.
*/
@Test
- void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
BidirectionalTopicParams opParams =
- BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE).build();
+ BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE).build();
config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcLcmOperation.SELECTOR_KEYS);
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
@@ -130,18 +129,18 @@ import org.onap.policy.simulators.TopicServer;
}
@Test
- void testConstructor() {
+ void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
}
@Test
- void testGetPropertyNames() {
+ void testGetPropertyNames() {
assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_TARGET_ENTITY));
}
@Test
- void testMakeRequest() {
+ void testMakeRequest() {
oper.generateSubRequestId(2);
String subreq = oper.getSubRequestId();
assertNotNull(subreq);
@@ -165,16 +164,16 @@ import org.onap.policy.simulators.TopicServer;
* Tests makeRequest() when a property is missing.
*/
@Test
- void testMakeRequestMissingProperty() {
+ void testMakeRequestMissingProperty() {
oper = new AppcLcmOperation(params, config);
oper.generateSubRequestId(1);
assertThatIllegalStateException().isThrownBy(() -> oper.makeRequest(1))
- .withMessageContaining("missing target entity");
+ .withMessageContaining("missing target entity");
}
@Test
- void testConvertPayload() {
+ void testConvertPayload() {
// only builds a payload for ConfigModify
params = params.toBuilder().operation(AppcLcmConstants.OPERATION_CONFIG_MODIFY).build();
oper = new AppcLcmOperation(params, config);
@@ -201,19 +200,19 @@ import org.onap.policy.simulators.TopicServer;
oper.generateSubRequestId(2);
assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest(2))
- .withMessageContaining("Cannot convert payload");
+ .withMessageContaining("Cannot convert payload");
}
@Test
- void testGetExpectedKeyValues() {
+ void testGetExpectedKeyValues() {
oper.generateSubRequestId(2);
AppcLcmMessageWrapper request = oper.makeRequest(2);
assertEquals(List.of(request.getBody().getInput().getCommonHeader().getSubRequestId()),
- oper.getExpectedKeyValues(50, request));
+ oper.getExpectedKeyValues(50, request));
}
@Test
- void testDetmStatus() {
+ void testDetmStatus() {
assertEquals(Status.SUCCESS, oper.detmStatus(null, response));
// failure
@@ -242,7 +241,7 @@ import org.onap.policy.simulators.TopicServer;
}
@Test
- void testSetOutcome() {
+ void testSetOutcome() {
oper.setOutcome(outcome, OperationResult.SUCCESS, response);
assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertEquals(MY_MESSAGE, outcome.getMessage());
@@ -268,7 +267,7 @@ import org.onap.policy.simulators.TopicServer;
}
@Test
- void testGetStatus() {
+ void testGetStatus() {
assertNotNull(oper.getStatus(response));
// null status
@@ -288,7 +287,7 @@ import org.onap.policy.simulators.TopicServer;
}
@Test
- void testOperationSupportsPayload() {
+ void testOperationSupportsPayload() {
// these should support a payload
Set<String> supported = Set.of(AppcLcmConstants.OPERATION_CONFIG_MODIFY);
@@ -300,7 +299,7 @@ import org.onap.policy.simulators.TopicServer;
// these should NOT support a payload
Set<String> unsupported = AppcLcmConstants.OPERATION_NAMES.stream().filter(name -> !supported.contains(name))
- .collect(Collectors.toSet());
+ .collect(Collectors.toSet());
for (String name : unsupported) {
params = params.toBuilder().operation(name).build();
@@ -343,10 +342,10 @@ import org.onap.policy.simulators.TopicServer;
}
private AppcLcmMessageWrapper makeResponse() {
- AppcLcmMessageWrapper response = new AppcLcmMessageWrapper();
+ AppcLcmMessageWrapper wrapper = new AppcLcmMessageWrapper();
AppcLcmBody body = new AppcLcmBody();
- response.setBody(body);
+ wrapper.setBody(body);
AppcLcmOutput output = new AppcLcmOutput();
body.setOutput(output);
@@ -356,6 +355,6 @@ import org.onap.policy.simulators.TopicServer;
status.setMessage(MY_MESSAGE);
status.setCode(SUCCESS_CODE);
- return response;
+ return wrapper;
}
}
diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
index c5a20d9f2..8d99aaf12 100644
--- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
+++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ import org.onap.policy.simulators.CdsSimulator;
import org.onap.policy.simulators.Util;
@ExtendWith(MockitoExtension.class)
- class GrpcOperationTest {
+class GrpcOperationTest {
private static final String MY_VNF = "my-vnf";
private static final String MY_SVC_ID = "my-service-instance-id";
private static final String RESOURCE_ID = "my-resource-id";
@@ -88,12 +88,12 @@ import org.onap.policy.simulators.Util;
private GrpcOperation operation;
@BeforeAll
- static void setUpBeforeClass() throws Exception {
+ static void setUpBeforeClass() throws Exception {
sim = Util.buildCdsSim();
}
@AfterAll
- static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
sim.stop();
}
@@ -101,7 +101,7 @@ import org.onap.policy.simulators.Util;
* Sets up the fields.
*/
@BeforeEach
- void setUp() {
+ void setUp() {
// Setup the CDS properties
cdsProps = new CdsServerProperties();
cdsProps.setHost("10.10.10.10");
@@ -117,29 +117,29 @@ import org.onap.policy.simulators.Util;
targetEntityIds.put(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID, RESOURCE_ID);
params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation(GrpcOperation.NAME)
- .requestId(REQUEST_ID).actorService(new ActorService())
- .build();
+ .requestId(REQUEST_ID).actorService(new ActorService())
+ .build();
}
/**
* Tests "success" case with simulator.
*/
@Test
- void testSuccess() throws Exception {
+ void testSuccess() throws Exception {
Map<String, Object> payload = Map.of("artifact_name", "my_artifact", "artifact_version", "1.0");
params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation("subscribe")
- .requestId(REQUEST_ID).actorService(new ActorService())
- .retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload)
- .build();
+ .requestId(REQUEST_ID).actorService(new ActorService())
+ .retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload)
+ .build();
cdsProps.setHost("localhost");
cdsProps.setPort(sim.getPort());
cdsProps.setTimeout(3);
- GrpcConfig config = new GrpcConfig(blockingExecutor, cdsProps);
+ GrpcConfig grpcConfig = new GrpcConfig(blockingExecutor, cdsProps);
- operation = new GrpcOperation(params, config);
+ operation = new GrpcOperation(params, grpcConfig);
// set the properties
operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES, Collections.emptyMap());
@@ -150,7 +150,7 @@ import org.onap.policy.simulators.Util;
}
@Test
- void testGetPropertyNames() {
+ void testGetPropertyNames() {
/*
* check VNF case with target entities
*/
@@ -196,50 +196,50 @@ import org.onap.policy.simulators.Util;
}
@Test
- void testGetServiceInstanceId() {
+ void testGetServiceInstanceId() {
params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
operation = new GrpcOperation(params, config);
loadVnfData();
assertEquals(MY_SVC_ID,
operation.getOpProperties()
- .convertToAaiProperties(operation)
- .get(GrpcOperationProperties.AAI_SERVICE_INSTANCE_ID_KEY));
+ .convertToAaiProperties(operation)
+ .get(GrpcOperationProperties.AAI_SERVICE_INSTANCE_ID_KEY));
}
@Test
- void testGetVnfId() {
+ void testGetVnfId() {
params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
operation = new GrpcOperation(params, config);
loadVnfData();
assertEquals(MY_VNF,
operation.getOpProperties()
- .convertToAaiProperties(operation)
- .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
+ .convertToAaiProperties(operation)
+ .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
params = params.toBuilder().targetEntityIds(null).build();
operation = new GrpcOperation(params, config);
assertThatIllegalStateException().isThrownBy(()
-> operation.getOpProperties()
- .convertToAaiProperties(operation)
- .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
+ .convertToAaiProperties(operation)
+ .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_VNF);
assertEquals(MY_VNF,
- operation.getOpProperties()
- .convertToAaiProperties(operation)
- .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
+ operation.getOpProperties()
+ .convertToAaiProperties(operation)
+ .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, null);
}
@Test
- void testStartOperationAsync() {
+ void testStartOperationAsync() {
ControlLoopOperationParams clop =
- ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
- .operation(GrpcOperation.NAME)
- .requestId(REQUEST_ID)
- .actorService(new ActorService())
- .targetType(TargetType.VNF)
- .build();
+ ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
+ .operation(GrpcOperation.NAME)
+ .requestId(REQUEST_ID)
+ .actorService(new ActorService())
+ .targetType(TargetType.VNF)
+ .build();
verifyOperation(clop, () -> operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_VNF));
verifyOperation(clop.toBuilder().targetEntityIds(targetEntityIds).build(), this::loadVnfData);
@@ -249,33 +249,33 @@ import org.onap.policy.simulators.Util;
* Tests startOperationAsync() when the target type is PNF.
*/
@Test
- void testStartOperationAsyncPnf() {
+ void testStartOperationAsyncPnf() {
ControlLoopOperationParams clop =
- ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
- .operation(GrpcOperation.NAME)
- .requestId(REQUEST_ID)
- .actorService(new ActorService())
- .targetType(TargetType.PNF)
- .build();
+ ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
+ .operation(GrpcOperation.NAME)
+ .requestId(REQUEST_ID)
+ .actorService(new ActorService())
+ .targetType(TargetType.PNF)
+ .build();
verifyOperation(clop, this::loadPnfData);
}
@Test
- void testStartOperationAsyncError() {
+ void testStartOperationAsyncError() {
operation = new GrpcOperation(params, config);
assertThatIllegalArgumentException()
- .isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome()));
+ .isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome()));
}
private void verifyOperation(ControlLoopOperationParams clop, Runnable loader) {
Map<String, Object> payloadMap = Map.of(CdsActorConstants.KEY_CBA_NAME, CDS_BLUEPRINT_NAME,
- CdsActorConstants.KEY_CBA_VERSION, CDS_BLUEPRINT_VERSION, "data",
- "{\"mapInfo\":{\"key\":\"val\"},\"arrayInfo\":[\"one\",\"two\"],\"paramInfo\":\"val\"}");
+ CdsActorConstants.KEY_CBA_VERSION, CDS_BLUEPRINT_VERSION, "data",
+ "{\"mapInfo\":{\"key\":\"val\"},\"arrayInfo\":[\"one\",\"two\"],\"paramInfo\":\"val\"}");
params = clop.toBuilder().payload(payloadMap).build();
- GrpcConfig config = new GrpcConfig(executor, cdsProps);
- operation = new GrpcOperation(params, config);
+ GrpcConfig grpcConfig = new GrpcConfig(executor, cdsProps);
+ operation = new GrpcOperation(params, grpcConfig);
assertEquals(1000, operation.getTimeoutMs(null));
assertEquals(1000, operation.getTimeoutMs(0));
assertEquals(2000, operation.getTimeoutMs(2));
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
index e59c2fd89..c4418cff9 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,6 @@ import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ObjectValidationResult;
@@ -244,7 +243,7 @@ class ActorServiceTest {
service.getActors().stream()
.map(Actor::getName)
.sorted()
- .collect(Collectors.toList())
+ .toList()
.toString());
// @formatter:on
}
@@ -255,7 +254,7 @@ class ActorServiceTest {
assertEquals("[actor A, actor B, actor C, actor D]",
service.getActorNames().stream()
.sorted()
- .collect(Collectors.toList())
+ .toList()
.toString());
// @formatter:on
}
@@ -344,7 +343,7 @@ class ActorServiceTest {
/**
* Arranges for an actor to throw a validation exception when
- * {@link Actor#configure(Map)} is invoked.
+ * {@link Actor#configure(Object)} is invoked.
*
* @param actor actor of interest
*/
@@ -356,7 +355,7 @@ class ActorServiceTest {
/**
* Arranges for an actor to throw a runtime exception when
- * {@link Actor#configure(Map)} is invoked.
+ * {@link Actor#configure(Object)} is invoked.
*
* @param actor actor of interest
*/
@@ -367,9 +366,9 @@ class ActorServiceTest {
@Test
void testLoadActors() {
- ActorService service = new ActorService();
- assertFalse(service.getActors().isEmpty());
- assertNotNull(service.getActor(DummyActor.class.getSimpleName()));
+ ActorService actorService = new ActorService();
+ assertFalse(actorService.getActors().isEmpty());
+ assertNotNull(actorService.getActor(DummyActor.class.getSimpleName()));
}
/**
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java
index 068a72365..ce72630d5 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@ class UtilTest {
void testRunFunction() {
// no exception, no log
AtomicInteger count = new AtomicInteger();
- Util.runFunction(() -> count.incrementAndGet(), "no error");
+ Util.runFunction(count::incrementAndGet, "no error");
assertEquals(1, count.get());
assertEquals(0, appender.getExtracted().size());
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java
index 1635c16ce..0a37bf6f1 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@ import static org.mockito.Mockito.when;
import java.util.Iterator;
import java.util.Map;
-import java.util.stream.Collectors;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.policy.common.parameters.ObjectValidationResult;
@@ -74,7 +73,7 @@ class ActorImplTest {
* Initializes the fields, including a fully populated {@link #actor}.
*/
@BeforeEach
- void setUp() {
+ void setUp() {
oper1 = spy(new MyOper(OPER1));
oper2 = spy(new MyOper(OPER2));
oper3 = spy(new MyOper(OPER3));
@@ -91,14 +90,14 @@ class ActorImplTest {
}
@Test
- void testActorImpl_testGetName() {
+ void testActorImpl_testGetName() {
assertEquals(ACTOR_NAME, actor.getName());
assertEquals(4, actor.getOperationNames().size());
assertEquals(0, actor.getSequenceNumber());
}
@Test
- void testDoStart() {
+ void testDoStart() {
actor.configure(params);
assertEquals(4, actor.getOperationNames().size());
@@ -131,7 +130,7 @@ class ActorImplTest {
}
@Test
- void testDoStop() {
+ void testDoStop() {
actor.configure(params);
actor.start();
assertEquals(4, actor.getOperationNames().size());
@@ -163,7 +162,7 @@ class ActorImplTest {
}
@Test
- void testDoShutdown() {
+ void testDoShutdown() {
actor.configure(params);
actor.start();
assertEquals(4, actor.getOperationNames().size());
@@ -230,7 +229,7 @@ class ActorImplTest {
actor.getOperators().stream()
.map(Operator::getName)
.sorted()
- .collect(Collectors.toList())
+ .toList()
.toString());
// @formatter:on
}
@@ -241,7 +240,7 @@ class ActorImplTest {
assertEquals("[add, divide, multiply, subtract]",
actor.getOperationNames().stream()
.sorted()
- .collect(Collectors.toList())
+ .toList()
.toString());
// @formatter:on
}
@@ -328,19 +327,19 @@ class ActorImplTest {
/**
* Arranges for an operator to throw a validation exception when
- * {@link Operator#configure(Map)} is invoked.
+ * {@link Operator#configure(Object)} is invoked.
*
* @param oper operator of interest
*/
private void makeValidException(Operator oper) {
ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(
- new ObjectValidationResult(actor.getName(), null, ValidationStatus.INVALID, "null"));
+ new ObjectValidationResult(actor.getName(), null, ValidationStatus.INVALID, "null"));
doThrow(ex).when(oper).configure(any());
}
/**
* Arranges for an operator to throw a runtime exception when
- * {@link Operator#configure(Map)} is invoked.
+ * {@link Operator#configure(Object)} is invoked.
*
* @param oper operator of interest
*/
@@ -367,13 +366,13 @@ class ActorImplTest {
* @return a new actor
*/
private ActorImpl makeActor(Operator... operators) {
- ActorImpl actor = new ActorImpl(ACTOR_NAME);
+ ActorImpl actorImpl = new ActorImpl(ACTOR_NAME);
for (Operator oper : operators) {
- actor.addOperator(oper);
+ actorImpl.addOperator(oper);
}
- return actor;
+ return actorImpl;
}
private static class MyOper extends OperatorPartial {
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
index 38e8a29bb..d1f42d6b3 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@ 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 java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
@@ -66,7 +65,6 @@ class BidirectionalTopicOperatorTest {
@Mock
private BidirectionalTopicOperation<String, Integer> operation;
- private List<SelectorKey> keys;
private BidirectionalTopicParams params;
private MyOperator oper;
@@ -75,7 +73,7 @@ class BidirectionalTopicOperatorTest {
*/
@BeforeEach
void setUp() {
- keys = List.of(new SelectorKey(""));
+ List<SelectorKey> keys = List.of(new SelectorKey(""));
Mockito.lenient().when(mgr.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(handler);
Mockito.lenient().when(handler.addForwarder(keys)).thenReturn(forwarder);
@@ -113,8 +111,8 @@ class BidirectionalTopicOperatorTest {
// @formatter:off
OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation<?, ?>> maker =
- (params, config) -> {
- paramsRef.set(params);
+ (operationParams, config) -> {
+ paramsRef.set(operationParams);
configRef.set(config);
return operation;
};
@@ -144,7 +142,7 @@ class BidirectionalTopicOperatorTest {
// with no operation-maker
BidirectionalTopicOperator oper3 =
- new BidirectionalTopicOperator(ACTOR, OPERATION, mgr, Arrays.asList(new SelectorKey("")));
+ new BidirectionalTopicOperator(ACTOR, OPERATION, mgr, List.of(new SelectorKey("")));
assertThatThrownBy(() -> oper3.buildOperation(params2)).isInstanceOf(UnsupportedOperationException.class);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
index 04300c4d9..99e31f24f 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation.
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -118,7 +118,7 @@ class OperationPartialTest {
private PseudoExecutor executor;
private ControlLoopOperationParams params;
- private MyOper oper;
+ private MyOper myOperation;
private int numStart;
private int numEnd;
@@ -156,7 +156,7 @@ class OperationPartialTest {
}
/**
- * Initializes the fields, including {@link #oper}.
+ * Initializes the fields, including {@link #myOperation}.
*/
@BeforeEach
void setUp() {
@@ -168,7 +168,7 @@ class OperationPartialTest {
config = new OperatorConfig(executor);
- oper = new MyOper();
+ myOperation = new MyOper();
tstart = null;
@@ -181,9 +181,9 @@ class OperationPartialTest {
@Test
void testOperatorPartial_testGetActorName_testGetName() {
- assertEquals(ACTOR, oper.getActorName());
- assertEquals(OPERATION, oper.getName());
- assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
+ assertEquals(ACTOR, myOperation.getActorName());
+ assertEquals(OPERATION, myOperation.getName());
+ assertEquals(ACTOR + "." + OPERATION, myOperation.getFullName());
}
@Test
@@ -205,24 +205,24 @@ class OperationPartialTest {
@Test
void testGetPropertyNames() {
- assertThat(oper.getPropertyNames()).isEqualTo(PROP_NAMES);
+ assertThat(myOperation.getPropertyNames()).isEqualTo(PROP_NAMES);
}
@Test
void testGetProperty_testSetProperty_testGetRequiredProperty() {
- oper.setProperty("propertyA", "valueA");
- oper.setProperty("propertyB", "valueB");
- oper.setProperty("propertyC", 20);
- oper.setProperty("propertyD", "valueD");
+ myOperation.setProperty("propertyA", "valueA");
+ myOperation.setProperty("propertyB", "valueB");
+ myOperation.setProperty("propertyC", 20);
+ myOperation.setProperty("propertyD", "valueD");
- assertEquals("valueA", oper.getProperty("propertyA"));
- assertEquals("valueB", oper.getProperty("propertyB"));
- assertEquals(Integer.valueOf(20), oper.getProperty("propertyC"));
+ assertEquals("valueA", myOperation.getProperty("propertyA"));
+ assertEquals("valueB", myOperation.getProperty("propertyB"));
+ assertEquals(Integer.valueOf(20), myOperation.getProperty("propertyC"));
- assertEquals("valueD", oper.getRequiredProperty("propertyD", "typeD"));
+ assertEquals("valueD", myOperation.getRequiredProperty("propertyD", "typeD"));
- assertThatIllegalStateException().isThrownBy(() -> oper.getRequiredProperty("propertyUnknown", "some type"))
- .withMessage("missing some type");
+ assertThatIllegalStateException().isThrownBy(() ->
+ myOperation.getRequiredProperty("propertyUnknown", "some type")).withMessage("missing some type");
}
@Test
@@ -236,7 +236,7 @@ class OperationPartialTest {
@Test
void testStartMultiple() {
for (int count = 0; count < MAX_PARALLEL; ++count) {
- oper.start();
+ myOperation.start();
}
assertTrue(executor.runAll(MAX_REQUESTS * MAX_PARALLEL));
@@ -246,65 +246,65 @@ class OperationPartialTest {
assertEquals(OperationResult.SUCCESS, opend.getResult());
assertEquals(MAX_PARALLEL, numStart);
- assertEquals(MAX_PARALLEL, oper.getCount());
+ assertEquals(MAX_PARALLEL, myOperation.getCount());
assertEquals(MAX_PARALLEL, numEnd);
}
@Test
void testStartOperationAsync() {
- oper.start();
+ myOperation.start();
assertTrue(executor.runAll(MAX_REQUESTS));
- assertEquals(1, oper.getCount());
+ assertEquals(1, myOperation.getCount());
}
@Test
void testIsSuccess() {
- assertFalse(oper.isSuccess(null));
+ assertFalse(myOperation.isSuccess(null));
OperationOutcome outcome = new OperationOutcome();
outcome.setResult(OperationResult.SUCCESS);
- assertTrue(oper.isSuccess(outcome));
+ assertTrue(myOperation.isSuccess(outcome));
for (OperationResult failure : FAILURE_RESULTS) {
outcome.setResult(failure);
- assertFalse(oper.isSuccess(outcome), "testIsSuccess-" + failure);
+ assertFalse(myOperation.isSuccess(outcome), "testIsSuccess-" + failure);
}
}
@Test
void testIsActorFailed() {
- assertFalse(oper.isActorFailed(null));
+ assertFalse(myOperation.isActorFailed(null));
OperationOutcome outcome = params.makeOutcome();
// incorrect outcome
outcome.setResult(OperationResult.SUCCESS);
- assertFalse(oper.isActorFailed(outcome));
+ assertFalse(myOperation.isActorFailed(outcome));
outcome.setResult(OperationResult.FAILURE_RETRIES);
- assertFalse(oper.isActorFailed(outcome));
+ assertFalse(myOperation.isActorFailed(outcome));
// correct outcome
outcome.setResult(OperationResult.FAILURE);
// incorrect actor
outcome.setActor(MY_SINK);
- assertFalse(oper.isActorFailed(outcome));
+ assertFalse(myOperation.isActorFailed(outcome));
outcome.setActor(null);
- assertFalse(oper.isActorFailed(outcome));
+ assertFalse(myOperation.isActorFailed(outcome));
outcome.setActor(ACTOR);
// incorrect operation
outcome.setOperation(MY_SINK);
- assertFalse(oper.isActorFailed(outcome));
+ assertFalse(myOperation.isActorFailed(outcome));
outcome.setOperation(null);
- assertFalse(oper.isActorFailed(outcome));
+ assertFalse(myOperation.isActorFailed(outcome));
outcome.setOperation(OPERATION);
// correct values
- assertTrue(oper.isActorFailed(outcome));
+ assertTrue(myOperation.isActorFailed(outcome));
}
@Test
@@ -328,7 +328,7 @@ class OperationPartialTest {
params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
// trigger timeout very quickly
- oper = new MyOper() {
+ myOperation = new MyOper() {
@Override
protected long getTimeoutMs(Integer timeoutSec) {
return 1;
@@ -353,7 +353,7 @@ class OperationPartialTest {
}
};
- assertEquals(OperationResult.FAILURE_TIMEOUT, oper.start().get().getResult());
+ assertEquals(OperationResult.FAILURE_TIMEOUT, myOperation.start().get().getResult());
}
/**
@@ -364,9 +364,9 @@ class OperationPartialTest {
params = params.toBuilder().retry(0).build();
// new params, thus need a new operation
- oper = new MyOper();
+ myOperation = new MyOper();
- oper.setMaxFailures(10);
+ myOperation.setMaxFailures(10);
verifyRun("testSetRetryFlag_testRetryOnFailure_ZeroRetries", 1, 1, OperationResult.FAILURE);
}
@@ -379,9 +379,9 @@ class OperationPartialTest {
params = params.toBuilder().retry(null).build();
// new params, thus need a new operation
- oper = new MyOper();
+ myOperation = new MyOper();
- oper.setMaxFailures(10);
+ myOperation.setMaxFailures(10);
verifyRun("testSetRetryFlag_testRetryOnFailure_NullRetries", 1, 1, OperationResult.FAILURE);
}
@@ -395,9 +395,9 @@ class OperationPartialTest {
params = params.toBuilder().retry(maxRetries).build();
// new params, thus need a new operation
- oper = new MyOper();
+ myOperation = new MyOper();
- oper.setMaxFailures(10);
+ myOperation.setMaxFailures(10);
verifyRun("testSetRetryFlag_testRetryOnFailure_RetriesExhausted", maxRetries + 1, maxRetries + 1,
OperationResult.FAILURE_RETRIES);
@@ -411,10 +411,10 @@ class OperationPartialTest {
params = params.toBuilder().retry(10).build();
// new params, thus need a new operation
- oper = new MyOper();
+ myOperation = new MyOper();
final int maxFailures = 3;
- oper.setMaxFailures(maxFailures);
+ myOperation.setMaxFailures(maxFailures);
verifyRun("testSetRetryFlag_testRetryOnFailure_SuccessAfterRetries", maxFailures + 1, maxFailures + 1,
OperationResult.SUCCESS);
@@ -427,7 +427,7 @@ class OperationPartialTest {
void testSetRetryFlag_testRetryOnFailure_NullOutcome() {
// arrange to return null from doOperation()
- oper = new MyOper() {
+ myOperation = new MyOper() {
@Override
protected OperationOutcome doOperation(int attempt, OperationOutcome outcome) {
@@ -442,12 +442,12 @@ class OperationPartialTest {
@Test
void testSleep() throws Exception {
- CompletableFuture<Void> future = oper.sleep(-1, TimeUnit.SECONDS);
+ CompletableFuture<Void> future = myOperation.sleep(-1, TimeUnit.SECONDS);
assertTrue(future.isDone());
assertNull(future.get());
// edge case
- future = oper.sleep(0, TimeUnit.SECONDS);
+ future = myOperation.sleep(0, TimeUnit.SECONDS);
assertTrue(future.isDone());
assertNull(future.get());
@@ -455,9 +455,9 @@ class OperationPartialTest {
* Start a second sleep we can use to check the first while it's running.
*/
tstart = Instant.now();
- future = oper.sleep(100, TimeUnit.MILLISECONDS);
+ future = myOperation.sleep(100, TimeUnit.MILLISECONDS);
- CompletableFuture<Void> future2 = oper.sleep(10, TimeUnit.MILLISECONDS);
+ CompletableFuture<Void> future2 = myOperation.sleep(10, TimeUnit.MILLISECONDS);
// wait for second to complete and verify that the first has not completed
future2.get();
@@ -472,31 +472,31 @@ class OperationPartialTest {
@Test
void testIsSameOperation() {
- assertFalse(oper.isSameOperation(null));
+ assertFalse(myOperation.isSameOperation(null));
OperationOutcome outcome = params.makeOutcome();
// wrong actor - should be false
outcome.setActor(null);
- assertFalse(oper.isSameOperation(outcome));
+ assertFalse(myOperation.isSameOperation(outcome));
outcome.setActor(MY_SINK);
- assertFalse(oper.isSameOperation(outcome));
+ assertFalse(myOperation.isSameOperation(outcome));
outcome.setActor(ACTOR);
// wrong operation - should be null
outcome.setOperation(null);
- assertFalse(oper.isSameOperation(outcome));
+ assertFalse(myOperation.isSameOperation(outcome));
outcome.setOperation(MY_SINK);
- assertFalse(oper.isSameOperation(outcome));
+ assertFalse(myOperation.isSameOperation(outcome));
outcome.setOperation(OPERATION);
- assertTrue(oper.isSameOperation(outcome));
+ assertTrue(myOperation.isSameOperation(outcome));
}
@Test
void testFromException() {
// arrange to generate an exception when operation runs
- oper.setGenException(true);
+ myOperation.setGenException(true);
verifyRun("testFromException", 1, 1, OperationResult.FAILURE_EXCEPTION);
}
@@ -520,11 +520,11 @@ class OperationPartialTest {
final OperationOutcome outcome = params.makeOutcome();
tasks.add(() -> CompletableFuture.completedFuture(outcome));
- tasks.add(() -> new CompletableFuture<>());
+ tasks.add(CompletableFuture::new);
tasks.add(() -> null);
- tasks.add(() -> new CompletableFuture<>());
+ tasks.add(CompletableFuture::new);
- CompletableFuture<OperationOutcome> result = oper.anyOf(tasks);
+ CompletableFuture<OperationOutcome> result = myOperation.anyOf(tasks);
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isDone());
assertSame(outcome, result.get());
@@ -532,29 +532,29 @@ class OperationPartialTest {
// repeat using array form
@SuppressWarnings("unchecked")
Supplier<CompletableFuture<OperationOutcome>>[] taskArray = new Supplier[tasks.size()];
- result = oper.anyOf(tasks.toArray(taskArray));
+ result = myOperation.anyOf(tasks.toArray(taskArray));
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isDone());
assertSame(outcome, result.get());
// second task completes, others do not
tasks.clear();
- tasks.add(() -> new CompletableFuture<>());
+ tasks.add(CompletableFuture::new);
tasks.add(() -> CompletableFuture.completedFuture(outcome));
- tasks.add(() -> new CompletableFuture<>());
+ tasks.add(CompletableFuture::new);
- result = oper.anyOf(tasks);
+ result = myOperation.anyOf(tasks);
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isDone());
assertSame(outcome, result.get());
// third task completes, others do not
tasks.clear();
- tasks.add(() -> new CompletableFuture<>());
- tasks.add(() -> new CompletableFuture<>());
+ tasks.add(CompletableFuture::new);
+ tasks.add(CompletableFuture::new);
tasks.add(() -> CompletableFuture.completedFuture(outcome));
- result = oper.anyOf(tasks);
+ result = myOperation.anyOf(tasks);
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isDone());
assertSame(outcome, result.get());
@@ -569,15 +569,15 @@ class OperationPartialTest {
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
// zero items: check both using a list and using an array
- assertNull(oper.anyOf(tasks));
- assertNull(oper.anyOf());
+ assertNull(myOperation.anyOf(tasks));
+ assertNull(myOperation.anyOf());
// one item: : check both using a list and using an array
CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
tasks.add(() -> future1);
- assertSame(future1, oper.anyOf(tasks));
- assertSame(future1, oper.anyOf(() -> future1));
+ assertSame(future1, myOperation.anyOf(tasks));
+ assertSame(future1, myOperation.anyOf(() -> future1));
}
@Test
@@ -590,7 +590,7 @@ class OperationPartialTest {
@SuppressWarnings("unchecked")
CompletableFuture<OperationOutcome> result =
- oper.allOf(() -> future1, () -> future2, () -> null, () -> future3);
+ myOperation.allOf(() -> future1, () -> future2, () -> null, () -> future3);
assertTrue(executor.runAll(MAX_REQUESTS));
assertFalse(result.isDone());
@@ -625,7 +625,7 @@ class OperationPartialTest {
tasks.add(() -> null);
tasks.add(() -> future3);
- CompletableFuture<OperationOutcome> result = oper.allOf(tasks);
+ CompletableFuture<OperationOutcome> result = myOperation.allOf(tasks);
assertTrue(executor.runAll(MAX_REQUESTS));
assertFalse(result.isDone());
@@ -655,15 +655,15 @@ class OperationPartialTest {
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
// zero items: check both using a list and using an array
- assertNull(oper.allOf(tasks));
- assertNull(oper.allOf());
+ assertNull(myOperation.allOf(tasks));
+ assertNull(myOperation.allOf());
// one item: : check both using a list and using an array
CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
tasks.add(() -> future1);
- assertSame(future1, oper.allOf(tasks));
- assertSame(future1, oper.allOf(() -> future1));
+ assertSame(future1, myOperation.allOf(tasks));
+ assertSame(future1, myOperation.allOf(() -> future1));
}
@Test
@@ -681,7 +681,7 @@ class OperationPartialTest {
});
tasks.add(() -> future3);
- assertThatIllegalStateException().isThrownBy(() -> oper.anyOf(tasks)).withMessage(EXPECTED_EXCEPTION);
+ assertThatIllegalStateException().isThrownBy(() -> myOperation.anyOf(tasks)).withMessage(EXPECTED_EXCEPTION);
// should have canceled the first two, but not the last
assertTrue(future1.isCancelled());
@@ -705,7 +705,7 @@ class OperationPartialTest {
tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
tasks.add(() -> CompletableFuture.completedFuture(null));
tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
- CompletableFuture<OperationOutcome> result = oper.allOf(tasks);
+ CompletableFuture<OperationOutcome> result = myOperation.allOf(tasks);
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isDone());
@@ -718,7 +718,7 @@ class OperationPartialTest {
tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
tasks.add(() -> CompletableFuture.failedFuture(except));
tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
- result = oper.allOf(tasks);
+ result = myOperation.allOf(tasks);
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isCompletedExceptionally());
@@ -738,7 +738,7 @@ class OperationPartialTest {
tasks.add(() -> CompletableFuture.completedFuture(outcome));
tasks.add(() -> CompletableFuture.completedFuture(outcome));
- CompletableFuture<OperationOutcome> result = oper.sequence(tasks);
+ CompletableFuture<OperationOutcome> result = myOperation.sequence(tasks);
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isDone());
assertSame(outcome, result.get());
@@ -746,7 +746,7 @@ class OperationPartialTest {
// repeat using array form
@SuppressWarnings("unchecked")
Supplier<CompletableFuture<OperationOutcome>>[] taskArray = new Supplier[tasks.size()];
- result = oper.sequence(tasks.toArray(taskArray));
+ result = myOperation.sequence(tasks.toArray(taskArray));
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isDone());
assertSame(outcome, result.get());
@@ -759,7 +759,7 @@ class OperationPartialTest {
tasks.add(() -> CompletableFuture.completedFuture(failure));
tasks.add(() -> CompletableFuture.completedFuture(outcome));
- result = oper.sequence(tasks);
+ result = myOperation.sequence(tasks);
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isDone());
assertSame(failure, result.get());
@@ -774,15 +774,15 @@ class OperationPartialTest {
List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
// zero items: check both using a list and using an array
- assertNull(oper.sequence(tasks));
- assertNull(oper.sequence());
+ assertNull(myOperation.sequence(tasks));
+ assertNull(myOperation.sequence());
// one item: : check both using a list and using an array
CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
tasks.add(() -> future1);
- assertSame(future1, oper.sequence(tasks));
- assertSame(future1, oper.sequence(() -> future1));
+ assertSame(future1, myOperation.sequence(tasks));
+ assertSame(future1, myOperation.sequence(() -> future1));
}
private void verifyOutcomes(int expected, OperationResult... results) throws Exception {
@@ -800,7 +800,7 @@ class OperationPartialTest {
}
}
- CompletableFuture<OperationOutcome> result = oper.allOf(tasks);
+ CompletableFuture<OperationOutcome> result = myOperation.allOf(tasks);
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(result.isDone());
@@ -809,7 +809,7 @@ class OperationPartialTest {
@Test
void testDetmPriority() throws CoderException {
- assertEquals(1, oper.detmPriority(null));
+ assertEquals(1, myOperation.detmPriority(null));
OperationOutcome outcome = params.makeOutcome();
@@ -819,7 +819,7 @@ class OperationPartialTest {
for (Entry<OperationResult, Integer> ent : map.entrySet()) {
outcome.setResult(ent.getKey());
- assertEquals(ent.getValue().intValue(), oper.detmPriority(outcome), ent.getKey().toString());
+ assertEquals(ent.getValue().intValue(), myOperation.detmPriority(outcome), ent.getKey().toString());
}
/*
@@ -827,7 +827,7 @@ class OperationPartialTest {
* won't allow it. Instead, we decode it from a structure.
*/
outcome = new StandardCoder().decode("{\"result\":null}", OperationOutcome.class);
- assertEquals(1, oper.detmPriority(outcome));
+ assertEquals(1, myOperation.detmPriority(outcome));
}
/**
@@ -841,15 +841,15 @@ class OperationPartialTest {
* arrange to stop the controller when the start-callback is invoked, but capture
* the outcome
*/
- params = params.toBuilder().startCallback(oper -> {
- starter(oper);
+ params = params.toBuilder().startCallback(outcome -> {
+ starter(outcome);
future.get().cancel(false);
}).build();
// new params, thus need a new operation
- oper = new MyOper();
+ myOperation = new MyOper();
- future.set(oper.start());
+ future.set(myOperation.start());
assertTrue(executor.runAll(MAX_REQUESTS));
// should have only run once
@@ -864,14 +864,14 @@ class OperationPartialTest {
AtomicReference<Future<OperationOutcome>> future = new AtomicReference<>();
// arrange to stop the controller when the start-callback is invoked
- params = params.toBuilder().startCallback(oper -> {
+ params = params.toBuilder().startCallback(outcome -> {
future.get().cancel(false);
}).build();
// new params, thus need a new operation
- oper = new MyOper();
+ myOperation = new MyOper();
- future.set(oper.start());
+ future.set(myOperation.start());
assertTrue(executor.runAll(MAX_REQUESTS));
// should not have been set
@@ -886,12 +886,12 @@ class OperationPartialTest {
OperationOutcome outcome;
outcome = new OperationOutcome();
- oper.setOutcome(outcome, timex);
+ myOperation.setOutcome(outcome, timex);
assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage());
assertEquals(OperationResult.FAILURE_TIMEOUT, outcome.getResult());
outcome = new OperationOutcome();
- oper.setOutcome(outcome, new IllegalStateException(EXPECTED_EXCEPTION));
+ myOperation.setOutcome(outcome, new IllegalStateException(EXPECTED_EXCEPTION));
assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage());
assertEquals(OperationResult.FAILURE_EXCEPTION, outcome.getResult());
}
@@ -901,17 +901,17 @@ class OperationPartialTest {
OperationOutcome outcome;
outcome = new OperationOutcome();
- oper.setOutcome(outcome, OperationResult.SUCCESS);
+ myOperation.setOutcome(outcome, OperationResult.SUCCESS);
assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage());
assertEquals(OperationResult.SUCCESS, outcome.getResult());
- oper.setOutcome(outcome, OperationResult.SUCCESS);
+ myOperation.setOutcome(outcome, OperationResult.SUCCESS);
assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage());
assertEquals(OperationResult.SUCCESS, outcome.getResult());
for (OperationResult result : FAILURE_RESULTS) {
outcome = new OperationOutcome();
- oper.setOutcome(outcome, result);
+ myOperation.setOutcome(outcome, result);
assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage(), result.toString());
assertEquals(result, outcome.getResult(), result.toString());
}
@@ -919,22 +919,22 @@ class OperationPartialTest {
@Test
void testMakeOutcome() {
- oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_TARGET_ENTITY);
- assertEquals(MY_TARGET_ENTITY, oper.makeOutcome().getTarget());
+ myOperation.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_TARGET_ENTITY);
+ assertEquals(MY_TARGET_ENTITY, myOperation.makeOutcome().getTarget());
}
@Test
void testIsTimeout() {
final TimeoutException timex = new TimeoutException(EXPECTED_EXCEPTION);
- assertFalse(oper.isTimeout(new IllegalStateException(EXPECTED_EXCEPTION)));
- assertFalse(oper.isTimeout(new IllegalStateException(timex)));
- assertFalse(oper.isTimeout(new CompletionException(new IllegalStateException(timex))));
- assertFalse(oper.isTimeout(new CompletionException(null)));
- assertFalse(oper.isTimeout(new CompletionException(new CompletionException(timex))));
+ assertFalse(myOperation.isTimeout(new IllegalStateException(EXPECTED_EXCEPTION)));
+ assertFalse(myOperation.isTimeout(new IllegalStateException(timex)));
+ assertFalse(myOperation.isTimeout(new CompletionException(new IllegalStateException(timex))));
+ assertFalse(myOperation.isTimeout(new CompletionException(null)));
+ assertFalse(myOperation.isTimeout(new CompletionException(new CompletionException(timex))));
- assertTrue(oper.isTimeout(timex));
- assertTrue(oper.isTimeout(new CompletionException(timex)));
+ assertTrue(myOperation.isTimeout(timex));
+ assertTrue(myOperation.isTimeout(new CompletionException(timex)));
}
@Test
@@ -943,7 +943,7 @@ class OperationPartialTest {
// log structured data
appender.clearExtractions();
- oper.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, new MyData());
+ myOperation.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, new MyData());
List<String> output = appender.getExtracted();
assertEquals(1, output.size());
@@ -952,7 +952,7 @@ class OperationPartialTest {
// repeat with a response
appender.clearExtractions();
- oper.logMessage(EventType.IN, SOURCE_INFRA, MY_SOURCE, new MyData());
+ myOperation.logMessage(EventType.IN, SOURCE_INFRA, MY_SOURCE, new MyData());
output = appender.getExtracted();
assertEquals(1, output.size());
@@ -961,14 +961,14 @@ class OperationPartialTest {
// log a plain string
appender.clearExtractions();
- oper.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, TEXT);
+ myOperation.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, TEXT);
output = appender.getExtracted();
assertEquals(1, output.size());
assertThat(output.get(0)).contains(infraStr).contains(MY_SINK).contains(TEXT);
// log a null request
appender.clearExtractions();
- oper.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, null);
+ myOperation.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, null);
output = appender.getExtracted();
assertEquals(1, output.size());
@@ -978,7 +978,7 @@ class OperationPartialTest {
setOperCoderException();
appender.clearExtractions();
- oper.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, new MyData());
+ myOperation.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, new MyData());
output = appender.getExtracted();
assertEquals(2, output.size());
assertThat(output.get(0)).contains("cannot pretty-print request");
@@ -986,7 +986,7 @@ class OperationPartialTest {
// repeat with a response
appender.clearExtractions();
- oper.logMessage(EventType.IN, SOURCE_INFRA, MY_SOURCE, new MyData());
+ myOperation.logMessage(EventType.IN, SOURCE_INFRA, MY_SOURCE, new MyData());
output = appender.getExtracted();
assertEquals(2, output.size());
assertThat(output.get(0)).contains("cannot pretty-print response");
@@ -995,8 +995,8 @@ class OperationPartialTest {
@Test
void testGetRetry() {
- assertEquals(0, oper.getRetry(null));
- assertEquals(10, oper.getRetry(10));
+ assertEquals(0, myOperation.getRetry(null));
+ assertEquals(10, myOperation.getRetry(10));
}
@Test
@@ -1008,14 +1008,14 @@ class OperationPartialTest {
@Test
void testGetTimeOutMs() {
- assertEquals(TIMEOUT * 1000, oper.getTimeoutMs(params.getTimeoutSec()));
+ assertEquals(TIMEOUT * 1000, myOperation.getTimeoutMs(params.getTimeoutSec()));
params = params.toBuilder().timeoutSec(null).build();
// new params, thus need a new operation
- oper = new MyOper();
+ myOperation = new MyOper();
- assertEquals(0, oper.getTimeoutMs(params.getTimeoutSec()));
+ assertEquals(0, myOperation.getTimeoutMs(params.getTimeoutSec()));
}
private void starter(OperationOutcome oper) {
@@ -1074,7 +1074,7 @@ class OperationPartialTest {
starts.clear();
ends.clear();
- CompletableFuture<OperationOutcome> future = oper.start();
+ CompletableFuture<OperationOutcome> future = myOperation.start();
manipulator.accept(future);
@@ -1112,20 +1112,20 @@ class OperationPartialTest {
}
if (expectedOperations > 0) {
- assertNotNull(testName, oper.getSubRequestId());
- assertEquals(oper.getSubRequestId(), opstart.getSubRequestId(), testName + " op start");
- assertEquals(oper.getSubRequestId(), opend.getSubRequestId(), testName + " op end");
+ assertNotNull(testName, myOperation.getSubRequestId());
+ assertEquals(myOperation.getSubRequestId(), opstart.getSubRequestId(), testName + " op start");
+ assertEquals(myOperation.getSubRequestId(), opend.getSubRequestId(), testName + " op end");
}
}
- assertEquals(expectedOperations, oper.getCount(), testName);
+ assertEquals(expectedOperations, myOperation.getCount(), testName);
}
/**
- * Creates a new {@link #oper} whose coder will throw an exception.
+ * Creates a new {@link #myOperation} whose coder will throw an exception.
*/
private void setOperCoderException() {
- oper = new MyOper() {
+ myOperation = new MyOper() {
@Override
protected Coder getCoder() {
return new StandardCoder() {
@@ -1141,7 +1141,7 @@ class OperationPartialTest {
@Getter
static class MyData {
- private String text = TEXT;
+ private final String text = TEXT;
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java
index 2c8275986..7ed9eb4cd 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ package org.onap.policy.controlloop.actorserviceprovider.pipeline;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -253,7 +254,7 @@ class PipelineControllerFutureTest {
void testNewIncompleteFuture() {
PipelineControllerFuture<String> future = controller.newIncompleteFuture();
assertNotNull(future);
- assertTrue(future instanceof PipelineControllerFuture);
+ assertInstanceOf(PipelineControllerFuture.class, future);
assertNotSame(controller, future);
assertFalse(future.isDone());
}
@@ -402,7 +403,7 @@ class PipelineControllerFutureTest {
verify(controller, never()).remove(compFuture);
compFuture.completeExceptionally(EXPECTED_EXCEPTION);
- assertThatThrownBy(() -> future.get()).hasCause(EXPECTED_EXCEPTION);
+ assertThatThrownBy(future::get).hasCause(EXPECTED_EXCEPTION);
verify(controller).remove(compFuture);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java
index aef170ba7..a04e0f359 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,6 @@ class PipelineUtilTest {
ControlLoopOperationParams params = ControlLoopOperationParams.builder().build();
PipelineUtil util = new PipelineUtil(params);
- assertThatThrownBy(() -> util.start()).isInstanceOf(UnsupportedOperationException.class);
+ assertThatThrownBy(util::start).isInstanceOf(UnsupportedOperationException.class);
}
}