From b7239e0e2859d998d5f8448879409eb30c3bc658 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 30 Sep 2020 14:32:56 -0400 Subject: Fix new sonars in drools-pdp Addressed the following sonar issues: - extract common test method - too many assertions in test method - don't always return the same value Issue-ID: POLICY-2616 Change-Id: Iab836cdcd667b35e2db9db7d6ffc7896df33e1c8 Signed-off-by: Jim Hahn --- .../system/internal/AggregatedPolicyControllerTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'policy-management') diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java index 0b959f05..6b669a2d 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java @@ -600,20 +600,17 @@ public class AggregatedPolicyControllerTest { @Test(expected = IllegalArgumentException.class) public void testDeliver_NullTopic() { - apc.start(); - apc.deliver(CommInfrastructure.NOOP, null, MY_EVENT); + validateDeliverFailure(null, MY_EVENT); } @Test(expected = IllegalArgumentException.class) public void testDeliver_EmptyTopic() { - apc.start(); - apc.deliver(CommInfrastructure.NOOP, "", MY_EVENT); + validateDeliverFailure("", MY_EVENT); } @Test(expected = IllegalArgumentException.class) public void testDeliver_NullEvent() { - apc.start(); - apc.deliver(CommInfrastructure.NOOP, SINK_TOPIC1, null); + validateDeliverFailure(SINK_TOPIC1, null); } @Test(expected = IllegalStateException.class) @@ -788,6 +785,11 @@ public class AggregatedPolicyControllerTest { assertTrue(apc.toString().startsWith("AggregatedPolicyController [")); } + private void validateDeliverFailure(String topic, String event) { + apc.start(); + apc.deliver(CommInfrastructure.NOOP, topic, event); + } + /** * Performs an operation that has a beforeXxx method and an afterXxx method. Tries * combinations where beforeXxx and afterXxx return {@code true} and {@code false}. -- cgit 1.2.3-korg