Using standard success/failure messages in PAP 84/111284/1
authora.sreekumar <ajith.sreekumar@bell.ca>
Fri, 14 Aug 2020 15:49:40 +0000 (16:49 +0100)
committera.sreekumar <ajith.sreekumar@bell.ca>
Fri, 14 Aug 2020 15:49:46 +0000 (16:49 +0100)
Change-Id: If4613c0fc6f940bc82cf616aba2ba9cc03e1b599
Issue-ID: POLICY-2754
Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
main/src/main/java/org/onap/policy/pap/main/startstop/Main.java
main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java

index 74bb9f6..4ccfb11 100644 (file)
@@ -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);
     }
 
     /**
index ef41041..e49982b 100644 (file)
@@ -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));
     }
 }