From 0bfa9b4dfe33aa70fa921aa5e5c684790fd030d6 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 1 Oct 2018 15:05:58 +0100 Subject: Refactor monitoring REST tests to remove PowerMock Removed PowerMock from tests becasue coverage of PowerMock is not counted by JaCoCO. It was easier to remove PowerMock than to try and hack the build get PowerMock coverage counted. Issue-ID: POLICY-1034 Change-Id: Ifc3e1ff93b2bfcb5619a5af6dec320d2de992f87 Signed-off-by: liamfallon --- .../monitoring/rest/ApexMonitoringRestResource.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'client/client-monitoring/src/main') diff --git a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestResource.java b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestResource.java index 07e2efd13..c5c4b1291 100644 --- a/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestResource.java +++ b/client/client-monitoring/src/main/java/org/onap/policy/apex/client/monitoring/rest/ApexMonitoringRestResource.java @@ -89,7 +89,7 @@ public class ApexMonitoringRestResource { public Response createSession(@QueryParam("hostName") final String hostName, @QueryParam("port") final int port) { final Gson gson = new Gson(); final String host = hostName + ":" + port; - final EngineServiceFacade engineServiceFacade = new EngineServiceFacade(hostName, port); + final EngineServiceFacade engineServiceFacade = getEngineServiceFacade(hostName, port); try { engineServiceFacade.init(); @@ -175,7 +175,7 @@ public class ApexMonitoringRestResource { @Path("startstop/") public Response startStop(@QueryParam("hostName") final String hostName, @QueryParam("port") final int port, @QueryParam("engineId") final String engineId, @QueryParam("startstop") final String startStop) { - final EngineServiceFacade engineServiceFacade = new EngineServiceFacade(hostName, port); + final EngineServiceFacade engineServiceFacade = getEngineServiceFacade(hostName, port); try { engineServiceFacade.init(); @@ -227,7 +227,7 @@ public class ApexMonitoringRestResource { public Response periodiceventStartStop(@QueryParam("hostName") final String hostName, @QueryParam("port") final int port, @QueryParam("engineId") final String engineId, @QueryParam("startstop") final String startStop, @QueryParam("period") final long period) { - final EngineServiceFacade engineServiceFacade = new EngineServiceFacade(hostName, port); + final EngineServiceFacade engineServiceFacade = getEngineServiceFacade(hostName, port); final String host = hostName + ":" + port; try { engineServiceFacade.init(); @@ -312,6 +312,18 @@ public class ApexMonitoringRestResource { return valueList; } + + /** + * Get an engine service facade for sending REST requests. This method is package because it is used by unit test. + * + * @param hostName the host name of the Apex engine + * @param port the port of the Apex engine + * @return the engine service facade + */ + protected EngineServiceFacade getEngineServiceFacade(final String hostName, final int port) { + return new EngineServiceFacade(hostName, port); + } + /** * A list of values that uses a FIFO sliding window of a fixed size. */ -- cgit 1.2.3-korg