From 25e3f7a0d6cd5e364e4fd69eef310fcdb8a58b55 Mon Sep 17 00:00:00 2001
From: liamfallon <liam.fallon@est.tech>
Date: Fri, 4 Sep 2020 11:03:24 +0100
Subject: Remove client code from apex-pdp

Removal of the deployment and monitoring client from the apex-pdp as
the functionality is replaced by the Policy Framework deployment using
PAP and the Policy Framework monitoring GUI.

Code in the engine proper that was used to administer apex-pdp over the
Web Socket port is also removed, as this code was only used by the
apex-pdp legacy GUIs.

Issue-ID: POLICY-2621
Change-Id: Ib9fc4a667a4bc79377bb7b82fae6a2bd520a3e3d
Signed-off-by: liamfallon <liam.fallon@est.tech>
---
 .../monitoring/rest/MonitoringExceptionTest.java   |  40 ----
 .../monitoring/rest/MonitoringRestExtraTest.java   |  39 ---
 .../monitoring/rest/MonitoringRestMainTest.java    | 196 ---------------
 .../client/monitoring/rest/ParameterCheckTest.java | 191 ---------------
 .../client/monitoring/rest/RestResourceTest.java   | 263 ---------------------
 5 files changed, 729 deletions(-)
 delete mode 100644 client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringExceptionTest.java
 delete mode 100644 client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestExtraTest.java
 delete mode 100644 client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java
 delete mode 100644 client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheckTest.java
 delete mode 100644 client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java

(limited to 'client/client-monitoring/src/test')

