From 72cf248dced4e272e69a8c48f5ee24c9d345f41d Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 25 Aug 2020 17:05:37 -0400 Subject: 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 --- .../test/java/org/onap/policy/drools/policies/DomainMakerTest.java | 6 ++++-- .../org/onap/policy/drools/utils/logging/MdcTransactionTest.java | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'policy-utils/src/test') diff --git a/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java b/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java index 47d6c2d8..5bc767cd 100644 --- a/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java +++ b/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java @@ -108,7 +108,8 @@ public class DomainMakerTest { assertDomainPolicy(domainAPolicy); domainAPolicy.getProperties().getNested().setNested1(""); - assertThatThrownBy(() -> domainMaker.conformance(policy1.getTypeIdentifier(), domainAPolicy)) + ToscaPolicyTypeIdentifier ident1 = policy1.getTypeIdentifier(); + assertThatThrownBy(() -> domainMaker.conformance(ident1, domainAPolicy)) .isInstanceOf(ValidationFailedException.class) .hasMessageContaining("Pattern ^(.+)$ is not contained in text"); } @@ -142,8 +143,9 @@ public class DomainMakerTest { @Test public void testConvertToSchema() { + ToscaPolicyType type = new ToscaPolicyType(); assertThatThrownBy(() -> domainMaker - .convertToSchema(new ToscaPolicyType())) + .convertToSchema(type)) .isInstanceOf(UnsupportedOperationException.class); } diff --git a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java index dbf6a67c..82a2b2e6 100644 --- a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java +++ b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java @@ -164,7 +164,6 @@ public class MdcTransactionTest { assertEquals(trans.getInvocationId(), MDC.get(MdcTransactionConstants.INVOCATION_ID)); assertEquals(trans.timestamp(trans.getStartTime()), MDC.get(MdcTransactionConstants.BEGIN_TIMESTAMP)); assertEquals(trans.timestamp(trans.getEndTime()), MDC.get(MdcTransactionConstants.END_TIMESTAMP)); - assertNotEquals(trans.getElapsedTime(), MDC.get(MdcTransactionConstants.ELAPSED_TIME)); assertEquals(String.valueOf(Duration.between(trans.getStartTime(), trans.getEndTime()).toMillis()), MDC.get(MdcTransactionConstants.ELAPSED_TIME)); assertEquals(trans.getServiceInstanceId(), MDC.get(MdcTransactionConstants.SERVICE_INSTANCE_ID)); -- cgit 1.2.3-korg