aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-06-24 15:46:36 -0400
committerJim Hahn <jrh3@att.com>2019-06-26 08:55:15 -0400
commit67fcc6f6abb7904ecd4b4444fa23b355cf9fd4ae (patch)
treef5c63d96a4d337e8210f4d83c3dd14caf8e1c051 /policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
parentd1ab0ec8471deeb7739206dc2ef0aac3dc5b245f (diff)
Fix some sonar issues in policy-endpoints
Refactored various classes to reduce cyclomatic complexity. Introduced some endpoint utility classes to facilitate extraction and conversion of property values, and populating of common "builder" values. Change-Id: Ie1c91cd94cb54700dc9127f72780b4d94b82ec39 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
index 6e84c137..2860377e 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java
@@ -39,6 +39,7 @@ import org.slf4j.Logger;
*/
public class NetLoggerUtilTest {
+ private static final String TEST_TOPIC = "test-topic";
private static final String MESSAGE = "hello world!";
/**
* Test feature used for junits.
@@ -76,7 +77,7 @@ public class NetLoggerUtilTest {
*/
@Test
public void logTest() {
- NetLoggerUtil.log(EventType.IN, CommInfrastructure.NOOP, "test-topic", MESSAGE);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.NOOP, TEST_TOPIC, MESSAGE);
assertEquals(3, TestAppender.events.size());
}
@@ -85,7 +86,7 @@ public class NetLoggerUtilTest {
*/
@Test
public void logDefaultTest() {
- NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, "test-topic", MESSAGE);
+ NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, TEST_TOPIC, MESSAGE);
assertEquals(3, TestAppender.events.size());
assertEquals("network", TestAppender.events.get(0).getLoggerName());
}
@@ -96,7 +97,7 @@ public class NetLoggerUtilTest {
@Test
public void beforeLogReturnTrueTest() {
netLoggerFeature.setReturnValue(true, false);
- NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, "test-topic", MESSAGE);
+ NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, TEST_TOPIC, MESSAGE);
assertEquals(1, TestAppender.events.size());
}
@@ -106,7 +107,7 @@ public class NetLoggerUtilTest {
@Test
public void afterLogReturnTrueTest() {
netLoggerFeature.setReturnValue(false, true);
- NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, "test-topic", MESSAGE);
+ NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, TEST_TOPIC, MESSAGE);
assertEquals(3, TestAppender.events.size());
}
@@ -116,7 +117,7 @@ public class NetLoggerUtilTest {
@Test
public void beforeLogExceptionTest() {
netLoggerFeature.setExceptions(true, false);
- NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, "test-topic", MESSAGE);
+ NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, TEST_TOPIC, MESSAGE);
assertEquals(2, TestAppender.events.size());
}
@@ -126,7 +127,7 @@ public class NetLoggerUtilTest {
@Test
public void afterLogExceptionTest() {
netLoggerFeature.setExceptions(false, true);
- NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, "test-topic", MESSAGE);
+ NetLoggerUtil.log(null, EventType.IN, CommInfrastructure.NOOP, TEST_TOPIC, MESSAGE);
assertEquals(2, TestAppender.events.size());
}
@@ -139,7 +140,7 @@ public class NetLoggerUtilTest {
/**
* List of logged events.
*/
- public static List<ILoggingEvent> events = new ArrayList<>();
+ private static final List<ILoggingEvent> events = new ArrayList<>();
/**
* Called after every unit test to clear list of events.