aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-10 14:23:02 -0500
committerJim Hahn <jrh3@att.com>2021-02-10 14:26:29 -0500
commite3035927b9c49478e28e5ca7fca7c42c43b7300e (patch)
tree4d06bcb63231427fbc07ed77f4c7d9f0f483440e
parent98d2ab1beb887658521d4ff42ba6b17a97f8ebae (diff)
More sonar issues in common
Addressed the issues: - use of eq() in verify() - remove @NamedQueries - use computeIfAbsent() Issue-ID: POLICY-2914 Change-Id: I265bc98f0f326e7b4ce86c25e68fc4859bd7fb02 Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java6
-rw-r--r--common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java9
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java8
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java8
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java7
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java9
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientTest.java7
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java47
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java7
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java8
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/time/TestTimeMulti.java8
11 files changed, 56 insertions, 68 deletions
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
index 71476c6a..3e021169 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,9 +66,7 @@ public class EventTrackInfo {
return;
}
// in case override the start time, check the original event was already stored or not
- if (!eventInfo.containsKey(id)) {
- eventInfo.put(id, event);
- }
+ eventInfo.putIfAbsent(id, event);
}
}
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java
index eb6daee9..fadb2545 100644
--- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java
+++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/FlexLogger.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-Logging
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -179,12 +179,7 @@ public class FlexLogger extends SecurityManager {
String className = new FlexLogger().getClassName();
- if (!systemOutMap.containsKey(className)) {
- SystemOutLogger logger = new SystemOutLogger(className);
- systemOutMap.put(className, logger);
- }
-
- return systemOutMap.get(className);
+ return systemOutMap.computeIfAbsent(className, SystemOutLogger::new);
}
/**
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
index 2b2b806a..121b28b4 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
@@ -43,9 +42,8 @@ import org.onap.policy.common.ia.AuditorTime;
@Entity
@Table(name = "IntegrityAuditEntity")
-@NamedQueries({@NamedQuery(name = " IntegrityAuditEntity.findAll", query = "SELECT e FROM IntegrityAuditEntity e "),
- @NamedQuery(name = "IntegrityAuditEntity.deleteAll",
- query = "DELETE FROM IntegrityAuditEntity WHERE 1=1")})
+@NamedQuery(name = " IntegrityAuditEntity.findAll", query = "SELECT e FROM IntegrityAuditEntity e ")
+@NamedQuery(name = "IntegrityAuditEntity.deleteAll", query = "DELETE FROM IntegrityAuditEntity WHERE 1=1")
public class IntegrityAuditEntity implements Serializable {
private static final long serialVersionUID = 1L;
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java
index aa3524f0..88159311 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
@@ -41,9 +40,8 @@ import org.onap.policy.common.im.MonitorTime;
@Entity
@Table(name = "ForwardProgressEntity")
-@NamedQueries({@NamedQuery(name = " ForwardProgressEntity.findAll", query = "SELECT e FROM ForwardProgressEntity e "),
- @NamedQuery(name = "ForwardProgressEntity.deleteAll",
- query = "DELETE FROM ForwardProgressEntity WHERE 1=1")})
+@NamedQuery(name = " ForwardProgressEntity.findAll", query = "SELECT e FROM ForwardProgressEntity e ")
+@NamedQuery(name = "ForwardProgressEntity.deleteAll", query = "DELETE FROM ForwardProgressEntity WHERE 1=1")
// @SequenceGenerator(name="seqForwardProgress", initialValue=1, allocationSize=1)
public class ForwardProgressEntity implements Serializable {
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java
index 1eaf3a6f..14dce068 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
@@ -38,8 +37,8 @@ import org.onap.policy.common.im.MonitorTime;
@Entity
@Table(name = "ImTestEntity")
-@NamedQueries({@NamedQuery(name = " ImTestEntity.findAll", query = "SELECT e FROM ImTestEntity e "),
- @NamedQuery(name = "ImTestEntity.deleteAll", query = "DELETE FROM ImTestEntity WHERE 1=1")})
+@NamedQuery(name = " ImTestEntity.findAll", query = "SELECT e FROM ImTestEntity e ")
+@NamedQuery(name = "ImTestEntity.deleteAll", query = "DELETE FROM ImTestEntity WHERE 1=1")
// @SequenceGenerator(name="seqImTest", initialValue=1, allocationSize=1)
public class ImTestEntity implements Serializable {
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java
index d73100f7..20237afc 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
@@ -41,10 +40,8 @@ import org.onap.policy.common.im.MonitorTime;
@Entity
@Table(name = "ResourceRegistrationEntity")
-@NamedQueries({@NamedQuery(name = " ResourceRegistrationEntity.findAll",
- query = "SELECT e FROM ResourceRegistrationEntity e "),
- @NamedQuery(name = "ResourceRegistrationEntity.deleteAll",
- query = "DELETE FROM ResourceRegistrationEntity WHERE 1=1")})
+@NamedQuery(name = " ResourceRegistrationEntity.findAll", query = "SELECT e FROM ResourceRegistrationEntity e ")
+@NamedQuery(name = "ResourceRegistrationEntity.deleteAll", query = "DELETE FROM ResourceRegistrationEntity WHERE 1=1")
// @SequenceGenerator(name="seqResourceRegistration", initialValue=1, allocationSize=1)
public class ResourceRegistrationEntity implements Serializable {
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientTest.java
index 3f0a002c..ffa7c5a1 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -103,7 +102,7 @@ public class BidirectionalTopicClientTest {
when(endpoint.getTopicSinks(SINK_TOPIC)).thenReturn(Arrays.asList(sink));
when(endpoint.getTopicSources(any())).thenReturn(Arrays.asList());
- when(endpoint.getTopicSources(eq(Arrays.asList(SOURCE_TOPIC)))).thenReturn(Arrays.asList(source));
+ when(endpoint.getTopicSources(Arrays.asList(SOURCE_TOPIC))).thenReturn(Arrays.asList(source));
client = new BidirectionalTopicClient2(SINK_TOPIC, SOURCE_TOPIC);
}
@@ -132,7 +131,7 @@ public class BidirectionalTopicClientTest {
.hasMessage("no sources for topic: unknown-source");
// too many sources
- when(endpoint.getTopicSources(eq(Arrays.asList(SOURCE_TOPIC)))).thenReturn(Arrays.asList(source, source));
+ when(endpoint.getTopicSources(Arrays.asList(SOURCE_TOPIC))).thenReturn(Arrays.asList(source, source));
assertThatThrownBy(() -> new BidirectionalTopicClient2(SINK_TOPIC, SOURCE_TOPIC))
.isInstanceOf(BidirectionalTopicClientException.class)
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java
index 94717e53..d71d413e 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ package org.onap.policy.common.endpoints.listeners;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -119,16 +118,16 @@ public class RequestIdDispatcherTest {
// should process message that does not have a request id
status = new MyMessage();
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1).onTopicEvent(INFRA, TOPIC, status);
// should process again
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1, times(2)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1, times(2)).onTopicEvent(INFRA, TOPIC, status);
// should NOT process a message that has a request id
status = new MyMessage(REQID1);
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1, never()).onTopicEvent(INFRA, TOPIC, status);
}
@Test
@@ -138,21 +137,21 @@ public class RequestIdDispatcherTest {
// should NOT process message that does not have a request id
status = new MyMessage();
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1, never()).onTopicEvent(INFRA, TOPIC, status);
// should process a message that has the desired request id
status = new MyMessage(REQID1);
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1).onTopicEvent(INFRA, TOPIC, status);
// should process again
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1, times(2)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1, times(2)).onTopicEvent(INFRA, TOPIC, status);
// should NOT process a message that does NOT have the desired request id
status = new MyMessage(REQID2);
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1, never()).onTopicEvent(INFRA, TOPIC, status);
// null request id => exception
assertThatIllegalArgumentException().isThrownBy(() -> primary.register(null, secondary1));
@@ -169,17 +168,17 @@ public class RequestIdDispatcherTest {
// should process message
status = new MyMessage();
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
- verify(secondary2).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1).onTopicEvent(INFRA, TOPIC, status);
+ verify(secondary2).onTopicEvent(INFRA, TOPIC, status);
primary.unregister(secondary1);
// should NOT process again
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1, times(1)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1, times(1)).onTopicEvent(INFRA, TOPIC, status);
// other listener should still have processed it
- verify(secondary2, times(2)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary2, times(2)).onTopicEvent(INFRA, TOPIC, status);
}
@Test
@@ -190,18 +189,18 @@ public class RequestIdDispatcherTest {
// should process a message that has the desired request id
status = new MyMessage(REQID1);
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1).onTopicEvent(INFRA, TOPIC, status);
primary.unregister(REQID1);
// should NOT re-process
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1, times(1)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1, times(1)).onTopicEvent(INFRA, TOPIC, status);
// secondary should still be able to process
status = new MyMessage(REQID2);
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary2).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary2).onTopicEvent(INFRA, TOPIC, status);
}
@Test
@@ -214,18 +213,18 @@ public class RequestIdDispatcherTest {
// without request id
status = new MyMessage();
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
- verify(secondary2, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
- verify(secondary3).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
- verify(secondary4).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1, never()).onTopicEvent(INFRA, TOPIC, status);
+ verify(secondary2, never()).onTopicEvent(INFRA, TOPIC, status);
+ verify(secondary3).onTopicEvent(INFRA, TOPIC, status);
+ verify(secondary4).onTopicEvent(INFRA, TOPIC, status);
// with request id
status = new MyMessage(REQID1);
primary.onTopicEvent(INFRA, TOPIC, makeSco(status));
- verify(secondary1).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
- verify(secondary2, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
- verify(secondary3, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
- verify(secondary4, never()).onTopicEvent(eq(INFRA), eq(TOPIC), eq(status));
+ verify(secondary1).onTopicEvent(INFRA, TOPIC, status);
+ verify(secondary2, never()).onTopicEvent(INFRA, TOPIC, status);
+ verify(secondary3, never()).onTopicEvent(INFRA, TOPIC, status);
+ verify(secondary4, never()).onTopicEvent(INFRA, TOPIC, status);
}
@Test
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java
index 8543b73e..a782e4b2 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ package org.onap.policy.common.endpoints.listeners;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -111,14 +110,14 @@ public class ScoListenerTest {
status = new MyMessage(NAME);
sco = makeSco(status);
primary.onTopicEvent(INFRA, TOPIC, sco);
- verify(primary).onTopicEvent(eq(INFRA), eq(TOPIC), eq(sco), eq(status));
+ verify(primary).onTopicEvent(INFRA, TOPIC, sco, status);
assertFalse(appender.getExtracted().toString().contains("unable to decode"));
// undecodable message
logger.addAppender(appender);
primary.onTopicEvent(INFRA, TOPIC, makeSco("[]"));
- verify(primary, times(1)).onTopicEvent(eq(INFRA), eq(TOPIC), eq(sco), eq(status));
+ verify(primary, times(1)).onTopicEvent(INFRA, TOPIC, sco, status);
assertTrue(appender.getExtracted().toString().contains("unable to decode"));
}
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java
index 01206c32..e267179e 100644
--- a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java
+++ b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -169,7 +169,11 @@ public class GsonTestUtils {
JsonElement gsonjo = reorder(gson.fromJson(sgson, JsonElement.class));
JsonElement expjo = reorder(expected);
- assertEquals(expjo.toString(), gsonjo.toString());
+ /*
+ * As this method is only used within junit tests, it is OK to use assert calls,
+ * thus sonar is disabled.
+ */
+ assertEquals(expjo.toString(), gsonjo.toString()); // NOSONAR
}
/**
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTimeMulti.java b/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTimeMulti.java
index f4b36a00..54ec601a 100644
--- a/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTimeMulti.java
+++ b/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTimeMulti.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -189,11 +189,13 @@ public class TestTimeMulti extends TestTime {
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.error("interrupted while waiting for condition", e);
- fail("interrupted while waiting for condition: " + e.getMessage());
+ // disabling sonar, as this is only used by junit tests
+ fail("interrupted while waiting for condition: " + e.getMessage()); // NOSONAR
} catch (Exception e) {
logger.error("condition evaluator threw an exception", e);
- fail("condition evaluator threw an exception: " + e.getMessage());
+ // disabling sonar, as this is only used by junit tests
+ fail("condition evaluator threw an exception: " + e.getMessage()); // NOSONAR
}
fail(NEVER_SATISFIED);