aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuresh Charan <suresh.charan@bell.ca>2023-03-29 20:01:21 -0400
committerSuresh Charan <suresh.charan@bell.ca>2023-08-08 16:17:43 -0400
commit535f62b4b4870505d2351ed098415d8d643b2ace (patch)
tree2cf242cc90b5c7d6a640852f88ca1ad3639d6fdc
parent029c9b9ca902c0443b6b6cc3a4dbad99ebf180e9 (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>
-rw-r--r--main/pom.xml3
-rw-r--r--main/src/main/java/org/onap/policy/api/main/config/PolicyApiConfig.java40
-rw-r--r--main/src/main/java/org/onap/policy/api/main/exception/ServiceExceptionHandler.java5
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java174
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/ApiStatisticsManager.java235
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsProvider.java50
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsReport.java55
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/stub/ApiRestControllerStub.java8
-rw-r--r--main/src/main/resources/META-INF/persistence.xml2
-rw-r--r--main/src/main/resources/openapi/openapi.yaml120
-rw-r--r--main/src/test/java/org/onap/policy/api/contract/ApiContractTest.java2
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java53
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java70
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestStatisticsReport.java49
-rw-r--r--main/src/test/resources/META-INF/persistence.xml2
-rw-r--r--postman/lifecycle-api-collection.json32
16 files changed, 12 insertions, 888 deletions
diff --git a/main/pom.xml b/main/pom.xml
index 2f2b5bb9..893cec03 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -3,7 +3,7 @@
Copyright (C) 2018 Ericsson. All rights reserved.
Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
Copyright (C) 2019,2021 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2020-2022 Bell Canada.
+ Modifications Copyright (C) 2020-2023 Bell Canada.
Modifications Copyright (C) 2022-2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
@@ -149,7 +149,6 @@
ToscaServiceTemplate=org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate,
ToscaNodeTemplateArray=java.util.List,
HealthCheckReport=org.onap.policy.common.endpoints.report.HealthCheckReport,
- StatisticsReport=org.onap.policy.api.main.rest.provider.statistics.StatisticsReport,
PolicyFetchMode=org.onap.policy.api.main.rest.PolicyFetchMode
</importMappings>
<configOptions>
diff --git a/main/src/main/java/org/onap/policy/api/main/config/PolicyApiConfig.java b/main/src/main/java/org/onap/policy/api/main/config/PolicyApiConfig.java
deleted file mode 100644
index 0510d65f..00000000
--- a/main/src/main/java/org/onap/policy/api/main/config/PolicyApiConfig.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2022 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.api.main.config;
-
-import org.onap.policy.api.main.rest.provider.statistics.StatisticsReport;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class PolicyApiConfig {
-
- /**
- * Initialize the statistics report bean.
- *
- * @return a new instance of StatisticsReport
- */
- @Bean
- public StatisticsReport createStatisticsReport() {
- return new StatisticsReport();
- }
-} \ No newline at end of file
diff --git a/main/src/main/java/org/onap/policy/api/main/exception/ServiceExceptionHandler.java b/main/src/main/java/org/onap/policy/api/main/exception/ServiceExceptionHandler.java
index 1909e199..93240df9 100644
--- a/main/src/main/java/org/onap/policy/api/main/exception/ServiceExceptionHandler.java
+++ b/main/src/main/java/org/onap/policy/api/main/exception/ServiceExceptionHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022-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.
@@ -61,8 +61,7 @@ public class ServiceExceptionHandler {
* @param joinPoint the point of execution
* @param exception the exception
*/
- @AfterThrowing(pointcut = "execution(* org.onap.policy.api.main..*.*(..))"
- + " && !execution(* org.onap.policy.api.main.rest.provider.statistics.*.*(..))", throwing = "exception")
+ @AfterThrowing(pointcut = "execution(* org.onap.policy.api.main..*.*(..))", throwing = "exception")
public void handleTransactionException(JoinPoint joinPoint, TransactionException exception) {
final var errorResponse = new ErrorResponse();
errorResponse.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR);
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
index 47d82927..a1e6db25 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
@@ -5,7 +5,7 @@
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020-2022 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.
@@ -32,9 +32,6 @@ import lombok.RequiredArgsConstructor;
import org.onap.policy.api.main.exception.PolicyApiRuntimeException;
import org.onap.policy.api.main.rest.genapi.PolicyDesignApi;
import org.onap.policy.api.main.rest.provider.healthcheck.HealthCheckProvider;
-import org.onap.policy.api.main.rest.provider.statistics.ApiStatisticsManager;
-import org.onap.policy.api.main.rest.provider.statistics.StatisticsProvider;
-import org.onap.policy.api.main.rest.provider.statistics.StatisticsReport;
import org.onap.policy.api.main.service.ToscaServiceTemplateService;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
@@ -67,8 +64,6 @@ public class ApiRestController extends CommonRestController implements PolicyDes
private final ToscaServiceTemplateService toscaServiceTemplateService;
private final HealthCheckProvider healthCheckProvider;
- private final ApiStatisticsManager mgr;
- private final StatisticsProvider statisticsProvider;
/**
* Retrieves the healthcheck status of the API component.
@@ -78,22 +73,10 @@ public class ApiRestController extends CommonRestController implements PolicyDes
@Override
public ResponseEntity<HealthCheckReport> getHealthCheck(UUID requestId) {
final var report = healthCheckProvider.performHealthCheck();
- updateApiStatisticsCounter(Target.OTHER, HttpStatus.resolve(report.getCode()), HttpMethod.GET);
return makeResponse(requestId, report, report.getCode());
}
/**
- * Retrieves the statistics report of the API component.
- *
- * @return the Response object containing the results of the API operation
- */
- @Override
- public ResponseEntity<StatisticsReport> getStatistics(UUID requestId) {
- updateApiStatisticsCounter(Target.OTHER, HttpStatus.OK, HttpMethod.GET);
- return makeOkResponse(requestId, statisticsProvider.fetchCurrentStatistics());
- }
-
- /**
* Retrieves all available policy types.
*
* @return the Response object containing the results of the API operation
@@ -102,12 +85,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
public ResponseEntity<ToscaServiceTemplate> getAllPolicyTypes(UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(null, null);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
final var msg = "GET /policytypes";
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -125,12 +105,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, null);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
var msg = String.format("GET /policytypes/%s", policyTypeId);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -151,12 +128,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicyTypes(policyTypeId, versionId);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
var msg = String.format("GET /policytypes/%s/versions/%s", policyTypeId, versionId);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -174,12 +148,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
UUID requestId) {
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.fetchLatestPolicyTypes(policyTypeId);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
var msg = String.format("GET /policytypes/%s/versions/latest", policyTypeId);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -200,12 +171,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
}
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.createPolicyType(body);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.POST);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelRuntimeException pfme) {
final var msg = "POST /policytypes";
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.POST);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -226,12 +194,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.deletePolicyType(policyTypeId, versionId);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.OK, HttpMethod.DELETE);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelRuntimeException pfme) {
var msg = String.format("DELETE /policytypes/%s/versions/%s", policyTypeId, versionId);
- updateApiStatisticsCounter(Target.POLICY_TYPE, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.DELETE);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -253,12 +218,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, null, null, mode);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
var msg = String.format("GET /policytypes/%s/versions/%s/policies", policyTypeId, policyTypeVersion);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -282,13 +244,10 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicies(policyTypeId, policyTypeVersion, policyId, null, mode);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
var msg = String.format("/policytypes/%s/versions/%s/policies/%s",
policyTypeId, policyTypeVersion, policyId);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -314,13 +273,10 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService
.fetchPolicies(policyTypeId, policyTypeVersion, policyId, policyVersion, mode);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
var msg = String.format("GET /policytypes/%s/versions/%s/policies/%s/versions/%s",
policyTypeId, policyTypeVersion, policyId, policyVersion);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -344,13 +300,10 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchLatestPolicies(policyTypeId, policyTypeVersion, policyId, mode);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
var msg = String.format("GET /policytypes/%s/versions/%s/policies/%s/versions/latest",
policyTypeId, policyTypeVersion, policyId);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -377,12 +330,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.createPolicy(policyTypeId, policyTypeVersion, body);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.POST);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelRuntimeException pfme) {
var msg = String.format("POST /policytypes/%s/versions/%s/policies", policyTypeId, policyTypeVersion);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.POST);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -407,13 +357,10 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.DELETE);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelRuntimeException pfme) {
var msg = String.format("DELETE /policytypes/%s/versions/%s/policies/%s/versions/%s",
policyTypeId, policyTypeVersion, policyId, policyVersion);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.DELETE);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -430,12 +377,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicies(null, null, null, null, mode);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
final var msg = "GET /policies/ --";
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
if (pfme.getErrorResponse().getResponseCode().equals(Status.NOT_FOUND)) {
pfme.getErrorResponse().setErrorMessage(ERROR_MESSAGE_NO_POLICIES_FOUND);
pfme.getErrorResponse().setErrorDetails(List.of(ERROR_MESSAGE_NO_POLICIES_FOUND));
@@ -461,12 +405,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.fetchPolicies(null, null, policyId, policyVersion, mode);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
var msg = String.format("GET /policies/%s/versions/%s", policyId, policyVersion);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.GET);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -487,12 +428,9 @@ public class ApiRestController extends CommonRestController implements PolicyDes
}
try {
ToscaServiceTemplate serviceTemplate = toscaServiceTemplateService.createPolicies(body);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.POST);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelRuntimeException pfme) {
final var msg = "POST /policies";
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.POST);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
@@ -513,120 +451,10 @@ public class ApiRestController extends CommonRestController implements PolicyDes
try {
ToscaServiceTemplate serviceTemplate =
toscaServiceTemplateService.deletePolicy(null, null, policyId, policyVersion);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.OK, HttpMethod.DELETE);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelRuntimeException pfme) {
var msg = String.format("DELETE /policies/%s/versions/%s", policyId, policyVersion);
- updateApiStatisticsCounter(Target.POLICY, HttpStatus.resolve(pfme.getErrorResponse().getResponseCode()
- .getStatusCode()), HttpMethod.DELETE);
throw new PolicyApiRuntimeException(msg, pfme.getCause(), pfme.getErrorResponse(), requestId);
}
}
-
- private void updateApiStatisticsCounter(Target target, HttpStatus result, HttpMethod http) {
- mgr.updateTotalApiCallCount();
- switch (target) {
- case POLICY:
- updatePolicyStats(result, http);
- break;
- case POLICY_TYPE:
- updatePolicyTypeStats(result, http);
- break;
- default:
- mgr.updateApiCallSuccessCount();
- break;
- }
- }
-
- private void updatePolicyStats(HttpStatus result, HttpMethod http) {
- if (result.equals(HttpStatus.OK)) {
- switch (http) {
- case GET:
- mgr.updateApiCallSuccessCount();
- mgr.updateTotalPolicyGetCount();
- mgr.updatePolicyGetSuccessCount();
- break;
- case POST:
- mgr.updateApiCallSuccessCount();
- mgr.updateTotalPolicyPostCount();
- mgr.updatePolicyPostSuccessCount();
- break;
- case DELETE:
- mgr.updateApiCallSuccessCount();
- mgr.updateTotalPolicyDeleteCount();
- mgr.updatePolicyDeleteSuccessCount();
- break;
- default:
- mgr.updateApiCallSuccessCount();
- break;
- }
- } else {
- switch (http) {
- case GET:
- mgr.updateApiCallFailureCount();
- mgr.updateTotalPolicyGetCount();
- mgr.updatePolicyGetFailureCount();
- break;
- case POST:
- mgr.updateApiCallFailureCount();
- mgr.updateTotalPolicyPostCount();
- mgr.updatePolicyPostFailureCount();
- break;
- case DELETE:
- mgr.updateApiCallFailureCount();
- mgr.updateTotalPolicyDeleteCount();
- mgr.updatePolicyDeleteFailureCount();
- break;
- default:
- mgr.updateApiCallFailureCount();
- break;
- }
- }
- }
-
- private void updatePolicyTypeStats(HttpStatus result, HttpMethod http) {
- if (result.equals(HttpStatus.OK)) {
- switch (http) {
- case GET:
- mgr.updateApiCallSuccessCount();
- mgr.updateTotalPolicyTypeGetCount();
- mgr.updatePolicyTypeGetSuccessCount();
- break;
- case POST:
- mgr.updateApiCallSuccessCount();
- mgr.updateTotalPolicyTypePostCount();
- mgr.updatePolicyTypePostSuccessCount();
- break;
- case DELETE:
- mgr.updateApiCallSuccessCount();
- mgr.updateTotalPolicyTypeDeleteCount();
- mgr.updatePolicyTypeDeleteSuccessCount();
- break;
- default:
- mgr.updateApiCallSuccessCount();
- break;
- }
- } else {
- switch (http) {
- case GET:
- mgr.updateApiCallFailureCount();
- mgr.updateTotalPolicyTypeGetCount();
- mgr.updatePolicyTypeGetFailureCount();
- break;
- case POST:
- mgr.updateApiCallFailureCount();
- mgr.updateTotalPolicyTypePostCount();
- mgr.updatePolicyTypePostFailureCount();
- break;
- case DELETE:
- mgr.updateApiCallFailureCount();
- mgr.updateTotalPolicyTypeDeleteCount();
- mgr.updatePolicyTypeDeleteFailureCount();
- break;
- default:
- mgr.updateApiCallFailureCount();
- break;
- }
- }
- }
}
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/ApiStatisticsManager.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/ApiStatisticsManager.java
deleted file mode 100644
index c0d95e27..00000000
--- a/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/ApiStatisticsManager.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy API
- * ================================================================================
- * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020-2022 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.
- * 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.provider.statistics;
-
-import lombok.RequiredArgsConstructor;
-import org.springframework.stereotype.Component;
-
-/**
- * Class to hold statistical data for API access.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- */
-@Component
-@RequiredArgsConstructor
-public class ApiStatisticsManager {
-
- private final StatisticsReport report;
-
- private long totalPolicyDeleteCount;
- private long totalPolicyTypeDeleteCount;
- private long policyDeleteSuccessCount;
- private long policyDeleteFailureCount;
- private long policyTypeDeleteSuccessCount;
- private long policyTypeDeleteFailureCount;
-
- /**
- * Method to update the total api call count.
- *
- * @return the updated value of totalApiCallCount
- */
- public long updateTotalApiCallCount() {
- return ++report.totalApiCallCount;
- }
-
- /**
- * Method to update the successful api call count.
- *
- * @return the updated value of apiCallSuccessCount
- */
- public long updateApiCallSuccessCount() {
- return ++report.apiCallSuccessCount;
- }
-
- /**
- * Method to update the failed api call count.
- *
- * @return the updated value of apiCallFailureCount
- */
- public long updateApiCallFailureCount() {
- return ++report.apiCallFailureCount;
- }
-
- /**
- * Method to update the total policy GET count.
- *
- * @return the updated value of totalPolicyGetCount
- */
- public long updateTotalPolicyGetCount() {
- return ++report.totalPolicyGetCount;
- }
-
- /**
- * Method to update the total policy POST count.
- *
- * @return the updated value of totalPolicyPostCount
- */
- public long updateTotalPolicyPostCount() {
- return ++report.totalPolicyPostCount;
- }
-
- /**
- * Method to update the total policy DELETE count.
- *
- * @return the updated value of totalPolicyDeleteCount
- */
- public long updateTotalPolicyDeleteCount() {
- return ++totalPolicyDeleteCount;
- }
-
- /**
- * Method to update the total policyType GET count.
- *
- * @return the updated value of totalPolicyTypeGetCount
- */
- public long updateTotalPolicyTypeGetCount() {
- return ++report.totalPolicyTypeGetCount;
- }
-
- /**
- * Method to update the total policyType POST count.
- *
- * @return the updated value of totalPolicyTypePostCount
- */
- public long updateTotalPolicyTypePostCount() {
- return ++report.totalPolicyTypePostCount;
- }
-
- /**
- * Method to update the total policyType DELETE count.
- *
- * @return the updated value of totalPolicyTypeDeleteCount
- */
- public long updateTotalPolicyTypeDeleteCount() {
- return ++totalPolicyTypeDeleteCount;
- }
-
- /**
- * Method to update successful policy GET count.
- *
- * @return the updated value of policyGetSuccessCount
- */
- public long updatePolicyGetSuccessCount() {
- return ++report.policyGetSuccessCount;
- }
-
- /**
- * Method to update failed policy GET count.
- *
- * @return the updated value of policyGetFailureCount
- */
- public long updatePolicyGetFailureCount() {
- return ++report.policyGetFailureCount;
- }
-
- /**
- * Method to update successful policy POST count.
- *
- * @return the updated value of policyPostSuccessCount
- */
- public long updatePolicyPostSuccessCount() {
- return ++report.policyPostSuccessCount;
- }
-
- /**
- * Method to update failed policy POST count.
- *
- * @return the updated value of policyPostFailureCount
- */
- public long updatePolicyPostFailureCount() {
- return ++report.policyPostFailureCount;
- }
-
- /**
- * Method to update successful policy DELETE count.
- *
- * @return the updated value of policyDeleteSuccessCount
- */
- public long updatePolicyDeleteSuccessCount() {
- return ++policyDeleteSuccessCount;
- }
-
- /**
- * Method to update failed policy DELETE count.
- *
- * @return the updated value of policyDeleteFailureCount
- */
- public long updatePolicyDeleteFailureCount() {
- return ++policyDeleteFailureCount;
- }
-
- /**
- * Method to update successful policyType GET count.
- *
- * @return the updated value of policyTypeGetSuccessCount
- */
- public long updatePolicyTypeGetSuccessCount() {
- return ++report.policyTypeGetSuccessCount;
- }
-
- /**
- * Method to update failed policyType GET count.
- *
- * @return the updated value of policyTypeGetFailureCount
- */
- public long updatePolicyTypeGetFailureCount() {
- return ++report.policyTypeGetFailureCount;
- }
-
- /**
- * Method to update successful policyType POST count.
- *
- * @return the updated value of policyTypePostSuccessCount
- */
- public long updatePolicyTypePostSuccessCount() {
- return ++report.policyTypePostSuccessCount;
- }
-
- /**
- * Method to update failed policyType POST count.
- *
- * @return the updated value of policyTypePostFailureCount
- */
- public long updatePolicyTypePostFailureCount() {
- return ++report.policyTypePostFailureCount;
- }
-
- /**
- * Method to update successful policyType DELETE count.
- *
- * @return the updated value of policyTypeDeleteSuccessCount
- */
- public long updatePolicyTypeDeleteSuccessCount() {
- return ++policyTypeDeleteSuccessCount;
- }
-
- /**
- * Method to update failed policyType DELETE count.
- *
- * @return the updated value of policyTypePostFailureCount
- */
- public long updatePolicyTypeDeleteFailureCount() {
- return ++policyTypeDeleteFailureCount;
- }
-} \ No newline at end of file
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsProvider.java
deleted file mode 100644
index 7016ed40..00000000
--- a/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy API
- * ================================================================================
- * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2022 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.
- * 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.provider.statistics;
-
-import lombok.RequiredArgsConstructor;
-import org.springframework.stereotype.Service;
-
-/**
- * Class to fetch API statistics.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- */
-@Service
-@RequiredArgsConstructor
-public class StatisticsProvider {
-
- private final StatisticsReport report;
-
- /**
- * Return the current API statistics.
- *
- * @return Report containing API statistics
- */
- public StatisticsReport fetchCurrentStatistics() {
- report.setCode(200);
- return report;
- }
-} \ No newline at end of file
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsReport.java b/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsReport.java
deleted file mode 100644
index 3236392a..00000000
--- a/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsReport.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy API
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 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.
- * 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.provider.statistics;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-/**
- * Class to represent API statistics report.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- */
-@ToString
-@Getter
-@Setter
-public class StatisticsReport {
- private int code;
- protected long totalApiCallCount;
- protected long apiCallSuccessCount;
- protected long apiCallFailureCount;
- protected long totalPolicyGetCount;
- protected long totalPolicyPostCount;
- protected long totalPolicyTypeGetCount;
- protected long totalPolicyTypePostCount;
- protected long policyGetSuccessCount;
- protected long policyGetFailureCount;
- protected long policyPostSuccessCount;
- protected long policyPostFailureCount;
- protected long policyTypeGetSuccessCount;
- protected long policyTypeGetFailureCount;
- protected long policyTypePostSuccessCount;
- protected long policyTypePostFailureCount;
-} \ No newline at end of file
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/stub/ApiRestControllerStub.java b/main/src/main/java/org/onap/policy/api/main/rest/stub/ApiRestControllerStub.java
index 4b848904..38fe0032 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/stub/ApiRestControllerStub.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/stub/ApiRestControllerStub.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.
@@ -26,7 +27,6 @@ import lombok.RequiredArgsConstructor;
import org.onap.policy.api.main.rest.CommonRestController;
import org.onap.policy.api.main.rest.PolicyFetchMode;
import org.onap.policy.api.main.rest.genapi.PolicyDesignApi;
-import org.onap.policy.api.main.rest.provider.statistics.StatisticsReport;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.context.annotation.Profile;
@@ -174,10 +174,4 @@ public class ApiRestControllerStub extends CommonRestController implements Polic
return stubUtils.getStubbedResponse(ToscaServiceTemplate.class);
}
- @Override
- public ResponseEntity<StatisticsReport> getStatistics(
- UUID requestID) {
- return stubUtils.getStubbedResponse(StatisticsReport.class);
- }
-
}
diff --git a/main/src/main/resources/META-INF/persistence.xml b/main/src/main/resources/META-INF/persistence.xml
index aabe0f1f..43024eea 100644
--- a/main/src/main/resources/META-INF/persistence.xml
+++ b/main/src/main/resources/META-INF/persistence.xml
@@ -4,6 +4,7 @@
Copyright (C) 2019-2020 Nordix Foundation.
Modifications Copyright (C) 2021 AT&T Intellectual Property.
Modification Copyright 2022 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.
@@ -35,7 +36,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>
diff --git a/main/src/main/resources/openapi/openapi.yaml b/main/src/main/resources/openapi/openapi.yaml
index 5ab7e796..c8f44e5e 100644
--- a/main/src/main/resources/openapi/openapi.yaml
+++ b/main/src/main/resources/openapi/openapi.yaml
@@ -30,7 +30,7 @@ tags:
independent component running rest service that takes all policy design API calls
from clients and then assign them to different API working functions. Besides
that, API is also exposed for clients to retrieve healthcheck status of this API
- rest service and the statistics report including the counters of API invocation.
+ rest service.
paths:
/healthcheck:
get:
@@ -3237,118 +3237,6 @@ paths:
x-interface info:
api-version: 1.0.0
last-mod-release: Dublin
- /statistics:
- get:
- tags:
- - "Policy Design"
- summary: Retrieve current statistics
- description: Returns current statistics including the counters of API invocation
- operationId: getStatistics
- parameters:
- - name: X-ONAP-RequestID
- in: header
- description: RequestID for http transaction
- schema:
- type: string
- format: uuid
- responses:
- 200:
- description: OK, the statistics report in an instance of
- [StatisticsReport](https://github.com/onap/policy-api/blob/master/main/src/main/java/org/onap/policy/api/main/rest/provider/statistics/StatisticsReport.java)
- headers:
- X-LatestVersion:
- schema:
- type: string
- X-PatchVersion:
- schema:
- type: string
- X-MinorVersion:
- schema:
- type: string
- X-onap-RequestId:
- schema:
- type: string
- format: uuid
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/StatisticsReport'
- application/yaml:
- schema:
- $ref: '#/components/schemas/StatisticsReport'
- 401:
- description: Authentication Error
- headers:
- X-LatestVersion:
- schema:
- type: string
- X-PatchVersion:
- schema:
- type: string
- X-MinorVersion:
- schema:
- type: string
- X-ONAP-RequestID:
- schema:
- type: string
- format: uuid
- content: {}
- 403:
- description: Authorization Error
- headers:
- X-LatestVersion:
- schema:
- type: string
- X-PatchVersion:
- schema:
- type: string
- X-MinorVersion:
- schema:
- type: string
- X-ONAP-RequestID:
- schema:
- type: string
- format: uuid
- content: {}
- 404:
- description: Not Found
- headers:
- X-LatestVersion:
- schema:
- type: string
- X-PatchVersion:
- schema:
- type: string
- X-MinorVersion:
- schema:
- type: string
- X-onap-RequestId:
- schema:
- type: string
- format: uuid
- content: {}
- 500:
- description: Internal Server Error
- headers:
- X-LatestVersion:
- schema:
- type: string
- X-PatchVersion:
- schema:
- type: string
- X-MinorVersion:
- schema:
- type: string
- X-ONAP-RequestID:
- schema:
- type: string
- format: uuid
- content: {}
- security:
- - basicAuth: []
- x-interface info:
- api-version: 1.0.0
- last-mod-release: Dublin
components:
securitySchemes:
basicAuth:
@@ -3364,9 +3252,7 @@ components:
HealthCheckReport:
title: HealthCheckReport
type: object
- StatisticsReport:
- title: StatisticsReport
- type: object
PolicyFetchMode:
title: PolicyFetchMode
- type: object \ No newline at end of file
+ type: object
+
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>
diff --git a/postman/lifecycle-api-collection.json b/postman/lifecycle-api-collection.json
index 053f7edb..44dfe40c 100644
--- a/postman/lifecycle-api-collection.json
+++ b/postman/lifecycle-api-collection.json
@@ -70,38 +70,6 @@
"response": []
},
{
- "name": "API Statistics",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/statistics",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "statistics"
- ]
- },
- "description": "This is an API to fetch current statistics information for the policy-api component."
- },
- "response": []
- },
- {
"name": "Create Policy Type",
"request": {
"method": "POST",