aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/pap/contract/PapContractTest.java10
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java165
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java5
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPapStatisticsManager.java95
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java23
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsReport.java47
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java103
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java20
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java199
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java193
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java5
-rw-r--r--main/src/test/resources/application-test-e2e.yaml1
-rw-r--r--main/src/test/resources/application-test.yaml1
-rw-r--r--main/src/test/resources/parameters/MinimumParameters.json1
-rw-r--r--main/src/test/resources/parameters/PapConfigParameters.json1
-rw-r--r--main/src/test/resources/parameters/PapConfigParametersStd.json1
16 files changed, 8 insertions, 862 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/contract/PapContractTest.java b/main/src/test/java/org/onap/policy/pap/contract/PapContractTest.java
index f2440381..7b9698bb 100644
--- a/main/src/test/java/org/onap/policy/pap/contract/PapContractTest.java
+++ b/main/src/test/java/org/onap/policy/pap/contract/PapContractTest.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.
@@ -39,15 +40,6 @@ public class PapContractTest extends CommonPapRestServer {
}
@Test
- public void testStubsStatistics() throws Exception {
- checkStubJsonGet("pdps/statistics");
- checkStubJsonGet("pdps/statistics/group");
- checkStubJsonGet("pdps/statistics/group/type");
- checkStubJsonGet("pdps/statistics/group/type/pdp");
- checkStubJsonGet("statistics");
- }
-
- @Test
public void testStubsPolicies() throws Exception {
checkStubJsonGet("policies/audit");
checkStubJsonGet("policies/audit/group");
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
index 34c20410..20e34f62 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-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,19 +26,16 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
-import java.text.ParseException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import java.util.stream.Collectors;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.PdpGroup;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -77,7 +74,6 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
addGroups("PdpGroups.json");
PapParameterGroup parameterGroup = new PapParameterGroup();
parameterGroup.setPdpParameters(new PdpParameters());
- parameterGroup.setSavePdpStatisticsInDb(true);
// Testing pdp registration success case
final PdpStatus status1 = new PdpStatus();
@@ -227,164 +223,16 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
policies.add(polA);
policies.add(polB);
final PapParameterGroup testGroup = new CommonTestData().getPapParameterGroup(1);
- testGroup.setSavePdpStatisticsInDb(true);
List<ToscaConceptIdentifier> polsUndep =
policies.stream().map(ToscaPolicy::getIdentifier).collect(Collectors.toList());
- PdpStatusMessageHandler handler = new PdpStatusMessageHandler(testGroup, pdpGroupService,
- pdpStatisticsService);
+ PdpStatusMessageHandler handler = new PdpStatusMessageHandler(testGroup, pdpGroupService);
PdpUpdate update10 =
handler.createPdpUpdateMessage(status3.getPdpGroup(), new PdpSubGroup(), "pdp_2", policies, polsUndep);
assertSame(update10.getPoliciesToBeDeployed(), policies);
assertSame(update10.getPoliciesToBeUndeployed(), polsUndep);
assertThat(update10.getPoliciesToBeDeployed()).isInstanceOf(List.class);
}
-
- @Test
- public void testPdpStatistics() throws CoderException, PfModelException, ParseException {
- addGroups("PdpGroups.json");
- PapParameterGroup parameterGroup = new PapParameterGroup();
- parameterGroup.setPdpParameters(new PdpParameters());
- parameterGroup.setSavePdpStatisticsInDb(true);
- timeStamp = Instant.parse("2021-02-12T17:48:01.029211400Z");
-
- // init default pdp group
- final PdpStatus status1 = new PdpStatus();
- status1.setName(PDP_NAME);
- status1.setState(PdpState.ACTIVE);
- status1.setPdpGroup(DEFAULT_GROUP);
- status1.setPdpType(APEX_TYPE);
- status1.setHealthy(PdpHealthStatus.HEALTHY);
- final List<ToscaConceptIdentifier> idents1 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status1.setPolicies(idents1);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status1);
- verifyPdpGroup(DEFAULT_GROUP, 1);
-
- // init pdp instance
- final PdpStatus status2 = new PdpStatus();
- status2.setName(PDP_NAME);
- status2.setState(PdpState.ACTIVE);
- status2.setPdpGroup(DEFAULT_GROUP);
- status2.setPdpType(APEX_TYPE);
- status2.setHealthy(PdpHealthStatus.HEALTHY);
- status2.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents2 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status2.setPolicies(idents2);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status2);
-
- // Testing passing pdp statistics success case
- final PdpStatus status3 = new PdpStatus();
- status3.setName(PDP_NAME);
- status3.setState(PdpState.ACTIVE);
- status3.setPdpGroup(DEFAULT_GROUP);
- status3.setPdpType(APEX_TYPE);
- status3.setHealthy(PdpHealthStatus.HEALTHY);
- status3.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents3 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status3.setPolicies(idents3);
-
- PdpStatistics pdpStatistics03 = new PdpStatistics();
- pdpStatistics03.setPdpInstanceId(PDP_NAME);
- pdpStatistics03.setPdpGroupName(DEFAULT_GROUP);
- pdpStatistics03.setPdpSubGroupName(APEX_TYPE);
- pdpStatistics03.setTimeStamp(timeStamp);
- status3.setStatistics(pdpStatistics03);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status3);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- // Testing pdp statistics failure having the pdpStatistics null in the heartbeat for already registered pdp
- final PdpStatus status4 = new PdpStatus();
- status4.setName(PDP_NAME);
- status4.setState(PdpState.ACTIVE);
- status4.setPdpGroup(DEFAULT_GROUP);
- status4.setPdpType(APEX_TYPE);
- status4.setHealthy(PdpHealthStatus.HEALTHY);
- status4.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents4 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status4.setPolicies(idents4);
- status4.setStatistics(null);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status4);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- // Testing pdp statistics failure passing different pdpGroup, PdpSubGroup & pdpInstanceId
- final PdpStatus status5 = new PdpStatus();
- status5.setName(PDP_NAME);
- status5.setState(PdpState.ACTIVE);
- status5.setPdpGroup(DEFAULT_GROUP);
- status5.setPdpType(APEX_TYPE);
- status5.setHealthy(PdpHealthStatus.HEALTHY);
- status5.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents5 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status5.setPolicies(idents5);
-
- PdpStatistics pdpStatistics05 = new PdpStatistics();
- pdpStatistics05.setPdpInstanceId("pdp_2");
- pdpStatistics05.setPdpGroupName("defaultGroup_1");
- pdpStatistics05.setPdpSubGroupName("apex_1");
- pdpStatistics03.setTimeStamp(timeStamp);
- status5.setStatistics(pdpStatistics05);
-
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status5);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- // Test pdp statistics failure passing negative values
- final PdpStatus status6 = new PdpStatus();
- status6.setName(PDP_NAME);
- status6.setState(PdpState.ACTIVE);
- status6.setPdpGroup(DEFAULT_GROUP);
- status6.setPdpType(APEX_TYPE);
- status6.setHealthy(PdpHealthStatus.HEALTHY);
- status6.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents6 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status5.setPolicies(idents6);
-
- PdpStatistics pdpStatistics06 = new PdpStatistics();
- pdpStatistics06.setPdpInstanceId(PDP_NAME);
- pdpStatistics06.setPdpGroupName(DEFAULT_GROUP);
- pdpStatistics06.setPdpSubGroupName(APEX_TYPE);
- pdpStatistics03.setTimeStamp(timeStamp);
-
- pdpStatistics06.setPolicyDeployCount(-1);
- pdpStatistics06.setPolicyDeployFailCount(-1);
- pdpStatistics06.setPolicyUndeployCount(-1);
- pdpStatistics06.setPolicyUndeployFailCount(-1);
- status5.setStatistics(pdpStatistics06);
-
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status5);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- // Test pdp statistics save disabled case, sending valid pdp status but count should still remain 1
- parameterGroup = new PapParameterGroup();
- parameterGroup.setPdpParameters(new PdpParameters());
- parameterGroup.setSavePdpStatisticsInDb(false);
- timeStamp = Instant.parse("2021-02-12T17:48:05.029211400Z");
- final PdpStatus status7 = new PdpStatus();
- status7.setName(PDP_NAME);
- status7.setState(PdpState.ACTIVE);
- status7.setPdpGroup(DEFAULT_GROUP);
- status7.setPdpType(APEX_TYPE);
- status7.setHealthy(PdpHealthStatus.HEALTHY);
- status7.setPdpSubgroup(APEX_TYPE);
- final List<ToscaConceptIdentifier> idents7 =
- Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
- status7.setPolicies(idents7);
-
- PdpStatistics pdpStatistics07 = new PdpStatistics();
- pdpStatistics07.setPdpInstanceId(PDP_NAME);
- pdpStatistics07.setPdpGroupName(DEFAULT_GROUP);
- pdpStatistics07.setPdpSubGroupName(APEX_TYPE);
- pdpStatistics07.setTimeStamp(timeStamp);
- status7.setStatistics(pdpStatistics07);
- pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status7);
- verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, APEX_TYPE, 1);
-
- }
-
+
private void verifyPdpGroup(final String name, final int count) throws PfModelException {
final List<PdpGroup> fetchedGroups = fetchGroups(name);
for (final PdpSubGroup subGroup : fetchedGroups.get(0).getPdpSubgroups()) {
@@ -397,11 +245,4 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
}
}
}
-
- private void verifyPdpStatistics(final String pdpInstanceId, final String pdpGroupName,
- final String pdpSubGroupName, final int count) throws PfModelException {
- final Map<String, Map<String, List<PdpStatistics>>> fetchedPdpStatistics =
- fetchPdpStatistics(pdpInstanceId, pdpGroupName, pdpSubGroupName);
- assertEquals(count, fetchedPdpStatistics.size());
- }
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java b/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java
index 857309c8..60de563e 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021-2022 Nordix Foundation.
- * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications 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.
@@ -93,7 +93,6 @@ public class ProviderSuper {
protected Object lockit;
protected PdpModifyRequestMap reqmap;
protected ToscaPolicy policy1;
- protected PapStatisticsManager statsmanager;
protected MeterRegistry meterRegistry;
/**
@@ -110,7 +109,6 @@ public class ProviderSuper {
lockit = new Object();
policy1 = loadPolicy("policy.json");
- statsmanager = mock(PapStatisticsManager.class);
meterRegistry = mock(MeterRegistry.class);
@@ -123,7 +121,6 @@ public class ProviderSuper {
Registry.register(PapConstants.REG_PDP_MODIFY_LOCK, lockit);
Registry.register(PapConstants.REG_PDP_MODIFY_MAP, reqmap);
- Registry.register(PapConstants.REG_STATISTICS_MANAGER, statsmanager);
Registry.register(PapConstants.REG_METER_REGISTRY, meterRegistry);
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPapStatisticsManager.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPapStatisticsManager.java
deleted file mode 100644
index 5412ac94..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPapStatisticsManager.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 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.pap.main.rest;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.function.ToLongFunction;
-import org.junit.Test;
-
-public class TestPapStatisticsManager {
-
- @Test
- public void testTotalPdpCount() {
- verifyCount(PapStatisticsManager::getTotalPdpCount,
- PapStatisticsManager::updateTotalPdpCount);
- }
-
- @Test
- public void testTotalPdpGroupCount() {
- verifyCount(PapStatisticsManager::getTotalPdpGroupCount,
- PapStatisticsManager::updateTotalPdpGroupCount);
- }
-
- @Test
- public void testTotalPolicyDeployCount() {
- verifyCount(PapStatisticsManager::getTotalPolicyDeployCount,
- PapStatisticsManager::updateTotalPolicyDeployCount);
- }
-
- @Test
- public void testPolicyDeploySuccessCount() {
- verifyCount(PapStatisticsManager::getPolicyDeploySuccessCount,
- PapStatisticsManager::updatePolicyDeploySuccessCount);
- }
-
- @Test
- public void testPolicyDeployFailureCount() {
- verifyCount(PapStatisticsManager::getPolicyDeployFailureCount,
- PapStatisticsManager::updatePolicyDeployFailureCount);
- }
-
- @Test
- public void testTotalPolicyDownloadCount() {
- verifyCount(PapStatisticsManager::getTotalPolicyDownloadCount,
- PapStatisticsManager::updateTotalPolicyDownloadCount);
- }
-
- @Test
- public void testPolicyDownloadSuccessCount() {
- verifyCount(PapStatisticsManager::getPolicyDownloadSuccessCount,
- PapStatisticsManager::updatePolicyDownloadSuccessCount);
- }
-
- @Test
- public void testPolicyDownloadFailureCount() {
- verifyCount(PapStatisticsManager::getPolicyDownloadFailureCount,
- PapStatisticsManager::updatePolicyDownloadFailureCount);
- }
-
- private void verifyCount(ToLongFunction<PapStatisticsManager> getCount,
- ToLongFunction<PapStatisticsManager> updateCount) {
-
- PapStatisticsManager mgr = new PapStatisticsManager();
-
- assertEquals(0, getCount.applyAsLong(mgr));
- assertEquals(1, updateCount.applyAsLong(mgr));
- assertEquals(1, getCount.applyAsLong(mgr));
-
- assertEquals(2, updateCount.applyAsLong(mgr));
- assertEquals(2, getCount.applyAsLong(mgr));
-
- // now check reset
- mgr.resetAllStatistics();
-
- assertEquals(0, getCount.applyAsLong(mgr));
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
index 29c06f76..b828509b 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-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.
@@ -54,12 +54,10 @@ import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.pap.main.PapConstants;
public class TestPdpGroupDeployProvider extends ProviderSuper {
private static final String EXPECTED_EXCEPTION = "expected exception";
-
private static final String POLICY2_NAME = "policyB";
private static final String POLICY3_NAME = "policyC";
private static final String POLICY1_VERSION = "1.2.3";
@@ -568,25 +566,6 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
.hasMessage("policy not supported by any PDP group: policyA 1.2.3");
}
- /**
- * Tests PapStatisticsManager counts when policies are added to a subgroup.
- *
- * @throws Exception if an error occurs
- */
- @Test
- public void testDeployedPdpGroupCountStatistics() throws Exception {
- Registry.unregister(PapConstants.REG_STATISTICS_MANAGER);
- PapStatisticsManager mgr = new PapStatisticsManager();
- Registry.register(PapConstants.REG_STATISTICS_MANAGER, mgr);
-
- when(pdpGroupService.getFilteredPdpGroups(any())).thenReturn(loadGroups("deployPoliciesWildCard.json"));
- prov.deployPolicies(loadRequest("multiple_requests.json"), DEFAULT_USER);
- assertEquals(3, mgr.getTotalPolicyDeployCount());
-
- Registry.unregister(PapConstants.REG_STATISTICS_MANAGER);
- Registry.register(PapConstants.REG_STATISTICS_MANAGER, statsmanager);
- }
-
@Test
public void testMakeUpdater() throws Exception {
/*
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsReport.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsReport.java
deleted file mode 100644
index 60b95aab..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsReport.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 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.pap.main.rest;
-
-import com.openpojo.reflection.filters.FilterClassName;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-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.common.utils.test.ToStringTester;
-
-/**
- * Class to perform unit testing of {@link StatisticsReport}.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
- */
-public class TestStatisticsReport {
-
- @Test
- public void testStatisticsReport() {
- final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterMustExistRule())
- .with(new GetterMustExistRule()).with(new SetterTester()).with(new GetterTester()).build();
- validator.validate(StatisticsReport.class.getPackage().getName(),
- new FilterClassName(StatisticsReport.class.getName()));
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java
deleted file mode 100644
index 423c1d33..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestStatisticsRestControllerV1.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020, 2022 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
- * ================================================================================
- * 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.pap.main.rest;
-
-import static org.junit.Assert.assertEquals;
-
-import javax.ws.rs.client.Invocation;
-import org.junit.Test;
-import org.onap.policy.common.utils.services.Registry;
-import org.onap.policy.pap.main.PapConstants;
-import org.springframework.test.context.ActiveProfiles;
-
-/**
- * Class to perform unit test of {@link StatisticsRestControllerV1}.
- *
- * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
- */
-@ActiveProfiles({ "test", "default" })
-public class TestStatisticsRestControllerV1 extends CommonPapRestServer {
-
- private static final String STATISTICS_ENDPOINT = "statistics";
- private static final String STATISTICS_DB_ENDPOINT = "pdps/statistics";
-
- @Test
- public void testSwagger() throws Exception {
- super.testSwagger(STATISTICS_ENDPOINT);
- super.testSwagger(STATISTICS_DB_ENDPOINT);
- super.testSwagger(STATISTICS_DB_ENDPOINT + "/{group}");
- super.testSwagger(STATISTICS_DB_ENDPOINT + "/{group}" + "/{type}");
- super.testSwagger(STATISTICS_DB_ENDPOINT + "/{group}" + "/{type}" + "/{pdp}");
- }
-
- @Test
- public void testPapStatistics_200() throws Exception {
- Invocation.Builder invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 0, 200);
- updateDistributionStatistics();
-
- invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 1, 200);
-
- // verify it fails when no authorization info is included
- checkUnauthRequest(STATISTICS_ENDPOINT, req -> req.get());
- }
-
- @Test
- public void testPapStatistics_500() throws Exception {
-
- markActivatorDead();
-
- Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class).resetAllStatistics();
-
- Invocation.Builder invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
- validateStatisticsReport(report, 0, 500);
- }
-
- private void updateDistributionStatistics() {
- PapStatisticsManager mgr = Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class);
-
- mgr.updateTotalPdpCount();
- mgr.updateTotalPdpGroupCount();
- mgr.updateTotalPolicyDeployCount();
- mgr.updatePolicyDeploySuccessCount();
- mgr.updatePolicyDeployFailureCount();
- mgr.updateTotalPolicyDownloadCount();
- mgr.updatePolicyDownloadSuccessCount();
- mgr.updatePolicyDownloadFailureCount();
- }
-
- private void validateStatisticsReport(final StatisticsReport report, final int count, final int code) {
- assertEquals(code, report.getCode());
- assertEquals(count, report.getTotalPdpCount());
- assertEquals(count, report.getTotalPdpGroupCount());
- assertEquals(count, report.getTotalPolicyDeployCount());
- assertEquals(count, report.getPolicyDeploySuccessCount());
- assertEquals(count, report.getPolicyDeployFailureCount());
- assertEquals(count, report.getTotalPolicyDownloadCount());
- assertEquals(count, report.getPolicyDeploySuccessCount());
- assertEquals(count, report.getPolicyDeployFailureCount());
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
index fd74caa2..2b339f82 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020, 2022 Nordix Foundation.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-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.
@@ -28,7 +28,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
import lombok.Getter;
import org.junit.After;
@@ -43,14 +42,12 @@ import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.State;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.pap.main.PolicyPapRuntimeException;
import org.onap.policy.pap.main.repository.ToscaServiceTemplateRepository;
import org.onap.policy.pap.main.rest.CommonPapRestServer;
import org.onap.policy.pap.main.service.PdpGroupService;
-import org.onap.policy.pap.main.service.PdpStatisticsService;
import org.onap.policy.pap.main.service.PolicyStatusService;
import org.onap.policy.pap.main.service.ToscaServiceTemplateService;
import org.slf4j.Logger;
@@ -75,9 +72,6 @@ public abstract class End2EndBase extends CommonPapRestServer {
public PdpGroupService pdpGroupService;
@Autowired
- public PdpStatisticsService pdpStatisticsService;
-
- @Autowired
private ToscaServiceTemplateRepository serviceTemplateRepository;
@Autowired
@@ -187,18 +181,6 @@ public abstract class End2EndBase extends CommonPapRestServer {
}
/**
- * Fetch PDP statistics from the DB.
- *
- * @param instanceId name of the pdpStatistics
- * @param groupName name of the pdpGroup
- * @param subGroupName name of the pdpSubGroup
- */
- public Map<String, Map<String, List<PdpStatistics>>> fetchPdpStatistics(final String instanceId,
- final String groupName, final String subGroupName) {
- return pdpStatisticsService.fetchDatabaseStatistics(groupName, subGroupName, instanceId, 100, null, null);
- }
-
- /**
* Adds PdpPolicyStatus records to the DB.
*
* @param jsonFile name of the JSON file specifying the data to be loaded
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java
deleted file mode 100644
index 876ea0fb..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/StatisticsTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP PAP
- * ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
- * Modifications Copyright (C) 2021-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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.pap.main.rest.e2e;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-
-import java.net.HttpURLConnection;
-import java.time.Instant;
-import java.util.List;
-import java.util.Map;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.utils.services.Registry;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
-import org.onap.policy.pap.main.PapConstants;
-import org.onap.policy.pap.main.rest.PapStatisticsManager;
-import org.onap.policy.pap.main.rest.StatisticsReport;
-
-public class StatisticsTest extends End2EndBase {
- private static final String STATISTICS_ENDPOINT = "statistics";
- private static final String END_TIME_NAME = "endTime";
- private static final String START_TIME_NAME = "startTime";
- private static final long TIMESTAMP_SEC = 1562494272;
-
- private static PdpStatistics pdpStatisticsRecord;
-
- /**
- * Adds a record to the DB.
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- End2EndBase.setUpBeforeClass();
-
- pdpStatisticsRecord = new PdpStatistics();
- pdpStatisticsRecord.setPdpGroupName("defaultGroup");
- pdpStatisticsRecord.setPdpSubGroupName("apex");
- pdpStatisticsRecord.setPdpInstanceId("pdp1");
- pdpStatisticsRecord.setTimeStamp(Instant.ofEpochSecond(TIMESTAMP_SEC));
- pdpStatisticsRecord.setPolicyDeployCount(1);
- pdpStatisticsRecord.setPolicyDeployFailCount(0);
- pdpStatisticsRecord.setPolicyDeploySuccessCount(1);
- pdpStatisticsRecord.setPolicyExecutedCount(1);
- pdpStatisticsRecord.setPolicyExecutedFailCount(0);
- pdpStatisticsRecord.setPolicyExecutedSuccessCount(1);
- }
-
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
- pdpStatisticsService.createPdpStatistics(List.of(pdpStatisticsRecord));
- }
-
- @Test
- public void test() throws Exception {
- Invocation.Builder invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- StatisticsReport report = invocationBuilder.get(StatisticsReport.class);
- assertEquals(HttpURLConnection.HTTP_OK, report.getCode());
-
- updateDistributionStatistics();
-
- invocationBuilder = sendRequest(STATISTICS_ENDPOINT);
- StatisticsReport report2 = invocationBuilder.get(StatisticsReport.class);
-
- assertEquals(HttpURLConnection.HTTP_OK, report.getCode());
- assertEquals(report.getTotalPdpCount() + 1, report2.getTotalPdpCount());
- assertEquals(report.getTotalPdpGroupCount() + 1, report2.getTotalPdpGroupCount());
- assertEquals(report.getTotalPolicyDeployCount() + 1, report2.getTotalPolicyDeployCount());
- assertEquals(report.getPolicyDeploySuccessCount() + 1, report2.getPolicyDeploySuccessCount());
- assertEquals(report.getPolicyDeployFailureCount() + 1, report2.getPolicyDeployFailureCount());
- assertEquals(report.getTotalPolicyDownloadCount() + 1, report2.getTotalPolicyDownloadCount());
- assertEquals(report.getPolicyDeploySuccessCount() + 1, report2.getPolicyDeploySuccessCount());
- assertEquals(report.getPolicyDeployFailureCount() + 1, report2.getPolicyDeployFailureCount());
- }
-
- @Test
- public void testDb() throws Exception {
- verifyResponse("pdps/statistics");
- }
-
- @Test
- public void testDbWithGroup() throws Exception {
- verifyResponse("pdps/statistics/defaultGroup");
-
- }
-
- @Test
- public void testDbWithSubGroup() throws Exception {
- verifyResponse("pdps/statistics/defaultGroup/apex");
- }
-
- @Test
- public void testDbWithPdp() throws Exception {
- verifyResponse("pdps/statistics/defaultGroup/apex/pdp1");
- }
-
- @Test
- public void testDbWithPdpLatest() throws Exception {
- verifyResponse("pdps/statistics/defaultGroup/apex/pdp1?recordCount=5");
- }
-
- private void updateDistributionStatistics() {
- PapStatisticsManager mgr = Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class);
-
- mgr.updateTotalPdpCount();
- mgr.updateTotalPdpGroupCount();
- mgr.updateTotalPolicyDeployCount();
- mgr.updatePolicyDeploySuccessCount();
- mgr.updatePolicyDeployFailureCount();
- mgr.updateTotalPolicyDownloadCount();
- mgr.updatePolicyDownloadSuccessCount();
- mgr.updatePolicyDownloadFailureCount();
- }
-
- private void verifyResponse(String endpoint) throws Exception {
- Invocation.Builder invocationBuilder = sendRequest(endpoint);
- verifyResponse(invocationBuilder.get());
-
- // repeat with "start", in range
- invocationBuilder = sendRequest(addTimeParam(endpoint, START_TIME_NAME, TIMESTAMP_SEC));
- verifyResponse(invocationBuilder.get());
-
- // repeat with "end", in range
- invocationBuilder = sendRequest(addTimeParam(endpoint, END_TIME_NAME, TIMESTAMP_SEC));
- verifyResponse(invocationBuilder.get());
-
- // repeat with "start" and "end", in range
- invocationBuilder = sendRequest(addTimeParam(endpoint, START_TIME_NAME, TIMESTAMP_SEC - 1)
- + "&" + END_TIME_NAME + "=" + TIMESTAMP_SEC + 1);
- verifyResponse(invocationBuilder.get());
-
- // repeat with "start", out of range
- invocationBuilder = sendRequest(addTimeParam(endpoint, START_TIME_NAME, TIMESTAMP_SEC + 1));
- verifyEmptyResponse(invocationBuilder.get());
-
- // repeat with "end", out of range
- invocationBuilder = sendRequest(addTimeParam(endpoint, END_TIME_NAME, TIMESTAMP_SEC - 1));
- verifyEmptyResponse(invocationBuilder.get());
- }
-
- private void verifyResponse(Response testResponse) {
- assertEquals(Response.Status.OK.getStatusCode(), testResponse.getStatus());
- Map<String, Map<String, List<PdpStatistics>>> map =
- testResponse.readEntity(new GenericType<Map<String, Map<String, List<PdpStatistics>>>>() {});
- Map<String, List<PdpStatistics>> subMap = map.get("defaultGroup");
- List<PdpStatistics> resRecord = subMap.get("apex");
- assertEquals("pdp1", resRecord.get(0).getPdpInstanceId());
- assertEquals("apex", resRecord.get(0).getPdpSubGroupName());
- assertEquals("defaultGroup", resRecord.get(0).getPdpGroupName());
- }
-
- private void verifyEmptyResponse(Response testResponse) {
- assertEquals(Response.Status.OK.getStatusCode(), testResponse.getStatus());
- Map<String, Map<String, List<PdpStatistics>>> map =
- testResponse.readEntity(new GenericType<Map<String, Map<String, List<PdpStatistics>>>>() {});
- assertThat(map).isEmpty();
- }
-
- /**
- * Adds a timestamp parameter to an endpoint string.
- * @param endpoint endpoint to which it should be added
- * @param paramName parameter name
- * @param timeSec time, in seconds
- * @return the new endpoint, with the added parameter
- */
- private String addTimeParam(String endpoint, String paramName, long timeSec) {
- StringBuilder builder = new StringBuilder(endpoint);
- builder.append(endpoint.contains("?") ? '&' : '?');
- builder.append(paramName);
- builder.append('=');
- builder.append(timeSec);
- return builder.toString();
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java
deleted file mode 100644
index 1d429ee8..00000000
--- a/main/src/test/java/org/onap/policy/pap/main/service/PdpStatisticsServiceTest.java
+++ /dev/null
@@ -1,193 +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.pap.main.service;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
-import org.onap.policy.pap.main.repository.PdpStatisticsRepository;
-import org.onap.policy.pap.main.rest.CommonPapRestServer;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-
-@ActiveProfiles("test")
-public class PdpStatisticsServiceTest extends CommonPapRestServer {
-
- private static final String NAME3 = "name3";
- private static final String NAME1 = "name1";
- private static final String LIST_IS_NULL = "pdpStatisticsList is marked .*ull but is null";
- private static final String GROUP0 = "group0";
- private static final String GROUP = "group";
- private static final String SUBGROUP = "subgroup";
- private static final Instant TIMESTAMP1 = Instant.ofEpochSecond(1078884319);
- private static final Instant TIMESTAMP2 = Instant.ofEpochSecond(1078884350);
- private static final Integer NUMBER_RECORDS = 10;
-
- @Autowired
- private PdpStatisticsService pdpStatisticsService;
-
- @Autowired
- private PdpStatisticsRepository pdpStatisticsRepository;
-
- private PdpStatistics pdpStatistics1;
- private PdpStatistics pdpStatistics2;
- private PdpStatistics pdpStatistics3;
- private PdpStatistics pdpStatistics4;
-
- /**
- * Setup before tests.
- *
- * @throws Exception the exception
- */
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
- pdpStatistics1 = generatePdpStatistics(NAME1, TIMESTAMP1, GROUP);
- pdpStatistics2 = generatePdpStatistics("name2", TIMESTAMP1, GROUP);
- pdpStatistics3 = generatePdpStatistics(NAME1, TIMESTAMP2, GROUP);
- pdpStatistics4 = generatePdpStatistics(NAME3, TIMESTAMP2, GROUP0);
- }
-
- /**
- * Teardown after tests.
- */
- @Override
- @After
- public void tearDown() {
- pdpStatisticsRepository.deleteAll();
- }
-
- @Test
- public void testCreatePdpStatisticsSuccess() {
- List<PdpStatistics> createList = List.of(pdpStatistics1, pdpStatistics3, pdpStatistics4, pdpStatistics2);
- List<PdpStatistics> createdPdpStatisticsList = pdpStatisticsService.createPdpStatistics(createList);
- // these should match AND be in the same order
- assertThat(createdPdpStatisticsList).isEqualTo(createList);
- }
-
- @Test
- public void testCreatePdpStatisticsFailure() {
-
- assertThatThrownBy(() -> pdpStatisticsService.createPdpStatistics(null)).hasMessageMatching(LIST_IS_NULL);
-
- PdpStatistics pdpStatisticsErr = new PdpStatistics();
- pdpStatisticsErr.setPdpInstanceId("NULL");
- pdpStatisticsErr.setPdpGroupName(GROUP);
- assertThatThrownBy(() -> pdpStatisticsService.createPdpStatistics(List.of(pdpStatisticsErr)))
- .hasMessageContaining("item \"name\" value \"NULL\" INVALID, is null");
- }
-
- @Test
- public void testFetchDatabaseStatistics() {
- List<PdpStatistics> createList = List.of(pdpStatistics1, pdpStatistics3, pdpStatistics4, pdpStatistics2);
- pdpStatisticsService.createPdpStatistics(createList);
-
- Map<String, Map<String, List<PdpStatistics>>> statistics;
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, null, null);
- assertGroupAndSubgroupSize(statistics, 2, GROUP0, 1);
- assertGroupAndSubgroupSize(statistics, 2, GROUP, 3);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, TIMESTAMP2, TIMESTAMP2);
- assertGroupAndSubgroupSize(statistics, 2, GROUP0, 1);
- assertThat(statistics.get(GROUP0)).containsEntry(SUBGROUP, List.of(pdpStatistics4));
- assertGroupAndSubgroupSize(statistics, 2, GROUP, 1);
- assertThat(statistics.get(GROUP)).containsEntry(SUBGROUP, List.of(pdpStatistics3));
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, null, TIMESTAMP1);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 2);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(NUMBER_RECORDS, TIMESTAMP2, null);
- assertThat(statistics).hasSize(2);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP0, NUMBER_RECORDS, TIMESTAMP2, TIMESTAMP2);
- assertThat(statistics).hasSize(1);
- assertThat(statistics.get(GROUP0)).hasSize(1);
- assertThat(statistics.get(GROUP0)).containsEntry(SUBGROUP, List.of(pdpStatistics4));
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, NUMBER_RECORDS, null, TIMESTAMP1);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 2);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, NUMBER_RECORDS, TIMESTAMP2, null);
- assertThat(statistics).hasSize(1);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, TIMESTAMP1,
- TIMESTAMP2);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 3);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, null, TIMESTAMP1);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 2);
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NUMBER_RECORDS, TIMESTAMP2, null);
- assertThat(statistics).hasSize(1);
- assertThat(statistics.get(GROUP)).containsEntry(SUBGROUP, List.of(pdpStatistics3));
-
- statistics = pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NAME1, NUMBER_RECORDS, TIMESTAMP1,
- TIMESTAMP2);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 2);
-
- statistics =
- pdpStatisticsService.fetchDatabaseStatistics(GROUP, SUBGROUP, NAME1, NUMBER_RECORDS, null, TIMESTAMP1);
- assertGroupAndSubgroupSize(statistics, 1, GROUP, 1);
-
- statistics =
- pdpStatisticsService.fetchDatabaseStatistics(GROUP0, SUBGROUP, NAME3, NUMBER_RECORDS, TIMESTAMP2, null);
- assertThat(statistics).hasSize(1);
- assertThat(statistics.get(GROUP0)).containsEntry(SUBGROUP, List.of(pdpStatistics4));
- }
-
- /**
- * Asserts if statistics list is the expected size and the subgroup list is also the expected size.
- */
- private void assertGroupAndSubgroupSize(Map<String, Map<String, List<PdpStatistics>>> statistics, int listSize,
- String group, int subGroupSize) {
- assertThat(statistics).hasSize(listSize);
- assertThat(statistics.get(group)).hasSize(1);
- assertThat(statistics.get(group).get(SUBGROUP)).hasSize(subGroupSize);
- }
-
- private PdpStatistics generatePdpStatistics(String pdpInstanceId, Instant date, String group) {
- PdpStatistics pdpStatistics11 = new PdpStatistics();
- pdpStatistics11.setPdpInstanceId(pdpInstanceId);
- pdpStatistics11.setTimeStamp(date);
- pdpStatistics11.setPdpGroupName(group);
- pdpStatistics11.setPdpSubGroupName(PdpStatisticsServiceTest.SUBGROUP);
- pdpStatistics11.setPolicyDeployCount(2);
- pdpStatistics11.setPolicyDeployFailCount(1);
- pdpStatistics11.setPolicyDeploySuccessCount(1);
- pdpStatistics11.setPolicyExecutedCount(2);
- pdpStatistics11.setPolicyExecutedFailCount(1);
- pdpStatistics11.setPolicyExecutedSuccessCount(1);
- pdpStatistics11.setEngineStats(new ArrayList<>());
-
- return pdpStatistics11;
- }
-}
diff --git a/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java b/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java
index 67921381..04ef2b66 100644
--- a/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java
+++ b/main/src/test/java/org/onap/policy/pap/main/startstop/TestPapActivator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2022 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
- * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-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.
@@ -48,7 +48,6 @@ import org.onap.policy.pap.main.comm.PdpModifyRequestMap;
import org.onap.policy.pap.main.notification.PolicyNotifier;
import org.onap.policy.pap.main.parameters.CommonTestData;
import org.onap.policy.pap.main.parameters.PapParameterGroup;
-import org.onap.policy.pap.main.rest.PapStatisticsManager;
/**
@@ -125,7 +124,6 @@ public class TestPapActivator {
// ensure items were added to the registry
assertNotNull(Registry.get(PapConstants.REG_PDP_MODIFY_LOCK, Object.class));
- assertNotNull(Registry.get(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class));
assertNotNull(Registry.get(PapConstants.REG_PDP_MODIFY_MAP, PdpModifyRequestMap.class));
// repeat - should throw an exception
@@ -142,7 +140,6 @@ public class TestPapActivator {
// ensure items have been removed from the registry
assertNull(Registry.getOrDefault(PapConstants.REG_PDP_MODIFY_LOCK, Object.class, null));
- assertNull(Registry.getOrDefault(PapConstants.REG_STATISTICS_MANAGER, PapStatisticsManager.class, null));
assertNull(Registry.getOrDefault(PapConstants.REG_PDP_MODIFY_MAP, PdpModifyRequestMap.class, null));
// repeat - should throw an exception
diff --git a/main/src/test/resources/application-test-e2e.yaml b/main/src/test/resources/application-test-e2e.yaml
index 96ed124d..435eb569 100644
--- a/main/src/test/resources/application-test-e2e.yaml
+++ b/main/src/test/resources/application-test-e2e.yaml
@@ -41,7 +41,6 @@ pap:
maxWaitMs: 3000
heartBeatMs: 6000
maxMessageAgeMs: 20000
- savePdpStatisticsInDb: true
topicParameterGroup:
topicSources:
- topic: ${pap.topic.pdp-pap.name}
diff --git a/main/src/test/resources/application-test.yaml b/main/src/test/resources/application-test.yaml
index 7a2e9fc9..96ba60df 100644
--- a/main/src/test/resources/application-test.yaml
+++ b/main/src/test/resources/application-test.yaml
@@ -41,7 +41,6 @@ pap:
maxWaitMs: 3000
heartBeatMs: 6000
maxMessageAgeMs: 20000
- savePdpStatisticsInDb: true
topicParameterGroup:
topicSources:
- topic: ${pap.topic.pdp-pap.name}
diff --git a/main/src/test/resources/parameters/MinimumParameters.json b/main/src/test/resources/parameters/MinimumParameters.json
index 3c439d1f..80125305 100644
--- a/main/src/test/resources/parameters/MinimumParameters.json
+++ b/main/src/test/resources/parameters/MinimumParameters.json
@@ -26,7 +26,6 @@
"databasePassword": "P01icY",
"persistenceUnit": "PdpGroupTest"
},
- "savePdpStatisticsInDb": true,
"topicParameterGroup": {
"topicSources" : [{
"topic" : "POLICY-PDP-PAP",
diff --git a/main/src/test/resources/parameters/PapConfigParameters.json b/main/src/test/resources/parameters/PapConfigParameters.json
index bb1a7588..debdc47c 100644
--- a/main/src/test/resources/parameters/PapConfigParameters.json
+++ b/main/src/test/resources/parameters/PapConfigParameters.json
@@ -27,7 +27,6 @@
"databasePassword": "UDAxaWNZ",
"persistenceUnit": "ToscaConceptTest"
},
- "savePdpStatisticsInDb": true,
"topicParameterGroup": {
"topicSources" : [{
"topic" : "POLICY-PDP-PAP",
diff --git a/main/src/test/resources/parameters/PapConfigParametersStd.json b/main/src/test/resources/parameters/PapConfigParametersStd.json
index 9ba3f124..1b5b0eff 100644
--- a/main/src/test/resources/parameters/PapConfigParametersStd.json
+++ b/main/src/test/resources/parameters/PapConfigParametersStd.json
@@ -28,7 +28,6 @@
"databasePassword": "UDAxaWNZ",
"persistenceUnit": "ToscaConceptTest"
},
- "savePdpStatisticsInDb": true,
"topicParameterGroup": {
"topicSources" : [{
"topic" : "POLICY-PDP-PAP",