summaryrefslogtreecommitdiffstats
path: root/controlloop/common/rules-test/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-09-30 12:52:25 -0400
committerJim Hahn <jrh3@att.com>2020-09-30 14:59:39 -0400
commitfb9bd637567096f6174bbc2e52a5e149a4eed882 (patch)
tree7b0d2df1aefbb3635788af501be1157fbe05d798 /controlloop/common/rules-test/src
parente8e477ab80c6762fb05aebfe9becc630d2d51e39 (diff)
Fix new sonars in drools-apps
Addressed the following sonars: - too many assertions in test method - rename test class - use static method to modify static field - use already defined constant - code always returns the same value - use assertNotSame - use appropriate class name to access static method - define a constant - extract nested try block - don't always return the same value - use remove() instead of set(null) for thread-local-storage - add @Override Issue-ID: POLICY-2852 Change-Id: Icc62acd4ad57afa2d44ed4cdca504a3ac0810228 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/rules-test/src')
-rw-r--r--controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java11
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/NamedRunner2Test.java (renamed from controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/NamedRunnerTest2.java)2
2 files changed, 9 insertions, 4 deletions
diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java
index f5346def8..83825bca9 100644
--- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java
+++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java
@@ -30,6 +30,7 @@ import java.util.function.Supplier;
import java.util.stream.Collectors;
import lombok.AccessLevel;
import lombok.Getter;
+import lombok.Setter;
import org.awaitility.Awaitility;
import org.junit.Test;
import org.onap.policy.appc.Request;
@@ -55,6 +56,9 @@ public abstract class BaseTest {
private static final String APPC_RESTART_OP = "restart";
private static final String APPC_MODIFY_CONFIG_OP = "ModifyConfig";
+ private static final String SDNR_MODIFY_CONFIG_OP = "ModifyConfig";
+ private static final String SNDR_MODIFY_CONFIG_ANR_OP = "ModifyConfigANR";
+
/*
* Canonical Topic Names.
*/
@@ -135,6 +139,7 @@ public abstract class BaseTest {
// used to inject and wait for messages
@Getter(AccessLevel.PROTECTED)
+ @Setter(AccessLevel.PROTECTED)
protected static Topics topics;
// used to wait for messages on SINK topics
@@ -168,7 +173,7 @@ public abstract class BaseTest {
* Initializes {@link #topics} and {@link #controller}.
*/
public void init() {
- topics = topicMaker.get();
+ setTopics(topicMaker.get());
Map<String, SimpleLock> locks = getLockMap();
if (locks != null) {
@@ -348,7 +353,7 @@ public abstract class BaseTest {
*/
@Test
public void testVpciSunnyDayCompliant() {
- sdnrSunnyDay(VPCI_TOSCA_COMPLIANT_POLICY, VPCI_ONSET, VPCI_SDNR_SUCCESS, "ModifyConfig");
+ sdnrSunnyDay(VPCI_TOSCA_COMPLIANT_POLICY, VPCI_ONSET, VPCI_SDNR_SUCCESS, SDNR_MODIFY_CONFIG_OP);
}
// VSONH
@@ -358,7 +363,7 @@ public abstract class BaseTest {
*/
@Test
public void testVsonhSunnyDayCompliant() {
- sdnrSunnyDay(VSONH_TOSCA_COMPLIANT_POLICY, VSONH_ONSET, VSONH_SDNR_SUCCESS, "ModifyConfigANR");
+ sdnrSunnyDay(VSONH_TOSCA_COMPLIANT_POLICY, VSONH_ONSET, VSONH_SDNR_SUCCESS, SNDR_MODIFY_CONFIG_ANR_OP);
}
/**
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/NamedRunnerTest2.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/NamedRunner2Test.java
index 1ed5b20bc..91e19ce79 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/NamedRunnerTest2.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/NamedRunner2Test.java
@@ -32,7 +32,7 @@ import org.junit.runner.RunWith;
* executed.
*/
@RunWith(NamedRunner.class)
-public class NamedRunnerTest2 {
+public class NamedRunner2Test {
private static int testCount = 0;