diff options
author | Suresh Charan <suresh.charan@bell.ca> | 2023-03-29 20:01:21 -0400 |
---|---|---|
committer | Suresh Charan <suresh.charan@bell.ca> | 2023-08-08 16:17:43 -0400 |
commit | 535f62b4b4870505d2351ed098415d8d643b2ace (patch) | |
tree | 2cf242cc90b5c7d6a640852f88ca1ad3639d6fdc /main/src/test | |
parent | 029c9b9ca902c0443b6b6cc3a4dbad99ebf180e9 (diff) |
Removed db-based statistics feature
Statistics code cleanup
Issue-ID: POLICY-4109
Change-Id: I5ad893deaf365c7e289b57c00260672f127d2630
Signed-off-by: Suresh Charan <suresh.charan@bell.ca>
Diffstat (limited to 'main/src/test')
5 files changed, 3 insertions, 173 deletions
diff --git a/main/src/test/java/org/onap/policy/api/contract/ApiContractTest.java b/main/src/test/java/org/onap/policy/api/contract/ApiContractTest.java index 296c011b..3b90a106 100644 --- a/main/src/test/java/org/onap/policy/api/contract/ApiContractTest.java +++ b/main/src/test/java/org/onap/policy/api/contract/ApiContractTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023 Bell Canada. 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. @@ -85,7 +86,6 @@ public class ApiContractTest extends CommonTestRestController { + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/latest"); checkStubJsonGet("policytypes/380d5cb1-e43d-45b7-b10b-ebd15dfabd16/versions/1.0.0/policies/" + "9c65fa1f-2833-4076-a64d-5b62e35cd09b/versions/1.2.3"); - checkStubJsonGet("statistics"); checkStubJsonGet("healthcheck"); checkStubJsonPost("policies"); diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java index a1d67dcd..7442a8cc 100644 --- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java +++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java @@ -3,7 +3,7 @@ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved. * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-2020,2022-2023 Nordix Foundation. - * Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2020-2023 Bell Canada. 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. @@ -40,8 +40,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.policy.api.main.PolicyApiApplication; -import org.onap.policy.api.main.rest.provider.statistics.ApiStatisticsManager; -import org.onap.policy.api.main.rest.provider.statistics.StatisticsReport; import org.onap.policy.api.main.rest.utils.CommonTestRestController; import org.onap.policy.common.endpoints.report.HealthCheckReport; import org.onap.policy.common.utils.coder.StandardCoder; @@ -51,7 +49,6 @@ import org.onap.policy.common.utils.resources.TextFileUtils; import org.onap.policy.common.utils.security.SelfSignedKeyStore; import org.onap.policy.models.errors.concepts.ErrorResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.test.annotation.DirtiesContext; @@ -79,7 +76,6 @@ public class TestApiRestServer extends CommonTestRestController { private static final String APP_YAML = "application/yaml"; private static final String HEALTHCHECK_ENDPOINT = "healthcheck"; - private static final String STATISTICS_ENDPOINT = "statistics"; private static final String OP_POLICY_NAME_VCPE = "operational.restart"; @@ -159,9 +155,6 @@ public class TestApiRestServer extends CommonTestRestController { @LocalServerPort private int apiPort; - @Autowired - private ApiStatisticsManager mgr; - /** * Initializes parameters and set up test environment. * @@ -330,27 +323,6 @@ public class TestApiRestServer extends CommonTestRestController { } @Test - public void testApiStatistics_200_Json() throws Exception { - testApiStatistics_200(APP_JSON); - } - - @Test - public void testApiStatistics_200_Yaml() throws Exception { - testApiStatistics_200(APP_YAML); - } - - private void testApiStatistics_200(String mediaType) throws Exception { - Invocation.Builder invocationBuilder = sendHttpsRequest(CONTEXT_PATH, STATISTICS_ENDPOINT, mediaType, apiPort); - StatisticsReport report = invocationBuilder.get(StatisticsReport.class); - validateStatisticsReport(report, 200); - updateApiStatistics(); - invocationBuilder = sendHttpsRequest(CONTEXT_PATH, STATISTICS_ENDPOINT, mediaType, apiPort); - report = invocationBuilder.get(StatisticsReport.class); - validateStatisticsReport(report, 200); - // ApiStatisticsManager.resetAllStatistics(); - } - - @Test public void testReadPolicyTypesJson() throws Exception { testReadPolicyTypes(APP_JSON); } @@ -704,29 +676,6 @@ public class TestApiRestServer extends CommonTestRestController { } - private void updateApiStatistics() { - mgr.updateTotalApiCallCount(); - mgr.updateApiCallSuccessCount(); - mgr.updateApiCallFailureCount(); - mgr.updateTotalPolicyGetCount(); - mgr.updateTotalPolicyPostCount(); - mgr.updateTotalPolicyTypeGetCount(); - mgr.updateTotalPolicyTypePostCount(); - mgr.updatePolicyGetSuccessCount(); - mgr.updatePolicyGetFailureCount(); - mgr.updatePolicyPostSuccessCount(); - mgr.updatePolicyPostFailureCount(); - mgr.updatePolicyTypeGetSuccessCount(); - mgr.updatePolicyTypeGetFailureCount(); - mgr.updatePolicyTypePostSuccessCount(); - mgr.updatePolicyTypePostFailureCount(); - } - - private void validateStatisticsReport(final StatisticsReport report, final int code) { - - assertEquals(code, report.getCode()); - } - private void validateHealthCheckReport(final String name, final String url, final boolean healthy, final int code, final String message, final HealthCheckReport report) { diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java deleted file mode 100644 index 0e01ee40..00000000 --- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP Policy API - * ================================================================================ - * Copyright (C) 2019 IBM. - * Modifications Copyright (C) 2020-2022 Bell Canada. - * 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.api.main.rest; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.policy.api.main.PolicyApiApplication; -import org.onap.policy.api.main.rest.provider.statistics.ApiStatisticsManager; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = PolicyApiApplication.class) -@ActiveProfiles({ "test", "default" }) -public class TestApiStatisticsManager { - - @Autowired - private ApiStatisticsManager mgr; - - @Test - public void testUpdateMethods() { - assertEquals(1, mgr.updateTotalApiCallCount()); - assertEquals(1, mgr.updateApiCallSuccessCount()); - assertEquals(1, mgr.updateApiCallFailureCount()); - assertEquals(1, mgr.updateTotalPolicyGetCount()); - assertEquals(1, mgr.updateTotalPolicyPostCount()); - assertEquals(1, mgr.updateTotalPolicyDeleteCount()); - assertEquals(1, mgr.updateTotalPolicyTypeGetCount()); - assertEquals(1, mgr.updateTotalPolicyTypePostCount()); - assertEquals(1, mgr.updateTotalPolicyTypeDeleteCount()); - assertEquals(1, mgr.updatePolicyGetSuccessCount()); - assertEquals(1, mgr.updatePolicyGetFailureCount()); - assertEquals(1, mgr.updatePolicyPostSuccessCount()); - assertEquals(1, mgr.updatePolicyPostFailureCount()); - assertEquals(1, mgr.updatePolicyDeleteSuccessCount()); - assertEquals(1, mgr.updatePolicyDeleteFailureCount()); - assertEquals(1, mgr.updatePolicyTypeGetSuccessCount()); - assertEquals(1, mgr.updatePolicyTypeGetFailureCount()); - assertEquals(1, mgr.updatePolicyTypePostSuccessCount()); - assertEquals(1, mgr.updatePolicyTypePostFailureCount()); - assertEquals(1, mgr.updatePolicyTypeDeleteSuccessCount()); - assertEquals(1, mgr.updatePolicyTypeDeleteFailureCount()); - } -}
\ No newline at end of file diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestStatisticsReport.java b/main/src/test/java/org/onap/policy/api/main/rest/TestStatisticsReport.java deleted file mode 100644 index 664c9591..00000000 --- a/main/src/test/java/org/onap/policy/api/main/rest/TestStatisticsReport.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP Policy API - * ================================================================================ - * Copyright (C) 2019 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.api.main.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.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; -import org.junit.Test; -import org.onap.policy.api.main.rest.provider.statistics.StatisticsReport; -import org.onap.policy.common.utils.test.ToStringTester; - -/** - * Class to perform unit testing of {@link StatisticsReport}. - * - * @author Chenfei Gao (cgao@research.att.com) - */ -public class TestStatisticsReport { - - @Test - public void testStatisticsReport() { - final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterMustExistRule()) - .with(new SetterTester()).with(new GetterTester()).build(); - validator.validate(StatisticsReport.class.getPackage().getName(), - new FilterClassName(StatisticsReport.class.getName())); - } -}
\ No newline at end of file diff --git a/main/src/test/resources/META-INF/persistence.xml b/main/src/test/resources/META-INF/persistence.xml index c302de00..68f49dae 100644 --- a/main/src/test/resources/META-INF/persistence.xml +++ b/main/src/test/resources/META-INF/persistence.xml @@ -3,6 +3,7 @@ ============LICENSE_START======================================================= Copyright (C) 2019-2020 Nordix Foundation. Modifications Copyright (C) 2021 AT&T Intellectual Property. + Modifications Copyright (C) 2023 Bell Canada. 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. @@ -30,7 +31,6 @@ <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdp</class> <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup</class> <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpPolicyStatus</class> - <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpStatistics</class> <class>org.onap.policy.models.pdp.persistence.concepts.JpaPdpSubGroup</class> <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignment</class> <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaCapabilityAssignments</class> |