From 7be95544827a95524a9b683d946ee7473e6854f9 Mon Sep 17 00:00:00 2001 From: brunomilitzer Date: Fri, 21 Jan 2022 09:52:42 +0000 Subject: Removed PDP Monitoring from GUI Issue-ID: POLICY-3888 Change-Id: If59a7b7ad3074e718772051e2a13134eadb54997 Signed-off-by: brunomilitzer --- .../pdp/monitoring/MonitoringExceptionTest.java | 39 ----- .../gui/pdp/monitoring/MonitoringMainTest.java | 169 --------------------- .../gui/pdp/monitoring/MonitoringRestTest.java | 41 ----- .../gui/pdp/monitoring/rest/EngineStatusTest.java | 40 ----- .../monitoring/rest/StatisticsResponseTest.java | 39 ----- 5 files changed, 328 deletions(-) delete mode 100644 gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringExceptionTest.java delete mode 100644 gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringMainTest.java delete mode 100644 gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringRestTest.java delete mode 100644 gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/rest/EngineStatusTest.java delete mode 100644 gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/rest/StatisticsResponseTest.java (limited to 'gui-pdp-monitoring/src/test/java') diff --git a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringExceptionTest.java b/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringExceptionTest.java deleted file mode 100644 index 80262e9..0000000 --- a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringExceptionTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Inc. - * ================================================================================ - * 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.gui.pdp.monitoring; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.policy.common.utils.test.ExceptionsTester; - -/** - * Test the Pdp monitoring exception. - * - */ -public class MonitoringExceptionTest { - - @Test - public void test() { - assertEquals(2, new ExceptionsTester().test(PdpMonitoringServerParameterException.class)); - } -} diff --git a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringMainTest.java b/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringMainTest.java deleted file mode 100644 index 3606b44..0000000 --- a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringMainTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.gui.pdp.monitoring; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.catchThrowable; -import static org.junit.Assert.fail; - -import org.junit.Test; - -/** - * Test the periodic event manager utility. - */ -public class MonitoringMainTest { - @Test - public void testMonitoringServerBad() { - try { - final String[] eventArgs = {"-z"}; - - PdpMonitoringMain.main(eventArgs); - } catch (Exception exc) { - fail("test should not throw an exception"); - } - } - - @Test - public void testMonitoringServerOk() { - try { - final String[] eventArgs = {"-t", "1"}; - - PdpMonitoringMain.main(eventArgs); - } catch (Exception exc) { - fail("test should not throw an exception"); - } - } - - @Test - public void testMonitoringServerBadOptions() { - final String[] eventArgs = {"-zabbu"}; - Throwable thrown = catchThrowable(() -> new PdpMonitoringMain(eventArgs)); - assertThat(thrown).isInstanceOf(PdpMonitoringServerParameterException.class) - .hasMessageContaining("parameter error, invalid command line arguments specified"); - - } - - @Test - public void testMonitoringServerHelp() { - final String[] eventArgs = {"-h"}; - Throwable thrown = catchThrowable(() -> new PdpMonitoringMain(eventArgs)); - assertThat(thrown).isInstanceOf(PdpMonitoringServerParameterException.class).hasMessageContaining( - "usage: org.onap.policy.gui.pdp.monitoring.PdpMonitoringMain [options...]"); - } - - @Test - public void testMonitoringServerPortBad() { - final String[] eventArgs = {"-p", "hello"}; - Throwable thrown = catchThrowable(() -> new PdpMonitoringMain(eventArgs)); - assertThat(thrown).isInstanceOf(PdpMonitoringServerParameterException.class) - .hasMessageContaining("error parsing argument \"port\""); - } - - @Test - public void testMonitoringServerPortNegative() { - final String[] eventArgs = {"-p", "-1"}; - Throwable thrown = catchThrowable(() -> new PdpMonitoringMain(eventArgs)); - assertThat(thrown).isInstanceOf(PdpMonitoringServerParameterException.class).hasMessageContaining( - "item \"port\" value \"-1\" INVALID, is below the minimum value: 1024"); - } - - @Test - public void testMonitoringServerTtlTooSmall() { - final String[] eventArgs = {"-t", "-2"}; - - Throwable thrown = catchThrowable(() -> new PdpMonitoringMain(eventArgs)); - assertThat(thrown).isInstanceOf(PdpMonitoringServerParameterException.class) - .hasMessageContaining("item \"timeToLive\" value \"-2\" INVALID, is below the minimum value: -1"); - } - - @Test - public void testMonitoringServerTooManyPars() { - final String[] eventArgs = {"-t", "10", "-p", "12344", "aaa", "bbb"}; - - Throwable thrown = catchThrowable(() -> new PdpMonitoringMain(eventArgs)); - assertThat(thrown).isInstanceOf(PdpMonitoringServerParameterException.class) - .hasMessageContaining("parameter error, too many command line arguments specified : [aaa, bbb]"); - } - - @Test - public void testMonitoringServerTtlNotNumber() { - final String[] eventArgs = {"-t", "timetolive"}; - - Throwable thrown = catchThrowable(() -> new PdpMonitoringMain(eventArgs)); - assertThat(thrown).isInstanceOf(PdpMonitoringServerParameterException.class).hasMessageContaining( - "parameter error, error parsing argument \"time-to-live\""); - } - - @Test - public void testMonitoringServerPortTooBig() { - final String[] eventArgs = {"-p", "65536"}; - - Throwable thrown = catchThrowable(() -> new PdpMonitoringMain(eventArgs)); - assertThat(thrown).isInstanceOf(PdpMonitoringServerParameterException.class) - .hasMessageContaining("item \"port\" value \"65536\" INVALID, exceeds the maximum value: 65534"); - } - - @Test - public void testMonitoringOneSecStart() { - final String[] eventArgs = {"-t", "1"}; - - try { - PdpMonitoringMain monRestMain = new PdpMonitoringMain(eventArgs); - monRestMain.init(); - monRestMain.shutdown(); - - } catch (Exception ex) { - fail("test should not throw an exception"); - } - } - - @Test - public void testMonitoringForeverStart() { - final String[] eventArgs = {"-t", "-1"}; - - var monRestMain = new PdpMonitoringMain(eventArgs); - - Thread monThread = new Thread() { - @Override - public void run() { - monRestMain.init(); - } - }; - - try { - monThread.start(); - /* - * For some reason, getResource("webapp") returns null to PdpMonitoringServer, - * which results in an NPE, thus the server never gets started (in ANY of - * these test cases). Therefore, commented out the code that waits for it to - * start. - */ - // assertThat(monRestMain.awaitStart(5, TimeUnit.SECONDS)).isTrue(); - monRestMain.shutdown(); - monThread.join(5000); - assertThat(monThread.isAlive()).isFalse(); - } catch (Exception ex) { - monRestMain.shutdown(); - fail("test should not throw an exception"); - } - } -} diff --git a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringRestTest.java b/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringRestTest.java deleted file mode 100644 index a8459cd..0000000 --- a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/MonitoringRestTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.gui.pdp.monitoring; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * monitoring rest tests. - * - */ -public class MonitoringRestTest { - - @Test - public void test() { - var parameters = new PdpMonitoringServerParameters(); - parameters.setPort(12345); - assertEquals(12345, parameters.getPort()); - } - -} diff --git a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/rest/EngineStatusTest.java b/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/rest/EngineStatusTest.java deleted file mode 100644 index 46a19dc..0000000 --- a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/rest/EngineStatusTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2020 AT&T - * ================================================================================ - * 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.gui.pdp.monitoring.rest; - -import com.openpojo.reflection.filters.FilterClassName; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.SetterTester; -import org.junit.Test; - -public class EngineStatusTest { - - @Test - public void testEngineStatus() { - final Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule()) - .with(new SetterTester()).build(); - validator.validate(EngineStatus.class.getPackage().getName(), - new FilterClassName(EngineStatus.class.getName())); - } - -} diff --git a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/rest/StatisticsResponseTest.java b/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/rest/StatisticsResponseTest.java deleted file mode 100644 index d38f08c..0000000 --- a/gui-pdp-monitoring/src/test/java/org/onap/policy/gui/pdp/monitoring/rest/StatisticsResponseTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2020 AT&T - * ================================================================================ - * 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.gui.pdp.monitoring.rest; - -import com.openpojo.reflection.filters.FilterClassName; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.SetterTester; -import org.junit.Test; - -public class StatisticsResponseTest { - - @Test - public void testStatisticsResponse() { - final Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule()) - .with(new SetterTester()).build(); - validator.validate(StatisticsResponse.class.getPackage().getName(), - new FilterClassName(StatisticsResponse.class.getName())); - } -} -- cgit 1.2.3-korg