diff options
author | Jim Hahn <jrh3@att.com> | 2020-08-25 17:05:37 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-08-25 18:47:23 -0400 |
commit | 72cf248dced4e272e69a8c48f5ee24c9d345f41d (patch) | |
tree | b09ed0f9b7ee7aac6493119d950d78d50ae08da1 /feature-session-persistence | |
parent | 5c71b5a62f4208030b3c3cd18b3f42398a0a86e5 (diff) |
Address more sonars in drools-pdp
Addressed the following sonars:
- either log or rethrow
- call "remove()" for thread-local-storage
- use assertEquals
- only one method call in exception test
- swap arguments in assertEquals
- add assertion to assertThatThrownBy()
- explain @Ignore
Also addressed eclipse warnings:
- unused fields and methods
Issue-ID: POLICY-2616
Change-Id: I6590c0d2b103885bc933014d48bf5fd92401cd80
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-session-persistence')
2 files changed, 8 insertions, 18 deletions
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java index ed427255..efe2a294 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java @@ -767,6 +767,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine } } + session.removePolicySession(); logger.info("PersistentThreadModel completed"); } } diff --git a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java index 25f805d7..ec261982 100644 --- a/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java +++ b/feature-session-persistence/src/test/java/org/onap/policy/drools/persistence/PersistenceFeatureTest.java @@ -1098,15 +1098,9 @@ public class PersistenceFeatureTest { // return adjunct on next call when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue()); - try { - doThrow(new IllegalArgumentException(EXPECTED)).when(emf).close(); - - feat.destroyKieSession(polsess); - fail(MISSING_EXCEPTION); - - } catch (IllegalArgumentException ex) { - logger.trace(EXPECTED, ex); - } + IllegalArgumentException exception = new IllegalArgumentException(EXPECTED); + doThrow(exception).when(emf).close(); + assertThatCode(() -> feat.destroyKieSession(polsess)).isEqualTo(exception); verify(bds, times(2)).close(); } @@ -1126,15 +1120,10 @@ public class PersistenceFeatureTest { // return adjunct on next call when(polcont.getAdjunct(any())).thenReturn(adjcap.getValue()); - try { - doThrow(new SQLException(EXPECTED)).when(bds).close(); - - feat.destroyKieSession(polsess); - fail(MISSING_EXCEPTION); - - } catch (PersistenceFeatureException ex) { - logger.trace(EXPECTED, ex); - } + SQLException cause = new SQLException(EXPECTED); + doThrow(cause).when(bds).close(); + assertThatCode(() -> feat.destroyKieSession(polsess)).isInstanceOf(PersistenceFeatureException.class) + .hasCause(cause); } /** |