summaryrefslogtreecommitdiffstats
path: root/controlloop/common/rules-test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-07 15:50:22 -0400
committerJim Hahn <jrh3@att.com>2021-05-07 16:04:58 -0400
commitc2cbd89fea87897b6868b036d87d97916e89734e (patch)
treeff611957eba521fabac337d8436bb0a415330430 /controlloop/common/rules-test
parent2faa81d80569ce38a014e2a2ab404b1ea9f6899e (diff)
Fix sonars in drools-apps
Fixed: - use "var" - add @Override annotation - change constructor to "protected" - use Xxx.class::isIstance Issue-ID: POLICY-3290 Change-Id: I7f0795af306ea5afb46d12a4fe0b22adcbce683a Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/rules-test')
-rw-r--r--controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseTest.java6
-rw-r--r--controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/NamedRunner.java5
-rw-r--r--controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.java16
-rw-r--r--controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Topics.java4
4 files changed, 15 insertions, 16 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 9a82389be..4e4fb829c 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
@@ -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.
@@ -206,7 +206,7 @@ public abstract class BaseTest {
waitForLockAndPermit(policy, policyClMgt);
// restart request should be sent and fail four times (i.e., because retry=3)
- for (int count = 0; count < 4; ++count) {
+ for (var count = 0; count < 4; ++count) {
AppcLcmDmaapWrapper appcreq = appcLcmRead.await(req -> APPC_RESTART_OP.equals(req.getRpcName()));
topics.inject(APPC_LCM_WRITE_TOPIC, SERVICE123_APPC_RESTART_FAILURE,
@@ -258,7 +258,7 @@ public abstract class BaseTest {
topics.inject(DCAE_TOPIC, DUPLICATES_ONSET_1, UUID.randomUUID().toString());
// should see two restarts
- for (int count = 0; count < 2; ++count) {
+ for (var count = 0; count < 2; ++count) {
AppcLcmDmaapWrapper appcreq = appcLcmRead.await(req -> APPC_RESTART_OP.equals(req.getRpcName()));
// indicate success
diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/NamedRunner.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/NamedRunner.java
index 1cbe5a56a..5642f35fd 100644
--- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/NamedRunner.java
+++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/NamedRunner.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.
@@ -21,7 +21,6 @@
package org.onap.policy.controlloop.common.rules.test;
import org.junit.Ignore;
-import org.junit.runner.Description;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
@@ -41,7 +40,7 @@ public class NamedRunner extends BlockJUnit4ClassRunner {
@Override
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
- Description description = describeChild(method);
+ var description = describeChild(method);
if (method.getAnnotation(Ignore.class) != null) {
notifier.fireTestIgnored(description);
diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.java
index 1b8f94cae..06eab0d88 100644
--- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.java
+++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Rules.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.
@@ -113,10 +113,10 @@ public class Rules {
pdpdRepo.setConfigurationDir("src/test/resources/config");
try {
- File kmoduleFile = new File(resourceDir + "/META-INF/kmodule.xml");
- File pomFile = new File("src/test/resources/" + controllerName + ".pom");
- String resourceDir2 = resourceDir + "/org/onap/policy/controlloop/";
- File ruleFile = new File(resourceDir + File.separator + controllerName + ".drl");
+ var kmoduleFile = new File(resourceDir + "/META-INF/kmodule.xml");
+ var pomFile = new File("src/test/resources/" + controllerName + ".pom");
+ var resourceDir2 = resourceDir + "/org/onap/policy/controlloop/";
+ var ruleFile = new File(resourceDir + File.separator + controllerName + ".drl");
List<File> ruleFiles = Collections.singletonList(ruleFile);
installArtifact(kmoduleFile, pomFile, resourceDir2, ruleFiles);
@@ -183,7 +183,7 @@ public class Rules {
}
private ToscaPolicy getPolicyFromTemplate(String resourcePath, String policyName) throws CoderException {
- String policyJson = ResourceUtils.getResourceAsString(resourcePath);
+ var policyJson = ResourceUtils.getResourceAsString(resourcePath);
if (policyJson == null) {
throw new CoderException(new FileNotFoundException(resourcePath));
}
@@ -227,7 +227,7 @@ public class Rules {
* Get policy from file.
*/
public static ToscaPolicy getPolicyFromFile(String policyPath) throws CoderException {
- String policyJson = ResourceUtils.getResourceAsString(policyPath);
+ var policyJson = ResourceUtils.getResourceAsString(policyPath);
if (policyJson == null) {
throw new CoderException(new FileNotFoundException(policyPath));
}
@@ -267,7 +267,7 @@ public class Rules {
* Sets up Drools Logging for events of interest.
*/
private void setupDroolsLogging() {
- KieSession session = getKieSession();
+ var session = getKieSession();
session.addEventListener(new RuleListenerLogger());
session.addEventListener(new AgendaListenerLogger());
diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Topics.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Topics.java
index f71559acb..ff3abed48 100644
--- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Topics.java
+++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/Topics.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.
@@ -85,7 +85,7 @@ public class Topics {
*/
public void inject(String topicName, String file, String newText) {
try {
- String text = ResourceUtils.getResourceAsString(file);
+ var text = ResourceUtils.getResourceAsString(file);
if (text == null) {
throw new FileNotFoundException(file);
}