summaryrefslogtreecommitdiffstats
path: root/models-provider
diff options
context:
space:
mode:
Diffstat (limited to 'models-provider')
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java61
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java47
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java2
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java120
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java45
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java44
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java18
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyStatisticsPersistenceTest.java87
8 files changed, 7 insertions, 417 deletions
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
index 5cc5fc96b..f0a5382de 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2022 Nordix Foundation.
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020, 2022 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,6 @@
package org.onap.policy.models.provider;
-import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -30,15 +29,11 @@ import lombok.NonNull;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.pap.concepts.PolicyAudit;
-import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.pdp.persistence.provider.PdpFilterParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityKey;
@@ -378,46 +373,6 @@ public interface PolicyModelsProvider extends AutoCloseable {
*/
public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException;
-
- /**
- * Get filtered PdpStatistics.
- *
- * @param filterParams filter parameters
- * @return the PDP statistics found
- * @throws PfModelException on errors getting policies
- */
- public List<PdpStatistics> getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException;
-
- /**
- * Creates PDP statistics.
- *
- * @param pdpStatisticsList a specification of the PDP statistics to create
- * @return the PDP statistics created
- * @throws PfModelException on errors creating PDP statistics
- */
- public List<PdpStatistics> createPdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
- throws PfModelException;
-
- /**
- * Updates PDP statistics.
- *
- * @param pdpStatisticsList a specification of the PDP statistics to update
- * @return the PDP statistics updated
- * @throws PfModelException on errors updating PDP statistics
- */
- public List<PdpStatistics> updatePdpStatistics(@NonNull List<PdpStatistics> pdpStatisticsList)
- throws PfModelException;
-
- /**
- * Delete a PDP statistics.
- *
- * @param name the name of the policy to get, null to get all PDP statistics
- * @param timestamp the timestamp of statistics to delete, null to delete all statistics record of given pdp
- * @return the PDP statistics deleted
- * @throws PfModelException on errors deleting PDP statistics
- */
- public List<PdpStatistics> deletePdpStatistics(@NonNull String name, Instant timestamp) throws PfModelException;
-
/**
* Gets all policy deployments.
*
@@ -453,18 +408,4 @@ public interface PolicyModelsProvider extends AutoCloseable {
*/
public void cudPolicyStatus(Collection<PdpPolicyStatus> createObjs, Collection<PdpPolicyStatus> updateObjs,
Collection<PdpPolicyStatus> deleteObjs);
-
- /**
- * Creates records for audit actions on policies.
- *
- * @param auditRecords the objects to create
- */
- public void createAuditRecords(@NonNull List<PolicyAudit> auditRecords);
-
- /**
- * Collect the audit records.
- * @param auditFilter filter for search
- * @return list of {@link PolicyAudit} or empty if none or not match with filter
- */
- public List<PolicyAudit> getAuditRecords(AuditFilter auditFilter);
}
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java
index ffb470628..6747d9c49 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/AbstractPolicyModelsProvider.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021-2022 Nordix Foundation.
+ * 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.
@@ -20,7 +21,6 @@
package org.onap.policy.models.provider.impl;
-import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -30,18 +30,12 @@ import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.dao.PfDao;
-import org.onap.policy.models.pap.concepts.PolicyAudit;
-import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider;
-import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.pdp.persistence.provider.PdpFilterParameters;
import org.onap.policy.models.pdp.persistence.provider.PdpProvider;
-import org.onap.policy.models.pdp.persistence.provider.PdpStatisticsProvider;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
@@ -280,33 +274,6 @@ public abstract class AbstractPolicyModelsProvider implements PolicyModelsProvid
}
@Override
- public List<PdpStatistics> getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException {
- assertInitialized();
- return new PdpStatisticsProvider().getFilteredPdpStatistics(getPfDao(), filterParams);
- }
-
- @Override
- public List<PdpStatistics> createPdpStatistics(@NonNull final List<PdpStatistics> pdpStatisticsList)
- throws PfModelException {
- assertInitialized();
- return new PdpStatisticsProvider().createPdpStatistics(getPfDao(), pdpStatisticsList);
- }
-
- @Override
- public List<PdpStatistics> updatePdpStatistics(@NonNull final List<PdpStatistics> pdpStatisticsList)
- throws PfModelException {
- assertInitialized();
- return new PdpStatisticsProvider().updatePdpStatistics(getPfDao(), pdpStatisticsList);
- }
-
- @Override
- public List<PdpStatistics> deletePdpStatistics(@NonNull final String name, final Instant timestamp)
- throws PfModelException {
- assertInitialized();
- return new PdpStatisticsProvider().deletePdpStatistics(getPfDao(), name, timestamp);
- }
-
- @Override
public List<PdpPolicyStatus> getAllPolicyStatus() throws PfModelException {
assertInitialized();
return new PdpProvider().getAllPolicyStatus(getPfDao());
@@ -332,18 +299,6 @@ public abstract class AbstractPolicyModelsProvider implements PolicyModelsProvid
new PdpProvider().cudPolicyStatus(getPfDao(), createObjs, updateObjs, deleteObjs);
}
- @Override
- public void createAuditRecords(List<PolicyAudit> auditRecords) {
- assertInitialized();
- new PolicyAuditProvider().createAuditRecords(getPfDao(), auditRecords);
- }
-
- @Override
- public List<PolicyAudit> getAuditRecords(AuditFilter auditFilter) {
- assertInitialized();
- return new PolicyAuditProvider().getAuditRecords(getPfDao(), auditFilter);
- }
-
/**
* Check if the model provider is initialized.
*/
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
index af03fdbcf..ed47ae0a0 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Bell Canada. 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.
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
index 561ef5daa..ff3dae81a 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2022 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Bell Canada. 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.
@@ -22,14 +22,11 @@
package org.onap.policy.models.provider.impl;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -37,22 +34,16 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.pap.concepts.PolicyAudit;
-import org.onap.policy.models.pap.concepts.PolicyAudit.AuditAction;
-import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.pdp.persistence.provider.PdpFilterParameters;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityFilter;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
@@ -84,10 +75,6 @@ public class DatabasePolicyModelsProviderTest {
private static final String VERSION_100 = "1.0.0";
- private static final Instant TIMESTAMP = Instant.EPOCH;
-
- private static final String ORDER = "DESC";
-
private PolicyModelsProviderParameters parameters;
private PolicyModelsProvider databaseProvider;
@@ -282,18 +269,6 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.deletePdpGroup(null);
}).hasMessageMatching(NAME_IS_NULL);
- assertThatThrownBy(() -> {
- databaseProvider.createPdpStatistics(null);
- }).hasMessageMatching("^pdpStatisticsList is marked .*on.*ull but is null$");
-
- assertThatThrownBy(() -> {
- databaseProvider.updatePdpStatistics(null);
- }).hasMessageMatching("^pdpStatisticsList is marked .*on.*ull but is null$");
-
- assertThatThrownBy(() -> {
- databaseProvider.deletePdpStatistics(null, TIMESTAMP);
- }).hasMessageMatching(NAME_IS_NULL);
-
databaseProvider.close();
}
@@ -413,68 +388,6 @@ public class DatabasePolicyModelsProviderTest {
}).hasMessage("delete of PDP group \"name:0.0.0\" failed, PDP group does not exist");
assertEquals(pdpGroup.getName(), databaseProvider.deletePdpGroup(GROUP).getName());
-
- List<PdpStatistics> statisticsArrayList = makePdpStatisticsList();
-
- assertThat(databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().build())).isEmpty();
- assertThat(databaseProvider.createPdpStatistics(statisticsArrayList)).hasSize(1);
- assertThat(databaseProvider.updatePdpStatistics(statisticsArrayList)).hasSize(1);
- }
-
- @Test
- public void testProviderMethodsStatistics() throws PfModelException {
- databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
- databaseProvider.createPdpStatistics(makePdpStatisticsList());
-
- assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().build()).get(0)
- .getPdpInstanceId());
- assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(
- PdpFilterParameters.builder().group(GROUP).build()).get(0).getPdpInstanceId());
- assertEquals(0, databaseProvider.getFilteredPdpStatistics(
- PdpFilterParameters.builder().group(GROUP).startTime(Instant.now()).build()).size());
- assertEquals(NAME, databaseProvider
- .getFilteredPdpStatistics(PdpFilterParameters.builder().group(GROUP).endTime(TIMESTAMP).build())
- .get(0).getPdpInstanceId());
- assertEquals(0, databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().group(GROUP)
- .startTime(Instant.now()).endTime(Instant.now()).build()).size());
-
- assertEquals(NAME, databaseProvider
- .getFilteredPdpStatistics(PdpFilterParameters.builder().name(NAME).group(GROUP).build()).get(0)
- .getPdpInstanceId());
- assertEquals(0, databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().name(NAME).group(GROUP)
- .startTime(Instant.now()).endTime(Instant.now()).build()).size());
-
- assertEquals(NAME,
- databaseProvider.getFilteredPdpStatistics(
- PdpFilterParameters.builder().name(NAME).group(GROUP).subGroup("type").build())
- .get(0).getPdpInstanceId());
-
- assertEquals(0, databaseProvider.getFilteredPdpStatistics(
- PdpFilterParameters.builder().name(NAME).group(GROUP).subGroup("type")
- .startTime(Instant.now()).endTime(Instant.now()).build()).size());
-
- assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(
- PdpFilterParameters.builder().name(NAME).group(GROUP).subGroup("type")
- .sortOrder(ORDER).recordNum(1).build()).get(0).getPdpInstanceId());
- assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(
- PdpFilterParameters.builder().name(NAME).group(GROUP).subGroup("type")
- .sortOrder(ORDER).recordNum(5).build()).get(0).getPdpInstanceId());
- assertEquals(0, databaseProvider.getFilteredPdpStatistics(
- PdpFilterParameters.builder().name(NAME).group(GROUP).subGroup("type")
- .startTime(Instant.now()).endTime(Instant.now())
- .sortOrder(ORDER).recordNum(5).build()).size());
-
- assertEquals(NAME, databaseProvider.deletePdpStatistics(NAME, null).get(0).getPdpInstanceId());
- assertThat(databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().build())).isEmpty();
-
- assertThat(databaseProvider.getAllPolicyStatus()).isEmpty();
- assertThat(databaseProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy", null)))
- .isEmpty();
- assertThat(databaseProvider.getGroupPolicyStatus(GROUP)).isEmpty();
- assertThatCode(() -> databaseProvider.cudPolicyStatus(null, null, null))
- .doesNotThrowAnyException();
-
- databaseProvider.close();
}
@Test
@@ -551,27 +464,6 @@ public class DatabasePolicyModelsProviderTest {
}
@Test
- public void testCreateAuditRecords() throws PfModelException {
- PolicyAudit audit = PolicyAudit.builder().action(AuditAction.DEPLOYMENT).pdpGroup(GROUP).pdpType(GROUP)
- .policy(new ToscaConceptIdentifier(NAME, VERSION_100)).user("user").build();
-
- databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
-
- databaseProvider.createAuditRecords(List.of(audit));
- List<PolicyAudit> createdAudits = databaseProvider.getAuditRecords(AuditFilter.builder().recordNum(10).build());
- assertThat(createdAudits).hasSize(1);
-
- List<PolicyAudit> emptyList = databaseProvider
- .getAuditRecords(AuditFilter.builder().action(AuditAction.UNDEPLOYMENT).recordNum(10).build());
- assertThat(emptyList).isEmpty();
-
- assertThatThrownBy(() -> databaseProvider.createAuditRecords(null))
- .hasMessageContaining("audits is marked non-null but is null");
-
- databaseProvider.close();
- }
-
- @Test
public void testToscaNodeTemplateHandling() throws PfModelException {
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
@@ -596,16 +488,6 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider.close();
}
- private List<PdpStatistics> makePdpStatisticsList() {
- PdpStatistics pdpStatistics = new PdpStatistics();
- pdpStatistics.setPdpInstanceId(NAME);
- pdpStatistics.setTimeStamp(TIMESTAMP);
- pdpStatistics.setPdpGroupName(GROUP);
- pdpStatistics.setPdpSubGroupName("type");
- List<PdpStatistics> statisticsArrayList = List.of(pdpStatistics);
- return statisticsArrayList;
- }
-
private ToscaServiceTemplate makeNodeTemplate() {
ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
serviceTemplate.setToscaDefinitionsVersion("sample:1.1.0");
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
index 410ecf26a..84331e905 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2022 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Bell Canada. 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.
@@ -22,8 +22,6 @@
package org.onap.policy.models.provider.impl;
-import java.time.Instant;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -33,15 +31,11 @@ import lombok.NonNull;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.pap.concepts.PolicyAudit;
-import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.pdp.persistence.provider.PdpFilterParameters;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityFilter;
@@ -242,32 +236,6 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
}
@Override
- public List<PdpStatistics> getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException {
- // Not implemented
- return null;
- }
-
- @Override
- public List<PdpStatistics> createPdpStatistics(final List<PdpStatistics> pdpStatisticsList)
- throws PfModelException {
- // Not implemented
- return new ArrayList<>();
- }
-
- @Override
- public List<PdpStatistics> updatePdpStatistics(final List<PdpStatistics> pdpStatisticsList)
- throws PfModelException {
- // Not implemented
- return new ArrayList<>();
- }
-
- @Override
- public List<PdpStatistics> deletePdpStatistics(final String name, final Instant timestamp) {
- // Not implemented
- return null;
- }
-
- @Override
public List<PdpPolicyStatus> getAllPolicyStatus() throws PfModelException {
// Not implemented
return null;
@@ -297,15 +265,4 @@ public class DummyBadProviderImpl implements PolicyModelsProvider {
// Not implemented
return null;
}
-
- @Override
- public void createAuditRecords(List<PolicyAudit> auditRecords) {
- // Not implemented
- }
-
- @Override
- public List<PolicyAudit> getAuditRecords(AuditFilter auditFilter) {
- // Not implemented
- return null;
- }
}
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
index dcc436a05..4b8f1b866 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2022 Nordix Foundation.
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Bell Canada. 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.
@@ -22,7 +22,6 @@
package org.onap.policy.models.provider.impl;
-import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -34,15 +33,11 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.pap.concepts.PolicyAudit;
-import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.pdp.persistence.provider.PdpFilterParameters;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
@@ -250,32 +245,6 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public List<PdpStatistics> getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException {
- // Not implemented
- return new ArrayList<>();
- }
-
- @Override
- public List<PdpStatistics> createPdpStatistics(final List<PdpStatistics> pdpStatisticsList)
- throws PfModelException {
- // Not implemented
- return new ArrayList<>();
- }
-
- @Override
- public List<PdpStatistics> updatePdpStatistics(final List<PdpStatistics> pdpStatisticsList)
- throws PfModelException {
- // Not implemented
- return new ArrayList<>();
- }
-
- @Override
- public List<PdpStatistics> deletePdpStatistics(final String name, final Instant timestamp) {
- // Not implemented
- return new ArrayList<>();
- }
-
- @Override
public List<PdpPolicyStatus> getAllPolicyStatus() throws PfModelException {
// Not implemented
return new ArrayList<>();
@@ -300,17 +269,6 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
// Not implemented
}
- @Override
- public void createAuditRecords(List<PolicyAudit> auditRecords) {
- // Not implemented
- }
-
- @Override
- public List<PolicyAudit> getAuditRecords(AuditFilter auditFilter) {
- // Not implemented
- return new ArrayList<>();
- }
-
/**
* Return a ToscaServicetemplate dummy response.
*
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
index ca4c2e573..628aef96e 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Bell Canada. 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.
@@ -30,15 +30,12 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import java.time.Instant;
import java.util.ArrayList;
import org.junit.Test;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.pdp.persistence.provider.PdpFilterParameters;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
@@ -112,17 +109,6 @@ public class DummyPolicyModelsProviderTest {
dummyProvider.updatePdpSubGroup("name", new PdpSubGroup());
dummyProvider.updatePdp("name", "type", new Pdp());
- dummyProvider.updatePdpStatistics(new ArrayList<>());
- assertThat(dummyProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().name("name").build()))
- .isEmpty();
-
- assertTrue(
- dummyProvider.getFilteredPdpStatistics(
- PdpFilterParameters.builder().name("name")
- .startTime(Instant.now()).endTime(Instant.now()).build()).isEmpty());
- assertTrue(dummyProvider.createPdpStatistics(null).isEmpty());
- assertTrue(dummyProvider.updatePdpStatistics(null).isEmpty());
- assertTrue(dummyProvider.deletePdpStatistics(null, Instant.now()).isEmpty());
assertThat(dummyProvider.getAllPolicyStatus()).isEmpty();
assertThat(dummyProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy",
@@ -130,8 +116,6 @@ public class DummyPolicyModelsProviderTest {
assertThat(dummyProvider.getGroupPolicyStatus("name")).isEmpty();
assertThatCode(() -> dummyProvider.cudPolicyStatus(null, null,
null)).doesNotThrowAnyException();
- assertThatCode(() -> dummyProvider.createAuditRecords(null)).doesNotThrowAnyException();
- assertThat(dummyProvider.getAuditRecords(AuditFilter.builder().recordNum(10).build())).isEmpty();
}
@Test
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyStatisticsPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyStatisticsPersistenceTest.java
deleted file mode 100644
index abc08846a..000000000
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyStatisticsPersistenceTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.provider.impl;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-
-import java.time.Instant;
-import java.util.Arrays;
-import org.junit.Test;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.pdp.concepts.PdpStatistics;
-import org.onap.policy.models.provider.PolicyModelsProvider;
-import org.onap.policy.models.provider.PolicyModelsProviderFactory;
-import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-
-/**
- * Test persistence of PDP statistics to and from the database.
- */
-public class PolicyStatisticsPersistenceTest {
-
- @Test
- public void testPdpStatiscticsPersistence() throws PfModelException {
- // Try the test on three providers
- for (int i = 0; i < 3; i++) {
- try (PolicyModelsProvider databaseProvider = setupProvider()) {
- testPdpStatiscticsPersistenceOneProvider(databaseProvider);
- }
- }
- }
-
- public void testPdpStatiscticsPersistenceOneProvider(PolicyModelsProvider databaseProvider) {
- PdpStatistics pdpStatistics = new PdpStatistics();
- pdpStatistics.setPdpInstanceId("TheInstance");
- pdpStatistics.setTimeStamp(Instant.now());
-
- // Try creating three identical statistics instances
- for (int i = 0; i < 3; i++) {
- assertThatCode(() -> databaseProvider.createPdpStatistics(Arrays.asList(pdpStatistics)))
- .doesNotThrowAnyException();
- }
-
- // Try creating three statistics instances with timestams incremented
- for (int i = 0; i < 3; i++) {
- pdpStatistics.setTimeStamp(pdpStatistics.getTimeStamp().plusSeconds(1));
-
- assertThatCode(() -> databaseProvider.createPdpStatistics(Arrays.asList(pdpStatistics)))
- .doesNotThrowAnyException();
- }
- }
-
- private PolicyModelsProvider setupProvider() throws PfModelException {
- PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
-
- if (System.getProperty("USE-MARIADB") != null) {
- parameters.setDatabaseDriver("org.mariadb.jdbc.Driver");
- parameters.setDatabaseUrl("jdbc:mariadb://localhost:3306/policy");
- } else {
- parameters.setDatabaseDriver("org.h2.Driver");
- parameters.setDatabaseUrl("jdbc:h2:mem:PolicyStatisticsPersistenceTest");
- }
-
- parameters.setDatabaseUser("policy");
- parameters.setDatabasePassword("P01icY");
- parameters.setPersistenceUnit("ToscaConceptTest");
-
- return new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
- }
-}