change HealthCheckReport URL from self to hostName

Issue-ID: POLICY-1689 Consolidate Policy Health Check into PAP
Change-Id: I00e17610d3e4788008649791c684c0af415863ee
Signed-off-by: Hengye <yehui.wang@est.tech>
diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java b/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java
index a22d085..2fe46b2 100644
--- a/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java
+++ b/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Ericsson. All rights reserved.
+ *  Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
 package org.onap.policy.distribution.main.rest;
 
 import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.common.utils.network.NetworkUtil;
 import org.onap.policy.distribution.main.startstop.DistributionActivator;
 
 /**
@@ -32,7 +34,7 @@
 
     private static final String NOT_ALIVE = "not alive";
     private static final String ALIVE = "alive";
-    private static final String URL = "self";
+    private static final String URL = NetworkUtil.getHostname();
     private static final String NAME = "Policy SSD";
 
     /**
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
index 3644864..008a110 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestDistributionRestServer.java
@@ -3,6 +3,7 @@
  *  Copyright (C) 2018 Ericsson. All rights reserved.
  *  Copyright (C) 2019 Nordix Foundation.
  *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,12 +58,12 @@
     private static final Logger LOGGER = LoggerFactory.getLogger(TestDistributionRestServer.class);
     private static final String NOT_ALIVE = "not alive";
     private static final String ALIVE = "alive";
-    private static final String SELF = "self";
+    private static final String SELF = NetworkUtil.getHostname();
     private static final String NAME = "Policy SSD";
 
     @Test
     public void testHealthCheckSuccess() {
-        final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]";
+        final String reportString = "Report [name=Policy SSD, url=" + SELF + ", healthy=true, code=200, message=alive]";
         try {
             final Main main = startDistributionService();
             final HealthCheckReport report = performHealthCheck();
@@ -76,7 +77,8 @@
 
     @Test
     public void testHealthCheckFailure() {
-        final String reportString = "Report [name=Policy SSD, url=self, healthy=false, code=500, message=not alive]";
+        final String reportString =
+                "Report [name=Policy SSD, url=" + SELF + ", healthy=false, code=500, message=not alive]";
         final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
         restServerParams.setName(CommonTestData.DISTRIBUTION_GROUP_NAME);
         final RestServer restServer = new RestServer(restServerParams, null, DistributionRestController.class);
diff --git a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
index f3046c2..7a9835c 100644
--- a/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
+++ b/main/src/test/java/org/onap/policy/distribution/main/rest/TestHttpsDistributionRestServer.java
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Intel. All rights reserved.
- *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -55,13 +55,13 @@
 
     private static final Logger LOGGER = LoggerFactory.getLogger(TestHttpsDistributionRestServer.class);
     private static final String ALIVE = "alive";
-    private static final String SELF = "self";
+    private static final String SELF = NetworkUtil.getHostname();
     private static final String NAME = "Policy SSD";
     private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
 
     @Test
     public void testHttpsHealthCheckSuccess() {
-        final String reportString = "Report [name=Policy SSD, url=self, healthy=true, code=200, message=alive]";
+        final String reportString = "Report [name=Policy SSD, url=" + SELF + ", healthy=true, code=200, message=alive]";
         try {
             final Main main = startDistributionService();
             final HealthCheckReport report = performHealthCheck();