diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2019-11-08 08:42:55 -0600 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2019-11-08 14:40:02 -0600 |
commit | f38687b040bec7b8556fb4bde229343831fa43fd (patch) | |
tree | 8c1706c077c8a45e6bf05423b5d2a6004bf81983 | |
parent | 0588d03bb8e9ea5faebf65d4af8e4bff735a96ae (diff) |
Miscellaneous code clean up
Issue-ID: POLICY-2203
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: I5731d4636bd2aaecbc486406298bcba1b19e8f4d
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
40 files changed, 226 insertions, 246 deletions
diff --git a/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureApi.java b/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureApi.java index 5be1c526..751ca28f 100644 --- a/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureApi.java +++ b/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureApi.java @@ -35,7 +35,7 @@ public interface ActiveStandbyFeatureApi extends OrderedService { * * @return String (resourceName) */ - public String getPdpdNowActive(); + String getPdpdNowActive(); /** * Returns the resourceName (PDP ID) for the Drools-PDP that is @@ -43,12 +43,12 @@ public interface ActiveStandbyFeatureApi extends OrderedService { * * @return String (resourceName) */ - public String getPdpdLastActive(); + String getPdpdLastActive(); /** * Returns the resourceName associated with this instance of the feature. * * @return String (resourceName) */ - public String getResourceName(); + String getResourceName(); } diff --git a/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureApi.java b/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureApi.java index d2c7b390..bdac688e 100644 --- a/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureApi.java +++ b/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureApi.java @@ -53,7 +53,7 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * problem that has resolved). * @throws AllSeemsWellException exception */ - public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg) + void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg) throws AllSeemsWellException; /** @@ -61,35 +61,35 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * * @param stateChangeObserver observer */ - public void addObserver(Observer stateChangeObserver); + void addObserver(Observer stateChangeObserver); /** * Returns the X.731 Administrative State for this resource. * * @return String (locked, unlocked) */ - public String getAdminState(); + String getAdminState(); /** * Returns the X.731 Operational State for this resource. * * @return String (enabled, disabled) */ - public String getOpState(); + String getOpState(); /** * Returns the X.731 Availability Status for this resource. * * @return String (failed; dependency; dependency,failed) */ - public String getAvailStatus(); + String getAvailStatus(); /** * Returns the X.731 Standby Status for this resource. * * @return String (providingservice, hotstandby or coldstandby) */ - public String getStandbyStatus(); + String getStandbyStatus(); /** * Returns the X.731 Standby Status for the named resource @@ -97,7 +97,7 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * @param resourceName the resource name * @return String (providingservice, hotstandby or coldstandby) */ - public String getStandbyStatus(String resourceName); + String getStandbyStatus(String resourceName); /** * This method moves the X.731 Operational State for the named resource into a value of disabled @@ -107,7 +107,7 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * @param resourceName resource name * @throws Exception exception */ - public void disableFailed(String resourceName) throws Exception; + void disableFailed(String resourceName) throws Exception; /** * This method moves the X.731 Operational State for this resource into a value of disabled and @@ -116,7 +116,7 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * * @throws Exception exception */ - public void disableFailed() throws Exception; + void disableFailed() throws Exception; /** * This method moves the X.731 Standby Status for this resource from hotstandby to @@ -126,7 +126,7 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * * @throws Exception exception */ - public void promote() throws Exception; + void promote() throws Exception; /** * This method moves the X.731 Standby Status for this resource from providingservice to @@ -135,7 +135,7 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * * @throws Exception exception */ - public void demote() throws Exception; + void demote() throws Exception; /** * Returns the resourceName associated with this instance of the @@ -143,7 +143,7 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * * @return String (resourceName) */ - public String getResourceName(); + String getResourceName(); /** * This Lockable method will lock the StateManagement object Admin state. @@ -151,7 +151,7 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * @return true if successful, false otherwise */ @Override - public boolean lock(); + boolean lock(); /** * This Lockable method will unlock the StateManagement object Admin state. @@ -159,7 +159,7 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * @return true if successfull, false otherwise */ @Override - public boolean unlock(); + boolean unlock(); /** * This Lockable method indicates the Admin state StateManagement object. @@ -167,5 +167,5 @@ public interface StateManagementFeatureApi extends OrderedService, Lockable { * @return true if locked, false otherwise */ @Override - public boolean isLocked(); + boolean isLocked(); } diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java index 8fada968..12c75929 100644 --- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java +++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdp.java @@ -24,27 +24,27 @@ import java.util.Date; public interface DroolsPdp { - public String getPdpId(); + String getPdpId(); - public boolean isDesignated(); + boolean isDesignated(); - public int getPriority(); + int getPriority(); - public Date getUpdatedDate(); + Date getUpdatedDate(); - public void setDesignated(boolean isDesignated); + void setDesignated(boolean isDesignated); - public void setUpdatedDate(Date updatedDate); + void setUpdatedDate(Date updatedDate); - public int comparePriority(DroolsPdp other); + int comparePriority(DroolsPdp other); - public int comparePriority(DroolsPdp other,String previousSite); + int comparePriority(DroolsPdp other, String previousSite); - public String getSite(); + String getSite(); - public void setSite(String site); + void setSite(String site); - public Date getDesignatedDate(); + Date getDesignatedDate(); - public void setDesignatedDate(Date designatedDate); + void setDesignatedDate(Date designatedDate); } diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java index fdb87378..6e06272c 100644 --- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java +++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsConnector.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * feature-active-standby-management * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. * 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. @@ -26,39 +26,39 @@ public interface DroolsPdpsConnector { //return a list of PDPs, NOT including this PDP - public Collection<DroolsPdp> getDroolsPdps(); + Collection<DroolsPdp> getDroolsPdps(); - public void update(DroolsPdp pdp); + void update(DroolsPdp pdp); - //determines if the DroolsPdp parameter is considered "current" or expired + //determines if the DroolsPdp parameter is considered "current" or expired //(has it been too long since the Pdp sent an update) - public boolean isPdpCurrent(DroolsPdp pdp); + boolean isPdpCurrent(DroolsPdp pdp); // Updates DESIGNATED boolean in PDP record. - public void setDesignated(DroolsPdp pdp, boolean designated); + void setDesignated(DroolsPdp pdp, boolean designated); // Marks droolspdpentity.DESIGNATED=false, so another PDP-D will go active. - public void standDownPdp(String pdpId); + void standDownPdp(String pdpId); // This is used in a JUnit test environment to manually // insert a PDP - public void insertPdp(DroolsPdp pdp); + void insertPdp(DroolsPdp pdp); // This is used in a JUnit test environment to manually // delete a PDP - public void deletePdp(String pdpId); + void deletePdp(String pdpId); // This is used in a JUnit test environment to manually // clear the droolspdpentity table. - public void deleteAllPdps(); + void deleteAllPdps(); // This is used in a JUnit test environment to manually // get a PDP - public DroolsPdpEntity getPdp(String pdpId); + DroolsPdpEntity getPdp(String pdpId); // Used by DroolsPdpsElectionHandler to determine if the currently designated // PDP has failed. - public boolean hasDesignatedPdpFailed(Collection<DroolsPdp> pdps); + boolean hasDesignatedPdpFailed(Collection<DroolsPdp> pdps); } diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java index 5308cbe6..37382e81 100644 --- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java +++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/DroolsPdpsElectionHandler.java @@ -49,14 +49,8 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker { */ private static DroolsPdp myPdp; - private DesignationWaiter designationWaiter; - private Timer updateWorker; - private Timer waitTimer; private Date waitTimerLastRunDate; - // The interval between checks of the DesignationWaiter to be sure it is running. - private int pdpCheckInterval; - // The interval between runs of the DesignationWaiter private int pdpUpdateInterval; @@ -100,12 +94,14 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker { this.pdpsConnector = pdps; DroolsPdpsElectionHandler.myPdp = myPdp; this.isDesignated = false; - pdpCheckInterval = 3000; + + // The interval between checks of the DesignationWaiter to be sure it is running. + int pdpCheckInterval = 3000; try { pdpCheckInterval = Integer.parseInt(ActiveStandbyProperties.getProperty( ActiveStandbyProperties.PDP_CHECK_INVERVAL)); } catch (Exception e) { - logger.error("Could not get pdpCheckInterval property. Using default {}",pdpCheckInterval, e); + logger.error("Could not get pdpCheckInterval property. Using default {}", pdpCheckInterval, e); } pdpUpdateInterval = 2000; try { @@ -122,7 +118,7 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker { // Create the timer which will update the updateDate in DroolsPdpEntity table. // This is the heartbeat - updateWorker = Factory.getInstance().makeTimer(); + Timer updateWorker = Factory.getInstance().makeTimer(); // Schedule the TimerUpdateClass to run at 100 ms and run at pdpCheckInterval ms thereafter // NOTE: The first run of the TimerUpdateClass results in myPdp being added to the @@ -130,12 +126,12 @@ public class DroolsPdpsElectionHandler implements ThreadRunningChecker { updateWorker.scheduleAtFixedRate(new TimerUpdateClass(), 100, pdpCheckInterval); // Create the timer which will run the election algorithm - waitTimer = Factory.getInstance().makeTimer(); + Timer waitTimer = Factory.getInstance().makeTimer(); // Schedule it to start in startMs ms // (so it will run after the updateWorker and run at pdpUpdateInterval ms thereafter long startMs = getDWaiterStartMs(); - designationWaiter = new DesignationWaiter(); + DesignationWaiter designationWaiter = new DesignationWaiter(); waitTimer.scheduleAtFixedRate(designationWaiter, startMs, pdpUpdateInterval); waitTimerLastRunDate = new Date(nowMs + startMs); diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifier.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifier.java index 735e3a2a..f350bb0a 100644 --- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifier.java +++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifier.java @@ -64,7 +64,6 @@ public class PmStandbyStateChangeNotifier extends StateChangeNotifier { // get an instance of logger private static final Logger logger = LoggerFactory.getLogger(PmStandbyStateChangeNotifier.class); private Timer delayActivateTimer; - private int pdpUpdateInterval; private boolean isWaitingForActivation; private long startTimeWaitingForActivationMs; private long waitInterval; @@ -81,8 +80,8 @@ public class PmStandbyStateChangeNotifier extends StateChangeNotifier { * */ public PmStandbyStateChangeNotifier() { - pdpUpdateInterval = - Integer.parseInt(ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_UPDATE_INTERVAL)); + int pdpUpdateInterval = + Integer.parseInt(ActiveStandbyProperties.getProperty(ActiveStandbyProperties.PDP_UPDATE_INTERVAL)); isWaitingForActivation = false; startTimeWaitingForActivationMs = currentTime.getMillis(); // delay the activate so the DesignatedWaiter can run twice - give it an extra 2 seconds diff --git a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java index 373c373c..d359b5a6 100644 --- a/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java +++ b/feature-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ThreadRunningChecker.java @@ -22,6 +22,6 @@ package org.onap.policy.drools.activestandby; @FunctionalInterface public interface ThreadRunningChecker { - public void checkThreadStatus(); + void checkThreadStatus(); } diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java index cb7e4c3f..2616ac34 100644 --- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java +++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java @@ -20,6 +20,7 @@ package org.onap.policy.drools.activestandby; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -262,7 +263,7 @@ public class AllSeemsWellTest { DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId); logger.debug("testAllSeemsWell: After insertion, PDP={} has DESIGNATED={}", thisPdpId, droolsPdpEntity.isDesignated()); - assertTrue(droolsPdpEntity.isDesignated() == false); + assertFalse(droolsPdpEntity.isDesignated()); logger.debug("testAllSeemsWell: Instantiating stateManagement object"); StateManagement sm = new StateManagement(emfXacml, "dummy"); @@ -311,7 +312,7 @@ public class AllSeemsWellTest { droolsPdpEntity = conn.getPdp(thisPdpId); logger.debug("testAllSeemsWell: After sm.demote() invoked, DESIGNATED= {} " + "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId); - assertTrue(droolsPdpEntity.isDesignated() == true); + assertTrue(droolsPdpEntity.isDesignated()); String standbyStatus = smf.getStandbyStatus(thisPdpId); logger.debug("testAllSeemsWell: After demotion, PDP= {} " + "has standbyStatus= {}", thisPdpId, standbyStatus); diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java index 32648eb2..f51d620f 100644 --- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java +++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java @@ -20,6 +20,7 @@ package org.onap.policy.drools.activestandby; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -688,7 +689,7 @@ public class StandbyStateManagementTest { DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId); logger.debug("testColdStandby: After insertion, DESIGNATED= {} " + "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId); - assertTrue(droolsPdpEntity.isDesignated() == true); + assertTrue(droolsPdpEntity.isDesignated()); /* * When the Standby Status changes (from providingservice) to hotstandby @@ -760,7 +761,7 @@ public class StandbyStateManagementTest { droolsPdpEntity = conn.getPdp(thisPdpId); logger.debug("testColdStandby: After lock sm.lock() invoked, " + "DESIGNATED= {} for PDP={}", droolsPdpEntity.isDesignated(), thisPdpId); - assertTrue(droolsPdpEntity.isDesignated() == false); + assertFalse(droolsPdpEntity.isDesignated()); logger.debug("\n\ntestColdStandby: Exiting\n\n"); } @@ -795,7 +796,7 @@ public class StandbyStateManagementTest { DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId); logger.debug("testHotStandby1: After insertion, PDP={} has DESIGNATED={}", thisPdpId, droolsPdpEntity.isDesignated()); - assertTrue(droolsPdpEntity.isDesignated() == false); + assertFalse(droolsPdpEntity.isDesignated()); logger.debug("testHotStandby1: Instantiating stateManagement object"); StateManagement sm = new StateManagement(emfx, "dummy"); @@ -842,7 +843,7 @@ public class StandbyStateManagementTest { droolsPdpEntity = conn.getPdp(thisPdpId); logger.debug("testHotStandby1: After sm.demote() invoked, DESIGNATED= {} " + "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId); - assertTrue(droolsPdpEntity.isDesignated() == true); + assertTrue(droolsPdpEntity.isDesignated()); String standbyStatus = smf.getStandbyStatus(thisPdpId); logger.debug("testHotStandby1: After demotion, PDP= {} " + "has standbyStatus= {}", thisPdpId, standbyStatus); @@ -883,7 +884,7 @@ public class StandbyStateManagementTest { DroolsPdpEntity droolsPdpEntity = conn.getPdp(activePdpId); logger.info("testHotStandby2: After insertion, PDP= {}, which is " + "not current, has DESIGNATED= {}", activePdpId, droolsPdpEntity.isDesignated()); - assertTrue(droolsPdpEntity.isDesignated() == true); + assertTrue(droolsPdpEntity.isDesignated()); /* * Promote the designated PDP. @@ -917,7 +918,7 @@ public class StandbyStateManagementTest { droolsPdpEntity = conn.getPdp(thisPdpId); logger.info("testHotStandby2: After insertion, PDP={} " + "has DESIGNATED= {}", thisPdpId, droolsPdpEntity.isDesignated()); - assertTrue(droolsPdpEntity.isDesignated() == false); + assertFalse(droolsPdpEntity.isDesignated()); // Now we want to create a StateManagementFeature and initialize it. It will be @@ -976,7 +977,7 @@ public class StandbyStateManagementTest { logger.info("testHotStandby2: After demoting PDP={}" + ", DESIGNATED= {}" + " for PDP= {}", activePdpId, droolsPdpEntity.isDesignated(), thisPdpId); - assertTrue(droolsPdpEntity.isDesignated() == true); + assertTrue(droolsPdpEntity.isDesignated()); standbyStatus = sm2.getStandbyStatus(thisPdpId); logger.info("testHotStandby2: After demoting PDP={}" + ", PDP={} has standbyStatus= {}", @@ -1032,7 +1033,7 @@ public class StandbyStateManagementTest { DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId); logger.debug("testLocking1: After insertion, PDP= {} has DESIGNATED= {}", thisPdpId, droolsPdpEntity.isDesignated()); - assertTrue(droolsPdpEntity.isDesignated() == true); + assertTrue(droolsPdpEntity.isDesignated()); logger.debug("testLocking1: Instantiating stateManagement object"); StateManagement smDummy = new StateManagement(emfx, "dummy"); @@ -1237,7 +1238,7 @@ public class StandbyStateManagementTest { DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId); logger.debug("testLocking2: After insertion, PDP= {} has DESIGNATED= {}", thisPdpId, droolsPdpEntity.isDesignated()); - assertTrue(droolsPdpEntity.isDesignated() == true); + assertTrue(droolsPdpEntity.isDesignated()); logger.debug("testLocking2: Instantiating stateManagement object and promoting PDP={}", thisPdpId); StateManagement smDummy = new StateManagement(emfx, "dummy"); @@ -1281,7 +1282,7 @@ public class StandbyStateManagementTest { droolsPdpEntity = conn.getPdp(standbyPdpId); logger.debug("testLocking2: After insertion, PDP={} has DESIGNATED= {}", standbyPdpId, droolsPdpEntity.isDesignated()); - assertTrue(droolsPdpEntity.isDesignated() == false); + assertFalse(droolsPdpEntity.isDesignated()); logger.debug("testLocking2: Demoting PDP= {}", standbyPdpId); final StateManagement sm2 = new StateManagement(emfx, standbyPdpId); @@ -1347,8 +1348,7 @@ public class StandbyStateManagementTest { } logger.debug("testLocking2: Verifying designated status for PDP= {}", standbyPdpId); - boolean standbyPdpDesignated = conn.getPdp(standbyPdpId).isDesignated(); - assertTrue(standbyPdpDesignated == false); + assertFalse(conn.getPdp(standbyPdpId).isDesignated()); logger.debug("\n\ntestLocking2: Exiting\n\n"); } diff --git a/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java b/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java index 8c3e1c79..ecbb320d 100755 --- a/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java +++ b/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java @@ -75,10 +75,6 @@ public class ControllerLoggingTest { private static final String TEST_TOPIC = "test-topic"; private static final String TEST_SERVER = "http://test.com"; - /** - * These are used for sending PDPD configuration notifications to a policy controller. - */ - private static Properties controllerProps = null; private static String message = null; private static PdpdConfiguration pdpdNotification = null; private static PolicyController policyController = null; @@ -110,14 +106,15 @@ public class ControllerLoggingTest { KieUtils.installArtifact(Paths.get(JUNIT_KMODULE_PATH).toFile(), Paths.get(JUNIT_KMODULE_POM_PATH).toFile(), JUNIT_KJAR_DRL_PATH, Paths.get(JUNIT_KMODULE_DRL_PATH).toFile()); - controllerProps = new Properties(); + // These properties are used for sending PDPD configuration notifications to a policy controller. + Properties controllerProps = new Properties(); controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME); controllerProps.put(DroolsPropertyConstants.RULES_GROUPID, TEST_GROUP_ID); controllerProps.put(DroolsPropertyConstants.RULES_ARTIFACTID, TEST_ARTIFACT_ID); controllerProps.put(DroolsPropertyConstants.RULES_VERSION, TEST_VERSION); - policyController = PolicyEngineConstants.getManager().createPolicyController(TEST_CONTROLLER_NAME, - controllerProps); + policyController = + PolicyEngineConstants.getManager().createPolicyController(TEST_CONTROLLER_NAME, controllerProps); message = "{\"requestID\":\"38adde30-cc22-11e8-a8d5-f2801f1b9fd1\",\"entity\":\"controller\",\"controllers\":" + "[{\"name\":\"test-controller\",\"drools\":{\"groupId\":\"org.onap.policy.drools.test\"," diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java index b1b28f79..b7297998 100644 --- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java +++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java @@ -156,5 +156,5 @@ public interface HealthCheck extends Startable { * * @return a report */ - public Reports healthCheck(); + Reports healthCheck(); } diff --git a/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcFilterFeatureTest.java b/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcFilterFeatureTest.java index 51ff3e92..a8e0cf16 100755 --- a/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcFilterFeatureTest.java +++ b/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcFilterFeatureTest.java @@ -57,11 +57,6 @@ public class MdcFilterFeatureTest { private static final String TEST_TOPIC_B = "org.onap.policy.test-topic-b"; /** - * The mock PolicyController to be used for the junits. - */ - private PolicyController controller; - - /** * The mock properties to be used for the junits. */ private Properties props; @@ -85,12 +80,14 @@ public class MdcFilterFeatureTest { message = new String(Files.readAllBytes(Paths.get("src/test/resources/onset.json"))); props = mockFeatureProperties(); - controller = mock(PolicyController.class); props.setProperty("dmaap.source.topics", TEST_TOPIC_A); props.setProperty("dmaap.source.topics." + TEST_TOPIC_A + ".servers", "http://testing123.com/"); props.setProperty("noop.sink.topics", TEST_TOPIC_B); + // The mock PolicyController to be used for the junits. + PolicyController controller = mock(PolicyController.class); + List<TopicSource> topicSources = TopicEndpointManager.getManager().addTopicSources(props); doReturn(topicSources).when(controller).getTopicSources(); diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.java index b16f44ad..f0d3b267 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. @@ -29,5 +29,5 @@ public interface CancellableScheduledTask { /** * Cancels the scheduled task. */ - public void cancel(); + void cancel(); } diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java index d4704afe..da8a918f 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java @@ -339,7 +339,7 @@ public class PoolingFeature implements PolicyEngineFeatureApi, PolicyControllerF * @return {@code true} if the request was handled by the manager, {@code false} otherwise * @throws PoolingFeatureException feature exception */ - public boolean apply(PoolingManagerImpl mgr) throws PoolingFeatureException; + boolean apply(PoolingManagerImpl mgr) throws PoolingFeatureException; } /** diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java index e8e0174d..e3576b8f 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. * 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. @@ -33,108 +33,108 @@ public interface PoolingManager { /** * Gets the properties used to configure the manager. - * + * * @return pooling properties */ - public PoolingProperties getProperties(); + PoolingProperties getProperties(); /** * Gets the host id. - * + * * @return the host id */ - public String getHost(); + String getHost(); /** * Gets the name of the internal DMaaP topic used by this manager to communicate with * its other hosts. - * + * * @return the name of the internal DMaaP topic */ - public String getTopic(); + String getTopic(); /** * Starts distributing requests according to the given bucket assignments. - * + * * @param assignments must <i>not</i> be {@code null} */ - public void startDistributing(BucketAssignments assignments); + void startDistributing(BucketAssignments assignments); /** * Gets the current bucket assignments. - * + * * @return the current bucket assignments, or {@code null} if no assignments have been * made */ - public BucketAssignments getAssignments(); + BucketAssignments getAssignments(); /** * Publishes a message to the internal topic on the administrative channel. - * + * * @param msg message to be published */ - public void publishAdmin(Message msg); + void publishAdmin(Message msg); /** * Publishes a message to the internal topic on a particular channel. - * + * * @param channel channel on which the message should be published * @param msg message to be published */ - public void publish(String channel, Message msg); + void publish(String channel, Message msg); /** * Handles a {@link Forward} event that was received from the internal topic. - * + * * @param event event */ - public void handle(Forward event); + void handle(Forward event); /** * Schedules a timer to fire after a delay. - * + * * @param delayMs delay, in milliseconds * @param task task * @return a new scheduled task */ - public CancellableScheduledTask schedule(long delayMs, StateTimerTask task); + CancellableScheduledTask schedule(long delayMs, StateTimerTask task); /** * Schedules a timer to fire repeatedly. - * + * * @param initialDelayMs initial delay, in milliseconds * @param delayMs delay, in milliseconds * @param task task * @return a new scheduled task */ - public CancellableScheduledTask scheduleWithFixedDelay(long initialDelayMs, long delayMs, StateTimerTask task); + CancellableScheduledTask scheduleWithFixedDelay(long initialDelayMs, long delayMs, StateTimerTask task); /** * Transitions to the "start" state. - * + * * @return the new state */ - public State goStart(); + State goStart(); /** * Transitions to the "query" state. - * + * * @return the new state */ - public State goQuery(); + State goQuery(); /** * Transitions to the "active" state. - * + * * @return the new state */ - public State goActive(); + State goActive(); /** * Transitions to the "inactive" state. - * + * * @return the new state */ - public State goInactive(); + State goInactive(); } diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/Extractor.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/Extractor.java index 38d440cb..5e02d602 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/Extractor.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/extractor/Extractor.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. * 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. @@ -28,9 +28,9 @@ public interface Extractor { /** * Extracts an object contained within another object. - * + * * @param object object from which to extract the contained object * @return the extracted value, or {@code null} if it cannot be extracted */ - public Object extract(Object object); + Object extract(Object object); } diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.java index 346d4496..e4607f81 100644 --- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.java +++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. * 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. @@ -28,9 +28,9 @@ public interface StateTimerTask { /** * Fires the timer. - * + * * @return the new state, or {@code null} if the state is unchanged */ - public State fire(); + State fire(); } diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java index 5768e1d8..d51e61e6 100644 --- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java +++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java @@ -1105,6 +1105,6 @@ public class FeatureTest { @FunctionalInterface private static interface VoidFunction { - public void apply(); + void apply(); } } diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java index a711a7e9..5293b794 100644 --- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java +++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java @@ -95,7 +95,6 @@ public class PoolingManagerImplTest { */ private Queue<ScheduledFuture<?>> futures; - private Properties plainProps; private PoolingProperties poolProps; private ListeningController controller; private ClassExtractors extractors; @@ -111,12 +110,12 @@ public class PoolingManagerImplTest { /** * Setup. - * + * * @throws Exception throws exception */ @Before public void setUp() throws Exception { - plainProps = new Properties(); + Properties plainProps = new Properties(); poolProps = mock(PoolingProperties.class); when(poolProps.getSource()).thenReturn(plainProps); diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTest.java index c277a00f..0bf087a3 100644 --- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTest.java +++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/extractor/ClassExtractorsTest.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 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. * 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. @@ -412,7 +412,7 @@ public class ClassExtractorsTest { */ private static interface WithString { - public String getStrValue(); + String getStrValue(); } /** diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.java index 19e7ab0b..86247835 100644 --- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.java +++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.java @@ -207,7 +207,7 @@ public abstract class SupportBasicMessageTester<T extends Message> { /** * Verifies that fields are set as expected by {@link #makeValidMessage()}. - * + * * @param msg message whose fields are to be validated */ public void testValidFields(T msg) { @@ -217,7 +217,7 @@ public abstract class SupportBasicMessageTester<T extends Message> { /** * Function that updates a message. - * + * * @param <T> type of Message the function updates */ @FunctionalInterface @@ -225,15 +225,15 @@ public abstract class SupportBasicMessageTester<T extends Message> { /** * Updates a message. - * + * * @param msg message to be updated */ - public void update(T msg); + void update(T msg); } /** * Function that updates a single field within a message. - * + * * @param <T> type of Message the function updates */ @FunctionalInterface @@ -241,10 +241,10 @@ public abstract class SupportBasicMessageTester<T extends Message> { /** * Updates a field within a message. - * + * * @param msg message to be updated * @param newValue new field value */ - public void update(T msg, String newValue); + void update(T msg, String newValue); } } diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSession.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSession.java index e8b50817..3b3c942d 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSession.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSession.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * feature-session-persistence * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. * 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. @@ -24,19 +24,19 @@ import java.util.Date; public interface DroolsSession { - public String getSessionName(); - - public void setSessionName(String sessionName); - - public long getSessionId(); - - public void setSessionId(long sessionId); - - public Date getCreatedDate(); - - public void setCreatedDate(Date createdDate); - - public Date getUpdatedDate(); - - public void setUpdatedDate(Date updatedDate); + String getSessionName(); + + void setSessionName(String sessionName); + + long getSessionId(); + + void setSessionId(long sessionId); + + Date getCreatedDate(); + + void setCreatedDate(Date createdDate); + + Date getUpdatedDate(); + + void setUpdatedDate(Date updatedDate); } diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionConnector.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionConnector.java index 3a8885f8..4656f9fd 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionConnector.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/DroolsSessionConnector.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * feature-session-persistence * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. * 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. @@ -26,12 +26,12 @@ public interface DroolsSessionConnector { * @param sessName session name * @return a session, or {@code null} if it is not found */ - public DroolsSession get(String sessName); + DroolsSession get(String sessName); /** * Replaces a session, adding it if it does not exist. * @param sess session to be replaced */ - public void replace(DroolsSession sess); + void replace(DroolsSession sess); } diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java index 38e3ec23..40918312 100644 --- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java +++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/GenSchema.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-session-persistence * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. @@ -34,8 +34,6 @@ public class GenSchema { private static final Logger logger = LoggerFactory.getLogger(PersistenceFeatureTest.class); - private EntityManagerFactory emf; - /** * Opens the EMF, which generates the schema, as a side-effect. * @@ -47,9 +45,7 @@ public class GenSchema { propMap.put("javax.persistence.jdbc.driver", "org.h2.Driver"); propMap.put("javax.persistence.jdbc.url", "jdbc:h2:mem:JpaDroolsSessionConnectorTest"); - emf = Persistence.createEntityManagerFactory("schemaDroolsPU", propMap); - - emf.close(); + Persistence.createEntityManagerFactory("schemaDroolsPU", propMap).close(); } /** diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java index 1bab1977..e15f57ce 100644 --- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java +++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java @@ -114,7 +114,6 @@ public class PersistenceFeatureTest { private KieSessionConfiguration kiecfg; private KieBase kiebase; private KieStoreServices kiestore; - private KieContainer kiecont; private TransactionManager transmgr; private UserTransaction usertrans; private TransactionSynchronizationRegistry transreg; @@ -166,7 +165,6 @@ public class PersistenceFeatureTest { kiecfg = mock(KieSessionConfiguration.class); kiebase = mock(KieBase.class); kiestore = mock(KieStoreServices.class); - kiecont = mock(KieContainer.class); transmgr = mock(TransactionManager.class); usertrans = mock(UserTransaction.class); transreg = mock(TransactionSynchronizationRegistry.class); @@ -176,7 +174,7 @@ public class PersistenceFeatureTest { emfCount = 0; jpaCount = 0; propName = null; - + feat = new PersistenceFeatureImpl(); props.putAll(stdprops); @@ -188,6 +186,7 @@ public class PersistenceFeatureTest { when(kiesvc.getStoreServices()).thenReturn(kiestore); when(kiesvc.newKieSessionConfiguration()).thenReturn(kiecfg); + KieContainer kiecont = mock(KieContainer.class); when(polcont.getKieContainer()).thenReturn(kiecont); when(polsess.getPolicyContainer()).thenReturn(polcont); diff --git a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java index 0a4ef931..3ae4d594 100644 --- a/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java +++ b/feature-test-transaction/src/main/java/org/onap/policy/drools/testtransaction/TestTransaction.java @@ -30,12 +30,12 @@ public interface TestTransaction { * * @param controller policy controller */ - public void register(PolicyController controller); + void register(PolicyController controller); /** * unregisters a controller for monitoring test transactions. * * @param controller policy controller */ - public void unregister(PolicyController controller); + void unregister(PolicyController controller); } 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 c2b72fb5..69ca87cb 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 @@ -382,19 +382,19 @@ public class PolicySession /** * Start the thread or threads that do the 'KieSession' processing. */ - public void start(); + void start(); /** * Stop the thread or threads that do the 'KieSession' processing. */ - public void stop(); + void stop(); /** * This method is called to notify the running session that * 'KieContainer.updateToVersion(...)' has been called (meaning the * full name of this session has changed). */ - public default void updated() { + default void updated() { } } diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureApi.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureApi.java index f68747dd..181fbe55 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureApi.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureApi.java @@ -40,7 +40,7 @@ public interface PolicySessionFeatureApi extends OrderedService { * @param args standard 'main' arguments, which are currently ignored * @param configDir the relative directory containing configuration files */ - public default void globalInit(String[] args, String configDir) {} + default void globalInit(String[] args, String configDir) {} /** * This method is used to create a 'KieSession' as part of a @@ -57,7 +57,7 @@ public interface PolicySessionFeatureApi extends OrderedService { * (this depends on the capabilities and state of the object implementing * this interface) */ - public default KieSession activatePolicySession(PolicyContainer policyContainer, String name, String kieBaseName) { + default KieSession activatePolicySession(PolicyContainer policyContainer, String name, String kieBaseName) { return null; } @@ -67,13 +67,13 @@ public interface PolicySessionFeatureApi extends OrderedService { * * @param policySession the new 'PolicySession' instance */ - public default void newPolicySession(PolicySession policySession) {} + default void newPolicySession(PolicySession policySession) {} /** * This method is called to select the 'ThreadModel' instance associated * with a 'PolicySession' instance. */ - public default PolicySession.ThreadModel selectThreadModel(PolicySession session) { + default PolicySession.ThreadModel selectThreadModel(PolicySession session) { return null; } @@ -88,7 +88,7 @@ public interface PolicySessionFeatureApi extends OrderedService { * @return 'true' if this feature is handling the operation, * and 'false' if not. */ - public default boolean insertDrools(PolicySession session, Object object) { + default boolean insertDrools(PolicySession session, Object object) { return false; } @@ -98,7 +98,7 @@ public interface PolicySessionFeatureApi extends OrderedService { * @param policySession the 'PolicySession' object that wrapped the * 'KieSession' */ - public default void disposeKieSession(PolicySession policySession) {} + default void disposeKieSession(PolicySession policySession) {} /** * This method is called after 'KieSession.destroy()' is called. @@ -106,5 +106,5 @@ public interface PolicySessionFeatureApi extends OrderedService { * @param policySession the 'PolicySession' object that wrapped the * 'KieSession' */ - public default void destroyKieSession(PolicySession policySession) {} + default void destroyKieSession(PolicySession policySession) {} } diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmxMBean.java b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmxMBean.java index d2c05f85..390e00e7 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmxMBean.java +++ b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmxMBean.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * policy-core * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 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. * 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. @@ -22,7 +22,7 @@ package org.onap.policy.drools.core.jmx; public interface PdpJmxMBean { - public long getRulesFired(); - - public long getUpdates(); + long getRulesFired(); + + long getUpdates(); } 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 bbf7d229..905e31af 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 @@ -50,6 +50,6 @@ public interface PolicyResourceLockManager extends Startable, Lockable { * {@code false} otherwise * @return a new lock */ - public Lock createLock(String resourceId, String ownerKey, int holdSec, LockCallback callback, - boolean waitForLock); + Lock createLock(String resourceId, String ownerKey, int holdSec, LockCallback callback, + boolean waitForLock); } diff --git a/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java b/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java index babc0413..a5d577a6 100644 --- a/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java +++ b/policy-core/src/main/java/org/onap/policy/drools/util/KieUtils.java @@ -24,7 +24,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -50,8 +49,6 @@ import org.slf4j.LoggerFactory; */ public class KieUtils { - private static final Logger logger = LoggerFactory.getLogger(KieUtils.class); - private KieUtils() { // Utility class } diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java index dd654b1d..8e78b077 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java @@ -137,7 +137,7 @@ public interface DroolsController extends Startable, Lockable { * @param modelHash the hash for the model * @return true it owns it */ - boolean ownsCoder(Class<? extends Object> coderClass, int modelHash); + boolean ownsCoder(Class<?> coderClass, int modelHash); /** * fetches a class from the model. diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java index b641f24a..7652a671 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java @@ -43,8 +43,8 @@ public interface DroolsControllerFactory { * @throws IllegalArgumentException with invalid parameters * @throws LinkageError Failure to link rules and models in Drools Libraries */ - public DroolsController build(Properties properties, List<? extends TopicSource> eventSources, - List<? extends TopicSink> eventSinks) throws LinkageError; + DroolsController build(Properties properties, List<? extends TopicSource> eventSources, + List<? extends TopicSink> eventSinks) throws LinkageError; /** * Explicit construction of a Drools Controller. @@ -59,33 +59,33 @@ public interface DroolsControllerFactory { * @throws IllegalArgumentException with invalid parameters * @throws LinkageError Failure to link rules and models in Drools Libraries */ - public DroolsController build(String groupId, String artifactId, String version, - List<TopicCoderFilterConfiguration> decoderConfigurations, - List<TopicCoderFilterConfiguration> encoderConfigurations) throws LinkageError; + DroolsController build(String groupId, String artifactId, String version, + List<TopicCoderFilterConfiguration> decoderConfigurations, + List<TopicCoderFilterConfiguration> encoderConfigurations) throws LinkageError; /** * Releases the Drools Controller from operation. * * @param controller the Drools Controller to shut down */ - public void shutdown(DroolsController controller); + void shutdown(DroolsController controller); /** * Disables all Drools Controllers from operation. */ - public void shutdown(); + void shutdown(); /** * Destroys and releases resources for a Drools Controller. * * @param controller the Drools Controller to destroy */ - public void destroy(DroolsController controller); + void destroy(DroolsController controller); /** * Destroys all Drools Controllers. */ - public void destroy(); + void destroy(); /** * Gets the Drools Controller associated with the maven group and artifact id. @@ -97,12 +97,12 @@ public interface DroolsControllerFactory { * @return the Drools Controller * @throws IllegalArgumentException with invalid parameters */ - public DroolsController get(String groupId, String artifactId, String version); + DroolsController get(String groupId, String artifactId, String version); /** * returns the current inventory of Drools Controllers. * * @return a list of Drools Controllers */ - public List<DroolsController> inventory(); + List<DroolsController> inventory(); } diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java index 77bfcf9f..9b832b04 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java @@ -375,7 +375,7 @@ public class MavenDroolsController implements DroolsController { @Override - public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) { + public boolean ownsCoder(Class<?> coderClass, int modelHash) { if (!isClass(coderClass.getName())) { logger.error("{}{} cannot be retrieved. ", this, coderClass.getName()); return false; diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java index 5416d321..a43a1467 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java @@ -138,7 +138,7 @@ public class NullDroolsController implements DroolsController { } @Override - public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) { + public boolean ownsCoder(Class<?> coderClass, int modelHash) { throw new IllegalStateException(makeInvokeMsg()); } diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java index 6cbe94ae..7e268591 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java +++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java @@ -120,7 +120,7 @@ public interface EventProtocolCoder { * @param eventProtocolParams parameter object for event protocol * @throw IllegalArgumentException if an invalid parameter is passed */ - public void addDecoder(EventProtocolParams eventProtocolParams); + void addDecoder(EventProtocolParams eventProtocolParams); /** * removes all decoders associated with the controller id. @@ -140,7 +140,7 @@ public interface EventProtocolCoder { * @param topic the topic * @throws IllegalArgumentException if invalid arguments have been provided */ - public void removeDecoders(String groupId, String artifactId, String topic); + void removeDecoders(String groupId, String artifactId, String topic); /** * Given a controller id and a topic, it gives back its filters. @@ -151,7 +151,7 @@ public interface EventProtocolCoder { * @return list of decoders * @throw IllegalArgumentException if an invalid parameter is passed */ - public List<CoderFilters> getDecoderFilters(String groupId, String artifactId, String topic); + List<CoderFilters> getDecoderFilters(String groupId, String artifactId, String topic); /** * gets all decoders associated with the group and artifact ids. @@ -160,7 +160,7 @@ public interface EventProtocolCoder { * @param artifactId of the controller * @throws IllegalArgumentException if invalid arguments have been provided */ - public List<CoderFilters> getDecoderFilters(String groupId, String artifactId); + List<CoderFilters> getDecoderFilters(String groupId, String artifactId); /** * Given a controller id, a topic, and a classname, it gives back the classes that implements the decoding. @@ -172,8 +172,8 @@ public interface EventProtocolCoder { * @return list of decoders * @throw IllegalArgumentException if an invalid parameter is passed */ - public CoderFilters getDecoderFilters( - String groupId, String artifactId, String topic, String classname); + CoderFilters getDecoderFilters( + String groupId, String artifactId, String topic, String classname); /** * Given a controller id and a topic, it gives back the decoding configuration. @@ -184,7 +184,7 @@ public interface EventProtocolCoder { * @return decoding toolset * @throw IllegalArgumentException if an invalid parameter is passed */ - public ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic); + ProtocolCoderToolset getDecoders(String groupId, String artifactId, String topic); /** * Given a controller id and a topic, it gives back all the decoding configurations. @@ -194,7 +194,7 @@ public interface EventProtocolCoder { * @return decoding toolset * @throw IllegalArgumentException if an invalid parameter is passed */ - public List<ProtocolCoderToolset> getDecoders(String groupId, String artifactId); + List<ProtocolCoderToolset> getDecoders(String groupId, String artifactId); /** * Given a controller id and a topic, it gives back the classes that implements the encoding. @@ -205,7 +205,7 @@ public interface EventProtocolCoder { * @return list of decoders * @throw IllegalArgumentException if an invalid parameter is passed */ - public List<CoderFilters> getEncoderFilters(String groupId, String artifactId, String topic); + List<CoderFilters> getEncoderFilters(String groupId, String artifactId, String topic); /** * gets all encoders associated with the group and artifact ids. @@ -215,7 +215,7 @@ public interface EventProtocolCoder { * @return List of filters * @throws IllegalArgumentException if invalid arguments have been provided */ - public List<CoderFilters> getEncoderFilters(String groupId, String artifactId); + List<CoderFilters> getEncoderFilters(String groupId, String artifactId); /** * get encoder based on coordinates and classname. @@ -227,8 +227,8 @@ public interface EventProtocolCoder { * @return CoderFilters decoders * @throws IllegalArgumentException invalid arguments passed in */ - public CoderFilters getEncoderFilters( - String groupId, String artifactId, String topic, String classname); + CoderFilters getEncoderFilters( + String groupId, String artifactId, String topic, String classname); /** * is there a decoder supported for the controller id and topic. @@ -238,7 +238,7 @@ public interface EventProtocolCoder { * @param topic protocol * @return true if supported */ - public boolean isDecodingSupported(String groupId, String artifactId, String topic); + boolean isDecodingSupported(String groupId, String artifactId, String topic); /** * Adds a Encoder class to encode the protocol over this topic. @@ -246,7 +246,7 @@ public interface EventProtocolCoder { * @param eventProtocolParams parameter object for event protocol * @throw IllegalArgumentException if an invalid parameter is passed */ - public void addEncoder(EventProtocolParams eventProtocolParams); + void addEncoder(EventProtocolParams eventProtocolParams); /** * is there an encoder supported for the controller id and topic. @@ -256,7 +256,7 @@ public interface EventProtocolCoder { * @param topic protocol * @return true if supported */ - public boolean isEncodingSupported(String groupId, String artifactId, String topic); + boolean isEncodingSupported(String groupId, String artifactId, String topic); /** * get encoder based on topic and encoded class. @@ -266,7 +266,7 @@ public interface EventProtocolCoder { * @return list of filters * @throws IllegalArgumentException invalid arguments passed in */ - public List<CoderFilters> getReverseEncoderFilters(String topic, String encodedClass); + List<CoderFilters> getReverseEncoderFilters(String topic, String encodedClass); /** * gets the identifier of the creator of the encoder. @@ -276,7 +276,7 @@ public interface EventProtocolCoder { * @return a drools controller * @throws IllegalArgumentException invalid arguments passed in */ - public DroolsController getDroolsController(String topic, Object encodedClass); + DroolsController getDroolsController(String topic, Object encodedClass); /** * gets the identifier of the creator of the encoder. @@ -286,7 +286,7 @@ public interface EventProtocolCoder { * @return list of drools controllers * @throws IllegalArgumentException invalid arguments passed in */ - public List<DroolsController> getDroolsControllers(String topic, Object encodedClass); + List<DroolsController> getDroolsControllers(String topic, Object encodedClass); /** * decode topic's stringified event (json) to corresponding Event Object. @@ -300,7 +300,7 @@ public interface EventProtocolCoder { * @throws UnsupportedOperationException if the operation is not supported * @throws IllegalStateException if the system is in an illegal state */ - public Object decode(String groupId, String artifactId, String topic, String json); + Object decode(String groupId, String artifactId, String topic, String json); /** * encodes topic's stringified event (json) to corresponding Event Object. @@ -312,7 +312,7 @@ public interface EventProtocolCoder { * @return encoded string * @throws IllegalArgumentException invalid arguments passed in */ - public String encode(String groupId, String artifactId, String topic, Object event); + String encode(String groupId, String artifactId, String topic, Object event); /** * encodes topic's stringified event (json) to corresponding Event Object. @@ -323,7 +323,7 @@ public interface EventProtocolCoder { * @throws IllegalArgumentException invalid arguments passed in * @throws UnsupportedOperationException operation cannot be performed */ - public String encode(String topic, Object event); + String encode(String topic, Object event); /** * encodes topic's stringified event (json) to corresponding Event Object. @@ -335,5 +335,5 @@ public interface EventProtocolCoder { * @throws IllegalArgumentException invalid arguments passed in * @throws UnsupportedOperationException operation cannot be performed */ - public String encode(String topic, Object event, DroolsController droolsController); + String encode(String topic, Object event, DroolsController droolsController); } diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java index cb0749d9..db09cb47 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java @@ -309,8 +309,8 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener { * {@code false} otherwise * @return a new lock */ - public Lock createLock(String resourceId, String ownerKey, int holdSec, LockCallback callback, - boolean waitForLock); + Lock createLock(String resourceId, String ownerKey, int holdSec, LockCallback callback, + boolean waitForLock); /** * Invoked when the host goes into the active state. diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java index 6e529c74..0f046d23 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java @@ -221,7 +221,7 @@ class PolicyEngineManager implements PolicyEngine { defaultConfig.put( PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + TELEMETRY_SERVER_DEFAULT_NAME + PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX, - "" + Integer.toString(TELEMETRY_SERVER_DEFAULT_PORT)); + "" + TELEMETRY_SERVER_DEFAULT_PORT); defaultConfig.put( PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + TELEMETRY_SERVER_DEFAULT_NAME + PolicyEndPointProperties.PROPERTY_HTTP_REST_PACKAGES_SUFFIX, @@ -663,7 +663,7 @@ class PolicyEngineManager implements PolicyEngine { @FunctionalInterface private static interface PredicateWithEx<T> { - public boolean test(T value) throws InterruptedException; + boolean test(T value) throws InterruptedException; } @Override diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController3Test.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController3Test.java index e237a455..e7f65296 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController3Test.java +++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController3Test.java @@ -32,7 +32,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.kie.api.builder.ReleaseId; diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java index 2bbb08bf..8607fd6d 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java @@ -84,8 +84,8 @@ public class ProtocolCoderToolsetTest { public void testGsonToolset(JsonProtocolFilter protocolFilter) { GsonProtocolCoderToolset gsonToolset = new GsonProtocolCoderToolset( EventProtocolParams.builder().topic(JUNIT_PROTOCOL_CODER_TOPIC) - .groupId(this.releaseId.getGroupId()) - .artifactId(this.releaseId.getArtifactId()) + .groupId(releaseId.getGroupId()) + .artifactId(releaseId.getArtifactId()) .eventClass(Triple.class.getName()) .protocolFilter(protocolFilter) .customGsonCoder(null) @@ -193,8 +193,8 @@ public class ProtocolCoderToolsetTest { private void validateInitialization(JsonProtocolFilter protocolFilter, ProtocolCoderToolset coderToolset) { Assert.assertTrue(CONTROLLER_ID.equals(coderToolset.getControllerId())); - Assert.assertTrue(this.releaseId.getGroupId().equals(coderToolset.getGroupId())); - Assert.assertTrue(this.releaseId.getArtifactId().equals(coderToolset.getArtifactId())); + Assert.assertTrue(releaseId.getGroupId().equals(coderToolset.getGroupId())); + Assert.assertTrue(releaseId.getArtifactId().equals(coderToolset.getArtifactId())); Assert.assertNull(coderToolset.getCustomCoder()); Assert.assertTrue(coderToolset.getCoders().size() == 1); |