From 7602a4380488d872b25cd718176b23369bf9e472 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 24 Jul 2019 13:19:28 -0400 Subject: Add coverage to feature-active-standby-management Also removed some logger.isXxx() tests, which should reduce the number of branches that need to be tested. Removed unneeded objects and methods from feature-lifecyle. Change-Id: Ic3eb9c0b63a2ad5585846525eb0ebda81fc55d5e Issue-ID: POLICY-1772 Signed-off-by: Jim Hahn --- .../statemanagement/DroolsPdpIntegrityMonitor.java | 9 ++------ .../IntegrityMonitorRestManager.java | 10 ++++----- .../drools/statemanagement/RepositoryAudit.java | 24 ++++++++++------------ 3 files changed, 17 insertions(+), 26 deletions(-) (limited to 'feature-state-management') diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java index 1e528b2d..2fa54e6b 100644 --- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java +++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPdpIntegrityMonitor.java @@ -73,10 +73,7 @@ public class DroolsPdpIntegrityMonitor extends IntegrityMonitor { } private static void logPropertyValue(String prop, String val) { - if (logger.isInfoEnabled()) { - String msg = "\n\n init: property: " + prop + " = " + val + "\n"; - logger.info(msg); - } + logger.info("\n\n init: property: {} = {}\n", prop, val); } /** @@ -427,9 +424,7 @@ public class DroolsPdpIntegrityMonitor extends IntegrityMonitor { * @throws IntegrityMonitorException exception */ public static DroolsPdpIntegrityMonitor getInstance() throws IntegrityMonitorException { - if (logger.isDebugEnabled()) { - logger.debug("getInstance() called"); - } + logger.debug("getInstance() called"); if (im == null) { String msg = "No DroolsPDPIntegrityMonitor instance exists." + " Please use the method DroolsPDPIntegrityMonitor init(String configDir)"; diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java index 7dca9e63..3330bd80 100644 --- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java +++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java @@ -7,9 +7,9 @@ * 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. @@ -41,7 +41,7 @@ public class IntegrityMonitorRestManager { /** * Test interface for Integrity Monitor. - * + * * @return Exception message if exception, otherwise empty */ @ApiOperation( @@ -63,9 +63,7 @@ public class IntegrityMonitorRestManager { @GET @Path("test") public Response test() { - if (logger.isDebugEnabled()) { - logger.debug("integrity monitor /test accessed"); - } + logger.debug("integrity monitor /test accessed"); // The responses are stored within the audit objects, so we need to // invoke the audits and get responses before we handle another // request. diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java index e78b0a1a..9d39a7bf 100644 --- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java +++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java @@ -7,9 +7,9 @@ * 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. @@ -56,7 +56,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase { /** * Get the integrity monitor instance. - * + * * @return the single 'RepositoryAudit' instance */ public static DroolsPdpIntegrityMonitor.AuditBase getInstance() { @@ -71,9 +71,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase { @Override public void invoke(Properties properties) throws IOException, InterruptedException { - if (logger.isDebugEnabled()) { - logger.debug("Running 'RepositoryAudit.invoke'"); - } + logger.debug("Running 'RepositoryAudit.invoke'"); boolean isActive = true; // ignore errors by default @@ -81,14 +79,14 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase { String repoAuditIsActive = StateManagementProperties.getProperty("repository.audit.is.active"); String repoAuditIgnoreErrors = StateManagementProperties.getProperty("repository.audit.ignore.errors"); - logger.debug("RepositoryAudit.invoke: repoAuditIsActive = {}" + logger.debug("RepositoryAudit.invoke: repoAuditIsActive = {}" + ", repoAuditIgnoreErrors = {}",repoAuditIsActive, repoAuditIgnoreErrors); if (repoAuditIsActive != null) { try { isActive = Boolean.parseBoolean(repoAuditIsActive.trim()); } catch (NumberFormatException e) { - logger.warn("RepositoryAudit.invoke: Ignoring invalid property: repository.audit.is.active = {}", + logger.warn("RepositoryAudit.invoke: Ignoring invalid property: repository.audit.is.active = {}", repoAuditIsActive); } } @@ -103,7 +101,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase { ignoreErrors = Boolean.parseBoolean(repoAuditIgnoreErrors.trim()); } catch (NumberFormatException e) { ignoreErrors = true; - logger.warn("RepositoryAudit.invoke: Ignoring invalid property: repository.audit.ignore.errors = {}", + logger.warn("RepositoryAudit.invoke: Ignoring invalid property: repository.audit.ignore.errors = {}", repoAuditIgnoreErrors); } } else { @@ -134,7 +132,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase { try { timeoutInSeconds = Long.valueOf(timeoutString); } catch (NumberFormatException e) { - logger.error("RepositoryAudit: Invalid 'repository.audit.timeout' value: '{}'", + logger.error("RepositoryAudit: Invalid 'repository.audit.timeout' value: '{}'", timeoutString, e); if (!ignoreErrors) { response.append("Invalid 'repository.audit.timeout' value: '") @@ -238,7 +236,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase { .append(repo) .append("\n") .append(" \n"); - + for (Artifact artifact : artifacts) { // each artifact results in an 'artifactItem' element sb.append(" \n" @@ -315,7 +313,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase { if (fileContents.regionMatches(index, "loading: ", 0, 9)) { index += 9; int endIndex = fileContents.indexOf('\n', index); - logger.info("RepositoryAudit: Attempted download: '{}'", + logger.info("RepositoryAudit: Attempted download: '{}'", fileContents.substring(index, endIndex)); index = endIndex; } else if (fileContents.regionMatches(index, "loaded: ", 0, 8)) { @@ -481,7 +479,7 @@ public class RepositoryAudit extends DroolsPdpIntegrityMonitor.AuditBase { /** * Returns string representation. - * + * * @return the artifact id in the form: {@code"///"} */ @Override -- cgit 1.2.3-korg