private static final int DEFAULT_RECORD_COUNT = 10;
private static final int MAX_RECORD_COUNT = 100;
- /**
- * Get PDP statistics.
- *
- * @param dao the DAO to use to access the database
- * @param name the name of the PDP statistics to get, null to get all PDPs
- * @return the PDP statistics found
- * @throws PfModelException on errors getting PDP statistics
- */
- public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name, final Instant timeStamp)
- throws PfModelException {
- return asPdpStatisticsList(dao.getFiltered(JpaPdpStatistics.class, PdpFilterParameters.builder().name(name)
- .startTime(timeStamp).endTime(timeStamp).recordNum(MAX_RECORD_COUNT).build()));
- }
-
- /**
- * Get PDP statistics.
- *
- * @param dao the DAO to use to access the database
- * @param name the name of the PDP statistics to get, null to get all PDPs
- * @return the PDP statistics found
- * @throws PfModelException on errors getting PDP statistics
- */
- public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name)
- throws PfModelException {
- return asPdpStatisticsList(dao.getFiltered(JpaPdpStatistics.class,
- PdpFilterParameters.builder().name(name).recordNum(MAX_RECORD_COUNT).build()));
- }
-
/**
* Get filtered PDP statistics.
*
.hasMessageContaining(Validated.IS_A_NULL_KEY);
}
- @Test
- public void testGetPdpStatisticsName() throws Exception {
- assertThatThrownBy(() -> {
- new PdpStatisticsProvider().createPdpStatistics(null, null);
- }).hasMessageMatching(DAO_IS_NULL);
- assertThatThrownBy(() -> {
- new PdpStatisticsProvider().getPdpStatistics(null, null);
- }).hasMessageMatching(DAO_IS_NULL);
-
- List<PdpStatistics> getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, NAME);
- verifyEquals(getPdpStatisticsList, List.of(pdpStatistics12, pdpStatistics11));
-
- // name is null
- getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, null);
- verifyEquals(getPdpStatisticsList, List.of(pdpStatistics12, pdpStatistics22, pdpStatistics11, pdpStatistics31));
- }
-
- @Test
- public void testGetPdpStatisticsNameTimestamp() throws Exception {
- assertThatThrownBy(() -> {
- new PdpStatisticsProvider().createPdpStatistics(null, null);
- }).hasMessageMatching(DAO_IS_NULL);
- assertThatThrownBy(() -> {
- new PdpStatisticsProvider().getPdpStatistics(null, null, null);
- }).hasMessageMatching(DAO_IS_NULL);
-
- List<PdpStatistics> getPdpStatisticsList;
- getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, NAME, TIMESTAMP1);
- verifyEquals(getPdpStatisticsList, List.of(pdpStatistics11));
-
- // name is null
- getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, null, TIMESTAMP1);
- verifyEquals(getPdpStatisticsList, List.of(pdpStatistics11, pdpStatistics31));
-
- // timestamp is null
- getPdpStatisticsList = new PdpStatisticsProvider().getPdpStatistics(pfDao, NAME, null);
- verifyEquals(getPdpStatisticsList, List.of(pdpStatistics11, pdpStatistics12));
- }
-
@Test
public void testGetFilteredPdpStatistics() throws Exception {
*/
public PdpGroup deletePdpGroup(@NonNull final String name) throws PfModelException;
- /**
- * Get PDP statistics.
- *
- * @param name the name of the PDP group to get statistics for, null to get all PDP groups
- * @return the statistics found
- * @throws PfModelException on errors getting statistics
- */
- public List<PdpStatistics> getPdpStatistics(final String name, final Instant timestamp) throws PfModelException;
-
/**
* Get filtered PdpStatistics.
return new PdpProvider().deletePdpGroup(getPfDao(), name);
}
- @Override
- public List<PdpStatistics> getPdpStatistics(final String name, final Instant timestamp) throws PfModelException {
- assertInitialized();
- return new PdpStatisticsProvider().getPdpStatistics(getPfDao(), name, timestamp);
- }
-
@Override
public List<PdpStatistics> getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException {
assertInitialized();
return null;
}
- @Override
- public List<PdpStatistics> getPdpStatistics(final String name, final Instant timestamp) throws PfModelException {
- return new ArrayList<>();
- }
-
@Override
public List<PdpStatistics> getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException {
// Not implemented
List<PdpStatistics> statisticsArrayList = makePdpStatisticsList();
- assertThat(databaseProvider.getPdpStatistics(null, null)).isEmpty();
+ assertThat(databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().build())).isEmpty();
assertThat(databaseProvider.createPdpStatistics(statisticsArrayList)).hasSize(1);
assertThat(databaseProvider.updatePdpStatistics(statisticsArrayList)).hasSize(1);
}
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
databaseProvider.createPdpStatistics(makePdpStatisticsList());
- assertEquals(NAME, databaseProvider.getPdpStatistics(null, null).get(0).getPdpInstanceId());
+ 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(
.sortOrder(ORDER).recordNum(5).build()).size());
assertEquals(NAME, databaseProvider.deletePdpStatistics(NAME, null).get(0).getPdpInstanceId());
- assertEquals(0, databaseProvider.getPdpStatistics(null, null).size());
+ assertThat(databaseProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().build())).isEmpty();
assertThat(databaseProvider.getAllPolicyStatus()).isEmpty();
assertThat(databaseProvider.getAllPolicyStatus(new ToscaConceptIdentifierOptVersion("MyPolicy", null)))
// do nothing
}
- @Override
- public List<PdpStatistics> getPdpStatistics(final String name, final Instant timestamp) throws PfModelException {
- return new ArrayList<>();
- }
-
@Override
public List<PdpStatistics> getFilteredPdpStatistics(PdpFilterParameters filterParams) throws PfModelException {
// Not implemented
dummyProvider.updatePdpSubGroup("name", new PdpSubGroup());
dummyProvider.updatePdp("name", "type", new Pdp());
dummyProvider.updatePdpStatistics(new ArrayList<>());
- assertTrue(dummyProvider.getPdpStatistics("name", null).isEmpty());
+ assertThat(dummyProvider.getFilteredPdpStatistics(PdpFilterParameters.builder().name("name").build()))
+ .isEmpty();
assertTrue(
dummyProvider.getFilteredPdpStatistics(