diff options
author | a.sreekumar <ajith.sreekumar@bell.ca> | 2020-08-14 16:49:40 +0100 |
---|---|---|
committer | a.sreekumar <ajith.sreekumar@bell.ca> | 2020-08-14 16:49:46 +0100 |
commit | db5b469ca8698f7bf7110389de08b8233dfc7d6d (patch) | |
tree | 9858cdc09ca53ff42be04ad131f6d40723e779fa /main/src | |
parent | f91872a675d80c458c0ed17bacee81cc41adc639 (diff) |
Using standard success/failure messages in PAP
Change-Id: If4613c0fc6f940bc82cf616aba2ba9cc03e1b599
Issue-ID: POLICY-2754
Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/java/org/onap/policy/pap/main/startstop/Main.java | 9 | ||||
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java | 9 |
2 files changed, 9 insertions, 9 deletions
diff --git a/main/src/main/java/org/onap/policy/pap/main/startstop/Main.java b/main/src/main/java/org/onap/policy/pap/main/startstop/Main.java index 74bb9f69..4ccfb116 100644 --- a/main/src/main/java/org/onap/policy/pap/main/startstop/Main.java +++ b/main/src/main/java/org/onap/policy/pap/main/startstop/Main.java @@ -23,6 +23,7 @@ package org.onap.policy.pap.main.startstop; import java.util.Arrays; +import org.onap.policy.common.utils.resources.MessageConstants; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.PolicyPapException; @@ -39,8 +40,6 @@ import org.slf4j.LoggerFactory; */ public class Main { - private static final String START_FAILED = "start of policy pap service failed"; - private static final Logger LOGGER = LoggerFactory.getLogger(Main.class); private PapActivator activator; @@ -83,12 +82,14 @@ public class Main { if (null != activator) { Registry.unregister(PapConstants.REG_PAP_ACTIVATOR); } - throw new PolicyPapRuntimeException(START_FAILED + ", used parameters are " + Arrays.toString(args), exp); + throw new PolicyPapRuntimeException( + String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_PAP), exp); } // Add a shutdown hook to shut everything down in an orderly manner Runtime.getRuntime().addShutdownHook(new PolicyPapShutdownHookClass()); - LOGGER.info("Started policy pap service"); + String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_PAP); + LOGGER.info(successMsg); } /** diff --git a/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java index ef410412..e49982bf 100644 --- a/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java +++ b/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java @@ -32,6 +32,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; +import org.onap.policy.common.utils.resources.MessageConstants; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.pap.main.PapConstants; import org.onap.policy.pap.main.PolicyPapException; @@ -86,15 +87,14 @@ public class TestMain { public void testMain_NoArguments() { final String[] papConfigParameters = {}; assertThatThrownBy(() -> new Main(papConfigParameters)).isInstanceOf(PolicyPapRuntimeException.class) - .hasMessage("start of policy pap service failed, used parameters are []"); + .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_PAP)); } @Test public void testMain_InvalidArguments() { final String[] papConfigParameters = {"parameters/PapConfigParameters.json"}; assertThatThrownBy(() -> new Main(papConfigParameters)).isInstanceOf(PolicyPapRuntimeException.class) - .hasMessage( - "start of policy pap service failed, used parameters are [parameters/PapConfigParameters.json]"); + .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_PAP)); } @Test @@ -108,7 +108,6 @@ public class TestMain { public void testMain_InvalidParameters() { final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters_InvalidName.json"}; assertThatThrownBy(() -> new Main(papConfigParameters)).isInstanceOf(PolicyPapRuntimeException.class) - .hasMessage("start of policy pap service failed, " - + "used parameters are [-c, parameters/PapConfigParameters_InvalidName.json]"); + .hasMessage(String.format(MessageConstants.START_FAILURE_MSG, MessageConstants.POLICY_PAP)); } } |