aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actorServiceProvider/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-10 16:17:10 -0500
committerJim Hahn <jrh3@att.com>2021-02-10 17:17:34 -0500
commitb7097d21c25a48c9d209548ac8afdc09b1679457 (patch)
treeee7a911622c333818a9ac30f2cae68aee7eb6601 /models-interactions/model-actors/actorServiceProvider/src
parentf04d89c55ab4dfa94dfed1cc9b65471d1d3140c5 (diff)
More sonars in models
Addressed the following: - make constructors protected - check exception type - too many assertions - remove annotation lists - use "<>" - reduce cognitive complexity - extract constant - multiple method calls in one assert - don't use eq() in verify() - indentation Issue-ID: POLICY-2905 Change-Id: I25bb3951f781250e9cdfe8f5f3b80cb63e129184 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider/src')
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java6
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java8
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java8
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java5
9 files changed, 23 insertions, 24 deletions
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
index e02e59239..b0ad38eff 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
* @param clazz response class
* @param propertyNames names of properties required by this operation
*/
- public BidirectionalTopicOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
+ protected BidirectionalTopicOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
Class<S> clazz, List<String> propertyNames) {
super(params, config, propertyNames);
this.config = config;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
index c75ca1d4f..a4b48d432 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -93,7 +93,7 @@ public abstract class HttpOperation<T> extends OperationPartial {
* @param clazz response class
* @param propertyNames names of properties required by this operation
*/
- public HttpOperation(ControlLoopOperationParams params, HttpConfig config, Class<T> clazz,
+ protected HttpOperation(ControlLoopOperationParams params, HttpConfig config, Class<T> clazz,
List<String> propertyNames) {
super(params, config, propertyNames);
this.config = config;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
index 6874c5edd..7ad0cd82e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -118,7 +118,7 @@ public abstract class OperationPartial implements Operation {
* @param config configuration for this operation
* @param propertyNames names of properties required by this operation
*/
- public OperationPartial(ControlLoopOperationParams params, OperatorConfig config, List<String> propertyNames) {
+ protected OperationPartial(ControlLoopOperationParams params, OperatorConfig config, List<String> propertyNames) {
this.params = params;
this.config = config;
this.fullName = params.getActor() + "." + params.getOperation();
@@ -518,7 +518,7 @@ public abstract class OperationPartial implements Operation {
return futures[0];
}
- CompletableFuture.anyOf(futures).thenApply(outcome -> (OperationOutcome) outcome)
+ CompletableFuture.anyOf(futures).thenApply(OperationOutcome.class::cast)
.whenCompleteAsync(controller.delayedComplete(), params.getExecutor());
return controller;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
index 8007c24f9..e75e99eaa 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperatorPartial.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public abstract class OperatorPartial extends StartConfigPartial<Map<String, Obj
* @param actorName name of the actor with which this operator is associated
* @param name operation name
*/
- public OperatorPartial(String actorName, String name) {
+ protected OperatorPartial(String actorName, String name) {
super(actorName + "." + name);
this.actorName = actorName;
this.name = name;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
index 6c883f1b5..1cf611a61 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/StartConfigPartial.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@ public abstract class StartConfigPartial<T> implements Startable, Configurable<T
*
* @param fullName full name of this object, used for logging and exception purposes
*/
- public StartConfigPartial(String fullName) {
+ protected StartConfigPartial(String fullName) {
this.fullName = fullName;
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
index 937776926..55bdab9ad 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ public abstract class TypedOperator<C, T extends Operation> extends OperatorPart
* @param name operation name
* @param operationMaker function to make an operation
*/
- public TypedOperator(String actorName, String name, OperationMaker<C, T> operationMaker) {
+ protected TypedOperator(String actorName, String name, OperationMaker<C, T> operationMaker) {
super(actorName, name);
this.operationMaker = operationMaker;
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
index 605a7330c..6f667bb76 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -112,10 +112,10 @@ public class OperationOutcomeTest {
outcome.setOperation(OPERATION);
// null actor argument
- assertThatThrownBy(() -> outcome.isFor(null, OPERATION));
+ assertThatThrownBy(() -> outcome.isFor(null, OPERATION)).isInstanceOf(NullPointerException.class);
// null operation argument
- assertThatThrownBy(() -> outcome.isFor(ACTOR, null));
+ assertThatThrownBy(() -> outcome.isFor(ACTOR, null)).isInstanceOf(NullPointerException.class);
// true case
assertTrue(OperationOutcome.isFor(outcome, ACTOR, OPERATION));
@@ -126,7 +126,7 @@ public class OperationOutcomeTest {
outcome.setResult(OperationResult.FAILURE_EXCEPTION);
assertEquals(OperationResult.FAILURE_EXCEPTION, outcome.getResult());
- assertThatThrownBy(() -> outcome.setResult(null));
+ assertThatThrownBy(() -> outcome.setResult(null)).isInstanceOf(NullPointerException.class);
}
private void setAll() {
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
index 08d4adfd2..95799b7d2 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -166,7 +166,7 @@ public class BidirectionalTopicOperationTest {
assertEquals(OperationResult.SUCCESS, outcome.getResult());
assertEquals(response, outcome.getResponse());
- verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue());
}
/**
@@ -194,7 +194,7 @@ public class BidirectionalTopicOperationTest {
assertTrue(executor.runAll(MAX_REQUESTS));
assertTrue(future.isCompletedExceptionally());
- verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue());
}
/**
@@ -210,7 +210,7 @@ public class BidirectionalTopicOperationTest {
verify(forwarder).register(eq(Arrays.asList(REQ_ID)), listenerCaptor.capture());
// must still unregister
- verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue()));
+ verify(forwarder).unregister(Arrays.asList(REQ_ID), listenerCaptor.getValue());
}
@Test
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
index 54d56de53..7f2f6770e 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/BidirectionalTopicHandlerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -68,7 +67,7 @@ public class BidirectionalTopicHandlerTest {
MockitoAnnotations.initMocks(this);
when(mgr.getTopicSinks(MY_SINK)).thenReturn(Arrays.asList(publisher));
- when(mgr.getTopicSources(eq(Arrays.asList(MY_SOURCE)))).thenReturn(Arrays.asList(subscriber));
+ when(mgr.getTopicSources(Arrays.asList(MY_SOURCE))).thenReturn(Arrays.asList(subscriber));
when(publisher.getTopicCommInfrastructure()).thenReturn(CommInfrastructure.NOOP);