diff options
Diffstat (limited to 'models-pap/src/test')
-rw-r--r-- | models-pap/src/test/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProviderTest.java | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProviderTest.java b/models-pap/src/test/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProviderTest.java index 228a3fc01..0540d4844 100644 --- a/models-pap/src/test/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProviderTest.java +++ b/models-pap/src/test/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProviderTest.java @@ -134,7 +134,37 @@ public class PolicyAuditProviderTest { PolicyAuditProvider provider = new PolicyAuditProvider(); Instant date = Instant.now().truncatedTo(ChronoUnit.SECONDS); - System.out.println(date); + provider.createAuditRecords(pfDao, generatePolicyAudits(date, GROUP_A, MY_POLICY)); + provider.createAuditRecords(pfDao, generatePolicyAudits(date, GROUP_B, MY_POLICY)); + provider.createAuditRecords(pfDao, generatePolicyAudits(date, GROUP_B, MY_POLICY2)); + Awaitility.await().pollDelay(3, TimeUnit.SECONDS).until(() -> { + return true; + }); + + List<PolicyAudit> records = provider.getAuditRecords(pfDao, + AuditFilter.builder().fromDate(date).toDate(Instant.now()).recordNum(NUMBER_RECORDS).build()); + assertThat(records).hasSize(6); + + List<PolicyAudit> recordsWithGroupB = + provider.getAuditRecords(pfDao, + AuditFilter.builder().pdpGroup(GROUP_B).recordNum(NUMBER_RECORDS).build()); + assertThat(recordsWithGroupB).hasSize(4); + + List<PolicyAudit> recordsWithActionDeploy = provider.getAuditRecords(pfDao, + AuditFilter.builder().action(AuditAction.DEPLOYMENT).recordNum(NUMBER_RECORDS).build()); + assertThat(recordsWithActionDeploy).hasSize(3); + + List<PolicyAudit> recordsWithMyPolicy = provider.getAuditRecords(pfDao, + AuditFilter.builder().name(MY_POLICY.getName()).version(MY_POLICY.getVersion()) + .recordNum(NUMBER_RECORDS).build()); + assertThat(recordsWithMyPolicy).hasSize(4); + } + + @Test + public void testFiltersOld() { + PolicyAuditProvider provider = new PolicyAuditProvider(); + + Instant date = Instant.now().truncatedTo(ChronoUnit.SECONDS); provider.createAuditRecords(pfDao, generatePolicyAudits(date, GROUP_A, MY_POLICY)); provider.createAuditRecords(pfDao, generatePolicyAudits(date, GROUP_B, MY_POLICY)); provider.createAuditRecords(pfDao, generatePolicyAudits(date, GROUP_B, MY_POLICY2)); @@ -202,7 +232,7 @@ public class PolicyAuditProviderTest { }).hasMessageMatching(String.format(FIELD_IS_NULL, "dao")); assertThatThrownBy(() -> { - provider.getAuditRecords(pfDao, null); + provider.getAuditRecords(pfDao, (Integer) null); }).hasMessageMatching(String.format(FIELD_IS_NULL, "numRecords")); assertThatThrownBy(() -> { |