diff --git a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringExceptionTest.java b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringExceptionTest.java
deleted file mode 100644
index 3b5ecd100..000000000
--- a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringExceptionTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.client.monitoring.rest;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-
-/**
- * Test the REST monitoring exception.
- *
- */
-public class MonitoringExceptionTest {
-
-    @Test
-    public void test() {
-        ApexMonitoringRestParameterException ame = new ApexMonitoringRestParameterException("a message");
-        assertNotNull(ame);
-        assertEquals("a message", ame.getMessage());
-    }
-}
diff --git a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestExtraTest.java b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestExtraTest.java
deleted file mode 100644
index 277b2ed17..000000000
--- a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestExtraTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.client.monitoring.rest;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-/**
- * Extra monitoring rest tests.
- *
- */
-public class MonitoringRestExtraTest {
-
-    @Test
-    public void test() {
-        ApexMonitoringRestParameters parameters = new ApexMonitoringRestParameters();
-        parameters.setRestPort(12345);
-        assertEquals(12345, parameters.getRestPort());
-    }
-}
diff --git a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java
deleted file mode 100644
index b376c9bfa..000000000
--- a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/MonitoringRestMainTest.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.client.monitoring.rest;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.util.concurrent.TimeUnit;
-import org.junit.Test;
-
-/**
- * Test the periodic event manager utility.
- */
-public class MonitoringRestMainTest {
-    @Test
-    public void testMonitoringClientBad() {
-        final String[] eventArgs = {"-z"};
-        assertThatCode(() -> ApexMonitoringRestMain.main(eventArgs)).doesNotThrowAnyException();
-    }
-
-    @Test
-    public void testMonitoringClientOk() {
-        final String[] eventArgs = {"-t", "1"};
-        assertThatCode(() -> ApexMonitoringRestMain.main(eventArgs)).doesNotThrowAnyException();
-    }
-
-    @Test
-    public void testMonitoringClientNoOptions() {
-        final String[] eventArgs = new String[] {};
-
-        final String outputString = testApexMonitoringRestMainConstructor(eventArgs);
-
-        System.err.println(outputString);
-        assertEquals("*** StdOut ***\n\n*** StdErr ***\n", outputString);
-    }
-
-    @Test
-    public void testMonitoringClientBadOptions() {
-        final String[] eventArgs = {"-zabbu"};
-
-        assertThatThrownBy(() -> new ApexMonitoringRestMain(eventArgs, System.out))
-            .hasMessageContaining("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
-                + "parameter error, invalid command line arguments specified " + ": Unrecognized option: -zabbu");
-    }
-
-    @Test
-    public void testMonitoringClientHelp() {
-        final String[] eventArgs = {"-h"};
-
-        assertThatThrownBy(() -> new ApexMonitoringRestMain(eventArgs, System.out))
-            .hasMessageContaining("usage: org.onap.policy.apex.client.monitoring.rest."
-                    + "ApexMonitoringRestMain [options...]");
-    }
-
-    @Test
-    public void testMonitoringClientPortBad() {
-        final String[] eventArgs = {"-p", "hello"};
-
-        assertThatThrownBy(() -> new ApexMonitoringRestMain(eventArgs, System.out))
-            .hasMessageContaining("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
-                    + "parameter error, error parsing argument \"port\" :For input string: \"hello\"");
-    }
-
-    @Test
-    public void testMonitoringClientPortNegative() {
-        final String[] eventArgs = {"-p", "-1"};
-
-        assertThatThrownBy(() -> new ApexMonitoringRestMain(eventArgs, System.out))
-            .hasMessageContaining("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRest"
-                + "Parameters: URI=http://localhost:-1/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
-                + "port must be greater than 1023 and less than 65536");
-    }
-
-    @Test
-    public void testMonitoringClientTtlTooSmall() {
-        final String[] eventArgs = {"-t", "-2"};
-
-        assertThatThrownBy(() -> new ApexMonitoringRestMain(eventArgs, System.out))
-            .hasMessageContaining("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoringRest"
-                    + "Parameters: URI=http://localhost:18989/apexservices/, TTL=-2sec], State=STOPPED) parameters invalid, "
-                    + "time to live must be greater than -1 (set to -1 to wait forever)");
-    }
-
-    @Test
-    public void testMonitoringClientTooManyPars() {
-        final String[] eventArgs = {"-t", "10", "-p", "12344", "aaa", "bbb"};
-
-        assertThatThrownBy(() -> new ApexMonitoringRestMain(eventArgs, System.out))
-            .hasMessageContaining("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
-                    + "parameter error, too many command line arguments specified : [aaa, bbb]");
-    }
-
-    @Test
-    public void testMonitoringClientTtlNotNumber() {
-        final String[] eventArgs = {"-t", "timetolive"};
-
-        assertThatThrownBy(() -> new ApexMonitoringRestMain(eventArgs, System.out))
-            .hasMessageContaining("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[null], State=STOPPED) "
-                    + "parameter error, error parsing argument \"time-to-live\" :" + "For input string: \""
-                            + "timetolive\"");
-    }
-
-    @Test
-    public void testMonitoringClientPortTooBig() {
-        final String[] eventArgs = {"-p", "65536"};
-
-        assertThatThrownBy(() -> new ApexMonitoringRestMain(eventArgs, System.out))
-            .hasMessageContaining("Apex Services REST endpoint (ApexMonitoringRestMain: Config=[ApexMonitoring"
-                + "RestParameters: URI=http://localhost:65536/apexservices/, TTL=-1sec], State=STOPPED) parameters invalid, "
-                + "port must be greater than 1023 and less than 65536");
-    }
-
-    @Test
-    public void testMonitoringClientDefaultPars() {
-        ApexMonitoringRest monRest = new ApexMonitoringRest();
-        assertNotNull(monRest);
-        assertThatCode(() -> monRest.shutdown()).isNull();
-    }
-
-    @Test
-    public void testMonitoringOneSecStart() {
-        final String[] eventArgs = {"-t", "1"};
-
-        ApexMonitoringRestMain monRestMain = new ApexMonitoringRestMain(eventArgs, System.out);
-        assertNotNull(monRestMain);
-        monRestMain.init();
-        assertThatCode(() -> monRestMain.shutdown()).isNull();
-    }
-
-    @Test
-    public void testMonitoringForeverStart() {
-        final String[] eventArgs = {"-t", "-1"};
-
-        ApexMonitoringRestMain monRestMain = new ApexMonitoringRestMain(eventArgs, System.out);
-
-        Thread monThread = new Thread() {
-            @Override
-            public void run() {
-                monRestMain.init();
-            }
-        };
-        assertThatCode(() -> {
-            monThread.start();
-            await().atMost(6, TimeUnit.SECONDS)
-                .until(() -> monRestMain.getState().equals(ApexMonitoringRestMain.ServicesState.RUNNING));
-            monRestMain.shutdown();
-        }).doesNotThrowAnyException();
-    }
-
-    /**
-     * Run the application.
-     *
-     * @param eventArgs the command arguments
-     * @return a string containing the command output
-     */
-    private String testApexMonitoringRestMainConstructor(final String[] eventArgs) {
-        final ByteArrayOutputStream baosOut = new ByteArrayOutputStream();
-        final ByteArrayOutputStream baosErr = new ByteArrayOutputStream();
-
-        new ApexMonitoringRestMain(eventArgs, new PrintStream(baosOut, true));
-
-        InputStream testInput = new ByteArrayInputStream("Test Data for Input to WS".getBytes());
-        System.setIn(testInput);
-
-        String outString = baosOut.toString();
-        String errString = baosErr.toString();
-
-        return "*** StdOut ***\n" + outString + "\n*** StdErr ***\n" + errString;
-    }
-}
diff --git a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheckTest.java b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheckTest.java
deleted file mode 100644
index bea15eb87..000000000
--- a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/ParameterCheckTest.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.client.monitoring.rest;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-
-/**
- * Test the parameter check class.
- *
- */
-public class ParameterCheckTest {
-
-    @Test
-    public void testStartStop() {
-        assertEquals("START", ParameterCheck.StartStop.START.name());
-        assertEquals("STOP", ParameterCheck.StartStop.STOP.name());
-    }
-
-    @Test
-    public void testHostName() {
-        assertNull(ParameterCheck.getHostName(null));
-        
-        Map<String, String[]> parameterMap = new LinkedHashMap<>();
-        assertNull(ParameterCheck.getHostName(parameterMap));
-        parameterMap.put("hostname", null);
-        assertNull(ParameterCheck.getHostName(parameterMap));
-        
-        String[] hostnameBlankValue0 = {"", ""};
-        parameterMap.put("hostname", hostnameBlankValue0);
-        assertNull(ParameterCheck.getHostName(parameterMap));
-        
-        String[] hostnameBlankValue1 = {" ", " "};
-        parameterMap.put("hostname", hostnameBlankValue1);
-        assertNull(ParameterCheck.getHostName(parameterMap));
-        
-        String[] hostnameValue = {"hostname0", "hostname1"};
-        parameterMap.put("hostname", hostnameValue);
-        assertEquals("hostname0", ParameterCheck.getHostName(parameterMap));
-    }
-
-    @Test
-    public void testPort() {
-        assertEquals(-1, ParameterCheck.getPort(null));
-        
-        Map<String, String[]> parameterMap = new LinkedHashMap<>();
-        assertEquals(-1, ParameterCheck.getPort(parameterMap));
-        parameterMap.put("port", null);
-        assertEquals(-1, ParameterCheck.getPort(parameterMap));
-
-        String[] portBlankValue0 = {"", ""};
-        parameterMap.put("port", portBlankValue0);
-        assertEquals(-1, ParameterCheck.getPort(parameterMap));
-
-        String[] portBlankValue1 = {" ", " "};
-        parameterMap.put("port", portBlankValue1);
-        assertEquals(-1, ParameterCheck.getPort(parameterMap));
-        
-        String[] portValueBad = {"port", "value"};
-        parameterMap.put("port", portValueBad);
-        assertEquals(-1, ParameterCheck.getPort(parameterMap));
-        
-        String[] portValueRange0 = {"-1", "-1"};
-        parameterMap.put("port", portValueRange0);
-        assertEquals(-1, ParameterCheck.getPort(parameterMap));
-
-        String[] portValueRange1 = {"65536", "65536"};
-        parameterMap.put("port", portValueRange1);
-        assertEquals(-1, ParameterCheck.getPort(parameterMap));
-
-        String[] portValue = {"12344", "23221"};
-        parameterMap.put("port", portValue);
-        assertEquals(12344, ParameterCheck.getPort(parameterMap));
-    }
-
-    @Test
-    public void testEngineKey() {
-        assertEquals(null, ParameterCheck.getEngineKey(null));
-
-        Map<String, String[]> parameterMap = new LinkedHashMap<>();
-        parameterMap.put("Zooby", null);
-        assertEquals(null, ParameterCheck.getEngineKey(parameterMap));
-        
-        parameterMap.put("AxArtifactKey", null);
-        assertEquals(null, ParameterCheck.getEngineKey(parameterMap));
-        parameterMap.remove("AxArtifactKey");
-        
-        parameterMap.put("AxArtifactKey#zooby", null);
-        assertEquals(null, ParameterCheck.getEngineKey(parameterMap));
-        parameterMap.remove("AxArtifactKey#zooby");
-
-        parameterMap.put("AxArtifactKey#zooby#looby", null);
-        assertEquals(null, ParameterCheck.getEngineKey(parameterMap));
-        parameterMap.remove("AxArtifactKey#zooby#looby");
-
-        parameterMap.put("AxArtifactKey#Name:0.0.1", null);
-        assertEquals(new AxArtifactKey("Name", "0.0.1"), ParameterCheck.getEngineKey(parameterMap));
-    }
-
-    @Test
-    public void testStartStopValue() {
-        assertEquals(null, ParameterCheck.getStartStop(null, null));
-        
-        Map<String, String[]> parameterMap = new LinkedHashMap<>();
-        assertEquals(null, ParameterCheck.getStartStop(parameterMap, null));
-
-        parameterMap.put("Zooby", null);
-        assertEquals(null, ParameterCheck.getStartStop(parameterMap, null));
-
-        AxArtifactKey engineKey = new AxArtifactKey("Engine", "0.0.1");
-
-        parameterMap.put("Zooby", null);
-        assertEquals(null, ParameterCheck.getStartStop(parameterMap, engineKey));
-
-        String key = "AxArtifactKey#" + engineKey.getId();
-        
-        parameterMap.put(key, null);
-        assertEquals(null, ParameterCheck.getStartStop(parameterMap, engineKey));
-
-        String[] startStopBlankValue0 = {"", ""};
-        parameterMap.put(key, startStopBlankValue0);
-        assertEquals(null, ParameterCheck.getStartStop(parameterMap, engineKey));
-
-        String[] startStopBlankValue1 = {" ", " "};
-        parameterMap.put(key, startStopBlankValue1);
-        assertEquals(null, ParameterCheck.getStartStop(parameterMap, engineKey));
-        
-        String[] startStopValueBad = {key, "value"};
-        parameterMap.put(key, startStopValueBad);
-        assertEquals(null, ParameterCheck.getStartStop(parameterMap, engineKey));
-        
-        String[] startValue = {"START", "STOP"};
-        parameterMap.put(key, startValue);
-        assertEquals(ParameterCheck.StartStop.START, ParameterCheck.getStartStop(parameterMap, engineKey));
-
-        String[] stopValue = {"STOP", "START"};
-        parameterMap.put(key, stopValue);
-        assertEquals(ParameterCheck.StartStop.STOP, ParameterCheck.getStartStop(parameterMap, engineKey));
-    }
-
-    @Test
-    public void testLong() {
-        assertEquals(-1, ParameterCheck.getLong(null, null));
-        
-        Map<String, String[]> parameterMap = new LinkedHashMap<>();
-        assertEquals(-1, ParameterCheck.getLong(parameterMap, null));
-        
-        parameterMap.put("long0", null);
-        assertEquals(-1, ParameterCheck.getLong(parameterMap, "longx"));
-        assertEquals(-1, ParameterCheck.getLong(parameterMap, "long0"));
-
-        String[] longBlankValue0 = {"", ""};
-        parameterMap.put("long1", longBlankValue0);
-        assertEquals(-1, ParameterCheck.getLong(parameterMap, "long1"));
-
-        String[] longBlankValue1 = {" ", " "};
-        parameterMap.put("long2", longBlankValue1);
-        assertEquals(-1, ParameterCheck.getLong(parameterMap, "long2"));
-        
-        String[] longValueBad = {"long", "value"};
-        parameterMap.put("long3", longValueBad);
-        assertEquals(-1, ParameterCheck.getLong(parameterMap, "long3"));
-        
-        String[] longValue = {"12345", "6789"};
-        parameterMap.put("long4", longValue);
-        assertEquals(12345, ParameterCheck.getLong(parameterMap, "long4"));
-    }
-}
diff --git a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java b/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java
deleted file mode 100644
index e8e7e9251..000000000
--- a/client/client-monitoring/src/test/java/org/onap/policy/apex/client/monitoring/rest/RestResourceTest.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.client.monitoring.rest;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.onap.policy.apex.core.deployment.ApexDeploymentException;
-import org.onap.policy.apex.core.deployment.EngineServiceFacade;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
-
-/**
- * Test the monitoring rest resource.
- */
-public class RestResourceTest {
-    @Mock
-    private EngineServiceFacade engineServiceFacadeMock;
-    private ApexMonitoringRestResource restResource;
-
-    /**
-     * Set up mocking of the engine service facade.
-     *
-     * @throws ApexException on engine service facade setup errors
-     */
-    @Before
-    public void initializeMocking() throws ApexException {
-        MockitoAnnotations.initMocks(this);
-
-        final AxArtifactKey engineServiceKey = new AxArtifactKey("EngineServiceKey", "0.0.1");
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-        final AxArtifactKey[] engineServiceKeyArray =
-            { engineKey };
-        final AxEngineModel engineModel = new AxEngineModel(engineServiceKeyArray[0]);
-
-        restResource = Mockito.spy(new ApexMonitoringRestResource());
-        Mockito.doReturn(engineServiceFacadeMock).when(restResource).getEngineServiceFacade("apexServer", 12345);
-
-        Mockito.doReturn(engineServiceKey).when(engineServiceFacadeMock).getKey();
-        Mockito.doReturn(engineServiceKeyArray).when(engineServiceFacadeMock).getEngineKeyArray();
-        Mockito.doReturn(engineModel).when(engineServiceFacadeMock).getEngineStatus(engineKey);
-    }
-
-    @Test
-    public void testRestResourceCreateSession() throws ApexException {
-        Response response = restResource.createSession("apexServer", 12345);
-        assertEquals(200, response.getStatus());
-        assertTrue(((String) response.getEntity()).contains("Engine0:0.0.1"));
-    }
-
-    @Test
-    public void testRestResourceCreateSessionWithApexModelKey() throws ApexException {
-        Mockito.doReturn(new AxArtifactKey("ModelKey:0.0.1")).when(engineServiceFacadeMock).getApexModelKey();
-
-        Response response = restResource.createSession("apexServer", 12345);
-        assertEquals(200, response.getStatus());
-        assertTrue(((String) response.getEntity()).contains("Engine0:0.0.1"));
-    }
-
-    @Test
-    public void testRestResourceCreateSessionConnectException() throws ApexException {
-        Mockito.doThrow(new ApexDeploymentException("Connection Failed")).when(engineServiceFacadeMock).init();
-
-        Response response = restResource.createSession("apexServer", 12345);
-        assertEquals(500, response.getStatus());
-        assertTrue(((String) response.getEntity()).contains("Error connecting to Apex Engine Service"));
-    }
-
-    @Test
-    public void testRestResourceCreateSessionGetException() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-        Mockito.doThrow(new ApexException("Exception on get")).when(engineServiceFacadeMock).getEngineStatus(engineKey);
-
-        Response response = restResource.createSession("apexServer", 12345);
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceCreateSessionInfo() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-        Mockito.doReturn("{}").when(engineServiceFacadeMock).getEngineInfo(engineKey);
-
-        Response response = restResource.createSession("apexServer", 12345);
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceCreateSessionNullInfo() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-        Mockito.doReturn(null).when(engineServiceFacadeMock).getEngineInfo(engineKey);
-
-        Response response = restResource.createSession("apexServer", 12345);
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceCreateSessionEmptyInfo() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-        Mockito.doReturn(" ").when(engineServiceFacadeMock).getEngineInfo(engineKey);
-
-        Response response = restResource.createSession("apexServer", 12345);
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceCreateSessionExceptionInfo() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-        Mockito.doThrow(new ApexException("Exception on info")).when(engineServiceFacadeMock).getEngineInfo(engineKey);
-
-        Response response = restResource.createSession("apexServer", 12345);
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceStartEngine() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-
-        Response response = restResource.startStop("apexServer", 12345, engineKey.getId(), "Start");
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceStopEngine() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-
-        Response response = restResource.startStop("apexServer", 12345, engineKey.getId(), "Stop");
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceNotStartStopEngine() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-
-        Response response = restResource.startStop("apexServer", 12345, engineKey.getId(), "Hello");
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceInitExceptionStartStopEngine() throws ApexException {
-        Mockito.doThrow(new ApexDeploymentException("Exception on init")).when(engineServiceFacadeMock).init();
-
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-
-        Response response = restResource.startStop("apexServer", 12345, engineKey.getId(), "Hello");
-        assertEquals(500, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceExceptionStartStopEngine() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-        Mockito.doThrow(new ApexDeploymentException("Exception on Start/Stop")).when(engineServiceFacadeMock)
-                        .startEngine(engineKey);
-
-        Response response = restResource.startStop("apexServer", 12345, engineKey.getId(), "Start");
-        assertEquals(500, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceStartPeriodicEvents() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-
-        Response response = restResource.periodiceventStartStop("apexServer", 12345, engineKey.getId(), "Start", 1000);
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceStopPeriodicEvents() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-
-        Response response = restResource.periodiceventStartStop("apexServer", 12345, engineKey.getId(), "Stop", 1000);
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceNotStartStopPeriodicEvents() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-
-        Response response = restResource.periodiceventStartStop("apexServer", 12345, engineKey.getId(), "Hello", 1000);
-        assertEquals(200, response.getStatus());
-    }
-
-    @Test
-    public void testRestResourceExceptionPeriodicEvents() throws ApexException {
-        final AxArtifactKey engineKey = new AxArtifactKey("Engine0", "0.0.1");
-        Mockito.doThrow(new ApexDeploymentException("Exception on Periodic Events")).when(engineServiceFacadeMock)
-                        .stopPerioidicEvents(engineKey);
-
-        Response response = restResource.periodiceventStartStop("apexServer", 12345, engineKey.getId(), "Stop", 1000);
-        assertEquals(500, response.getStatus());
-    }
-
-    @Test
-    public void testCounter() {
-        ApexMonitoringRestResource.Counter counter = restResource.new Counter(1538338576, 1538338592);
-
-        assertEquals(1538338576, counter.getTimestamp());
-        assertEquals(1538338592, counter.getValue());
-    }
-
-    @Test
-    public void testSlidingWindow() {
-        ApexMonitoringRestResource.SlidingWindowList<String> slidingWindowList0 = restResource.new SlidingWindowList<>(
-                        2);
-
-        assertNotEquals(0, slidingWindowList0.hashCode());
-
-        assertTrue(slidingWindowList0.add("Hello"));
-        assertTrue(slidingWindowList0.add("Hi"));
-        assertTrue(slidingWindowList0.add("Howdy"));
-
-        assertNotNull(slidingWindowList0);
-        // disabling sonar because this code tests the equals() method
-        assertEquals(slidingWindowList0, slidingWindowList0); // NOSONAR
-        ApexMonitoringRestResource.SlidingWindowList<String> slidingWindowList1 = restResource.new SlidingWindowList<>(
-                        2);
-        ApexMonitoringRestResource.SlidingWindowList<String> slidingWindowList2 = restResource.new SlidingWindowList<>(
-                        2);
-        assertNotEquals(slidingWindowList0, slidingWindowList1);
-        assertNotEquals(slidingWindowList0, slidingWindowList2);
-        assertEquals(slidingWindowList1, slidingWindowList2);
-        ApexMonitoringRestResource.SlidingWindowList<String> slidingWindowList3 = restResource.new SlidingWindowList<>(
-                        3);
-        assertNotEquals(slidingWindowList1, slidingWindowList3);
-        ApexMonitoringRestResource.SlidingWindowList<Integer> slidingWindowList4 = restResource.new SlidingWindowList<>(
-                        3);
-        assertTrue(slidingWindowList3.add("Hello"));
-        assertTrue(slidingWindowList4.add(10));
-        assertNotEquals(slidingWindowList3, slidingWindowList4);
-    }
-
-    @Test
-    public void mopUp() {
-        assertEquals(engineServiceFacadeMock, restResource.getEngineServiceFacade("apexServer", 12345));
-    }
-}
-- 
cgit