diff options
author | Jim Hahn <jrh3@att.com> | 2021-06-10 17:38:58 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-06-14 08:21:04 -0400 |
commit | 8cbad257df2d5f5c585ce37e61cfd16e402be738 (patch) | |
tree | 18027d19e9c6c231e41e4321d5938c8b0a5d5632 /models-pap/src/test | |
parent | 1b460194bc034443ba57fa690d294131836a3e9e (diff) |
Fix sonars in policy-models
Fixed:
- too many parameters in method call
Fixed it by introducing PfFilterParameters. However, classes having the
Builder annotation are not easily subclassed, so introduced an
interface, too.
Issue-ID: POLICY-3094
Change-Id: Ida99522a542b1296b367c55b7e8f8e83783c2e4f
Signed-off-by: Jim Hahn <jrh3@att.com>
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(() -> { |