summaryrefslogtreecommitdiffstats
path: root/policy-core
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-09-28 04:58:26 -0400
committerPamela Dragosh <pdragosh@research.att.com>2018-10-01 10:28:44 -0400
commita0e0c7840f72392152a970d88a5a66d394c4a793 (patch)
tree1a1976844cb52020407b4d20e019f81ec25d5abf /policy-core
parent367f9d25434202a4fd6f5e54cb19196c7ec3d058 (diff)
Set drools-pdp checkstyle config
Fixed last remaining checkstyle issues along with setting the pom.xml to the correct path setting. Fixed forbidden summary fragments, not allowed to prepend summary with "This method returns" Issue-ID: POLICY-1153 Change-Id: I267842080494132a7b5507731e14f027a3f6fe44 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'policy-core')
-rw-r--r--policy-core/checkstyle-suppressions.xml30
-rw-r--r--policy-core/pom.xml40
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java22
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java52
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java (renamed from policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPI.java)6
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java12
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApiTest.java (renamed from policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPITest.java)8
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java16
8 files changed, 127 insertions, 59 deletions
diff --git a/policy-core/checkstyle-suppressions.xml b/policy-core/checkstyle-suppressions.xml
new file mode 100644
index 00000000..d771a027
--- /dev/null
+++ b/policy-core/checkstyle-suppressions.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2018 AT&T Technologies. 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.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+
+<suppressions>
+ <suppress checks="AbbreviationAsWordInName"
+ files="PolicyResourceLockFeatureAPI.java|PolicySessionFeatureAPI.java"
+ lines="1-9999"/>
+</suppressions>
diff --git a/policy-core/pom.xml b/policy-core/pom.xml
index 34a78a39..70df3745 100644
--- a/policy-core/pom.xml
+++ b/policy-core/pom.xml
@@ -124,4 +124,44 @@
<scope>test</scope>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <!-- Use Google Java Style Guide: https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
+ with minor changes -->
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
+ <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <excludes>
+ </excludes>
+ <suppressionsLocation>${project.baseUri}checkstyle-suppressions.xml</suppressionsLocation>
+ <consoleOutput>true</consoleOutput>
+ <failsOnViolation>true</failsOnViolation>
+ <violationSeverity>warning</violationSeverity>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java
index f2a084e4..2c5d87f8 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java
@@ -109,7 +109,7 @@ public class PolicyContainer implements Startable {
}
synchronized (containers) {
if (newReleaseId != null) {
- logger.info("Add a new kieContainer in containers: releaseId: {}", newReleaseId.toString());
+ logger.info("Add a new kieContainer in containers: releaseId: {}", newReleaseId);
} else {
logger.warn("input releaseId is null");
}
@@ -289,8 +289,8 @@ public class PolicyContainer implements Startable {
}
logger.info("activatePolicySession:new session was added in sessions with name {}", name);
}
- logger.info("activatePolicySession:session - " + (session == null ? "null" : session.getFullName())
- + " is returned.");
+ logger.info("activatePolicySession:session - {} is returned.",
+ session == null ? "null" : session.getFullName());
return session;
}
}
@@ -317,7 +317,7 @@ public class PolicyContainer implements Startable {
logger.warn("adoptKieSession:input kieSession is null");
throw new IllegalArgumentException("KieSession '" + name + "' is null " + getName());
} else {
- logger.info("adoptKieSession:name: " + name + " kieSession: " + kieSession);
+ logger.info("adoptKieSession:name: {} kieSession: {}", name, kieSession);
}
// fetch KieBase, and verify it belongs to this KieContainer
boolean match = false;
@@ -507,12 +507,12 @@ public class PolicyContainer implements Startable {
return rval;
}
- /*************************/
+ /*=======================*/
/* 'Startable' interface */
- /*************************/
+ /*=======================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public synchronized boolean start() {
@@ -537,7 +537,7 @@ public class PolicyContainer implements Startable {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public synchronized boolean stop() {
@@ -576,7 +576,7 @@ public class PolicyContainer implements Startable {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public synchronized void shutdown() {
@@ -594,15 +594,13 @@ public class PolicyContainer implements Startable {
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public boolean isAlive() {
return isStarted;
}
- /*************************/
-
/**
* This method is similar to 'shutdown', but it also frees any persistence resources as well.
*/
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java
index bb2148c0..958933fb 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java
@@ -232,12 +232,12 @@ public class PolicySession
}
}
- /***********************************/
+ /*=================================*/
/* 'AgendaEventListener' interface */
- /***********************************/
+ /*=================================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void afterMatchFired(AfterMatchFiredEvent event) {
@@ -249,7 +249,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event) {
@@ -261,7 +261,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void afterRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event) {
@@ -273,7 +273,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void agendaGroupPopped(AgendaGroupPoppedEvent event) {
@@ -285,7 +285,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void agendaGroupPushed(AgendaGroupPushedEvent event) {
@@ -297,7 +297,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
@@ -309,7 +309,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void beforeRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event) {
@@ -321,7 +321,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void beforeRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event) {
@@ -333,7 +333,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void matchCancelled(MatchCancelledEvent event) {
@@ -344,7 +344,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void matchCreated(MatchCreatedEvent event) {
@@ -354,12 +354,12 @@ public class PolicySession
}
}
- /****************************************/
+ /*======================================*/
/* 'RuleRuntimeEventListener' interface */
- /****************************************/
+ /*======================================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void objectDeleted(ObjectDeletedEvent event) {
@@ -370,7 +370,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void objectInserted(ObjectInsertedEvent event) {
@@ -381,7 +381,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void objectUpdated(ObjectUpdatedEvent event) {
@@ -390,7 +390,7 @@ public class PolicySession
+ ": AgendaEventListener.objectUpdated(" + event + ")");
}
}
-
+
/* ============================================================ */
/**
@@ -451,12 +451,12 @@ public class PolicySession
return "Session " + session.getFullName();
}
- /***************************/
+ /*=========================*/
/* 'ThreadModel' interface */
- /***************************/
+ /*=========================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void start() {
@@ -465,7 +465,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void stop() {
@@ -486,7 +486,7 @@ public class PolicySession
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void updated() {
@@ -494,12 +494,12 @@ public class PolicySession
thread.setName(getThreadName());
}
- /************************/
+ /*======================*/
/* 'Runnable' interface */
- /************************/
+ /*======================*/
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*/
@Override
public void run() {
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPI.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java
index 105d6ec9..66766453 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPI.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java
@@ -35,14 +35,14 @@ import org.onap.policy.drools.utils.OrderedServiceImpl;
* For instance, they may choose to implement an engine-wide locking scheme, or they may
* choose to implement a global locking scheme (e.g., through a shared DB).
*/
-public interface PolicyResourceLockFeatureAPI extends OrderedService {
+public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* 'FeatureAPI.impl.getList()' returns an ordered list of objects implementing the
* 'FeatureAPI' interface.
*/
- public static OrderedServiceImpl<PolicyResourceLockFeatureAPI> impl =
- new OrderedServiceImpl<>(PolicyResourceLockFeatureAPI.class);
+ public static OrderedServiceImpl<PolicyResourceLockFeatureApi> impl =
+ new OrderedServiceImpl<>(PolicyResourceLockFeatureApi.class);
/**
* Result of a requested operation.
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
index 3612b29d..33f4668c 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockManager.java
@@ -23,7 +23,7 @@ package org.onap.policy.drools.core.lock;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
-import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureAPI.OperResult;
+import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureApi.OperResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -184,7 +184,7 @@ public class PolicyResourceLockManager extends SimpleLockManager {
* @param defaultFunc default function
* @return {@code true} if success, {@code false} otherwise
*/
- private boolean doBoolIntercept(Function<PolicyResourceLockFeatureAPI, OperResult> interceptFunc,
+ private boolean doBoolIntercept(Function<PolicyResourceLockFeatureApi, OperResult> interceptFunc,
Supplier<Boolean> defaultFunc) {
OperResult result = doIntercept(OperResult.OPER_UNHANDLED, interceptFunc);
@@ -205,9 +205,9 @@ public class PolicyResourceLockManager extends SimpleLockManager {
* @return first non-null value returned by an implementer, <i>continueValue</i> if
* they all returned <i>continueValue</i>
*/
- private static <T> T doIntercept(T continueValue, Function<PolicyResourceLockFeatureAPI, T> func) {
+ private static <T> T doIntercept(T continueValue, Function<PolicyResourceLockFeatureApi, T> func) {
- for (PolicyResourceLockFeatureAPI impl : factory.getImplementers()) {
+ for (PolicyResourceLockFeatureApi impl : factory.getImplementers()) {
try {
T result = func.apply(impl);
if (result != continueValue) {
@@ -248,8 +248,8 @@ public class PolicyResourceLockManager extends SimpleLockManager {
*
* @return the list of feature implementers
*/
- public List<PolicyResourceLockFeatureAPI> getImplementers() {
- return PolicyResourceLockFeatureAPI.impl.getList();
+ public List<PolicyResourceLockFeatureApi> getImplementers() {
+ return PolicyResourceLockFeatureApi.impl.getList();
}
}
}
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPITest.java b/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApiTest.java
index 522a3f51..999ae50f 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureAPITest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApiTest.java
@@ -25,21 +25,21 @@ import static org.junit.Assert.assertFalse;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureAPI.OperResult;
+import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureApi.OperResult;
-public class PolicyResourceLockFeatureAPITest {
+public class PolicyResourceLockFeatureApiTest {
private static final String RESOURCE_ID = "the resource";
private static final String OWNER = "the owner";
- private PolicyResourceLockFeatureAPI api;
+ private PolicyResourceLockFeatureApi api;
/**
* set up.
*/
@Before
public void setUp() {
- api = new PolicyResourceLockFeatureAPI() {
+ api = new PolicyResourceLockFeatureApi() {
@Override
public int getSequenceNumber() {
return 0;
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java
index 962fb96a..8acafccf 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/lock/PolicyResourceLockManagerTest.java
@@ -41,7 +41,7 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureAPI.OperResult;
+import org.onap.policy.drools.core.lock.PolicyResourceLockFeatureApi.OperResult;
import org.onap.policy.drools.core.lock.PolicyResourceLockManager.Factory;
public class PolicyResourceLockManagerTest {
@@ -64,9 +64,9 @@ public class PolicyResourceLockManagerTest {
*/
private static Factory saveFactory;
- private PolicyResourceLockFeatureAPI impl1;
- private PolicyResourceLockFeatureAPI impl2;
- private List<PolicyResourceLockFeatureAPI> implList;
+ private PolicyResourceLockFeatureApi impl1;
+ private PolicyResourceLockFeatureApi impl2;
+ private List<PolicyResourceLockFeatureApi> implList;
private PolicyResourceLockManager mgr;
@@ -85,8 +85,8 @@ public class PolicyResourceLockManagerTest {
*/
@Before
public void setUp() {
- impl1 = mock(PolicyResourceLockFeatureAPI.class);
- impl2 = mock(PolicyResourceLockFeatureAPI.class);
+ impl1 = mock(PolicyResourceLockFeatureApi.class);
+ impl2 = mock(PolicyResourceLockFeatureApi.class);
initImplementer(impl1);
initImplementer(impl2);
@@ -97,7 +97,7 @@ public class PolicyResourceLockManagerTest {
PolicyResourceLockManager.setFactory(new Factory() {
@Override
- public List<PolicyResourceLockFeatureAPI> getImplementers() {
+ public List<PolicyResourceLockFeatureApi> getImplementers() {
return implList;
}
});
@@ -110,7 +110,7 @@ public class PolicyResourceLockManagerTest {
*
* @param impl implementer
*/
- private void initImplementer(PolicyResourceLockFeatureAPI impl) {
+ private void initImplementer(PolicyResourceLockFeatureApi impl) {
when(impl.beforeLock(anyString(), anyString(), anyInt())).thenReturn(OperResult.OPER_UNHANDLED);
when(impl.beforeRefresh(anyString(), anyString(), anyInt())).thenReturn(OperResult.OPER_UNHANDLED);
when(impl.beforeUnlock(anyString(), anyString())).thenReturn(OperResult.OPER_UNHANDLED);