From 347bc1022aba20ae134848ef1a04930e9cb69b09 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Thu, 2 Sep 2021 09:39:37 -0400 Subject: Fix PAP PDP expiration timer Added runtime exceptions to the "catch" clause so that the thread associated with the PDP expiration timer will not terminate. Also added to a few other "catch" clauses, particularly those in the REST controllers. Issue-ID: POLICY-3625 Change-Id: I9206121d3e9b91da593ae771e7586752b13949be Signed-off-by: Jim Hahn --- .../onap/policy/pap/main/comm/PdpModifyRequestMapTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'main/src/test/java/org') diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java index 27c01e18..e626d28d 100644 --- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java @@ -56,6 +56,7 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.pdp.concepts.Pdp; import org.onap.policy.models.pdp.concepts.PdpGroup; import org.onap.policy.models.pdp.concepts.PdpMessage; @@ -422,6 +423,13 @@ public class PdpModifyRequestMapTest extends CommonRequestBase { assertThatCode(map::removeExpiredPdps).doesNotThrowAnyException(); } + @Test + public void testRemoveExpiredPdps_DaoRtEx() throws Exception { + when(dao.getFilteredPdpGroups(any())).thenThrow(makeRuntimeException()); + + assertThatCode(map::removeExpiredPdps).doesNotThrowAnyException(); + } + @Test public void testRemoveFromSubgroup() throws Exception { PdpGroup group = makeGroup(MY_GROUP); @@ -454,6 +462,10 @@ public class PdpModifyRequestMapTest extends CommonRequestBase { return new PfModelException(Status.BAD_REQUEST, "expected exception"); } + protected PfModelRuntimeException makeRuntimeException() { + return new PfModelRuntimeException(Status.BAD_REQUEST, "expected exception"); + } + @Test public void testMakePdpRequests() { // this should invoke the real method without throwing an exception -- cgit 1.2.3-korg