summaryrefslogtreecommitdiffstats
path: root/models-sim/models-sim-dmaap/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-04-07 13:58:09 -0400
committerJim Hahn <jrh3@att.com>2020-04-07 17:15:07 -0400
commit9b3ff5f270572a6760ff07dda9577cdadb53b088 (patch)
treeeacd325199fbb72fddaba94a057178a19e9c3360 /models-sim/models-sim-dmaap/src/test
parent3000fdca611c32b7001c553621660b8ea0d2eb49 (diff)
Address sonar issues in models
Addressed the following sonar issues: - use RE2 instead of java.util Pattern for "+" and "*" - don't use deprecated methods - for Date(long), sonar appeared not to parse the argument's type correctly. Modified the code slightly to make sonar happy - duplicate blocks of code - either log or throw - missing assert in junit - for SDNR & VFC, eliminated threads, as they are unnecessary - duplicate code block in different branches - useless assignments - redeclaring abstract methods - cyclomatic complexity - used lombok in some cases (e.g., EqualsAndHashCode) - assert argument order - actually deleted ControlLoopTargetType, because it is not needed and sonar complains regardless of which order is used - add private constructor to utility classes - use StandardCharsets instead of literals Also: - added logback-test.xml to SO to eliminate the voluminous output from the junit test Issue-ID: POLICY-2305 Change-Id: I586c331781bedbd54a115a71847d04d293689445 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-sim/models-sim-dmaap/src/test')
-rw-r--r--models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java6
-rw-r--r--models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/MainTest.java5
2 files changed, 7 insertions, 4 deletions
diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java
index 4b9549a52..6c79ce9f8 100644
--- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java
+++ b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/provider/DmaapSimProviderTest.java
@@ -18,6 +18,7 @@
package org.onap.policy.models.sim.dmaap.provider;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -242,14 +243,15 @@ public class DmaapSimProviderTest {
// use a real provider so we can test the real makeTimer() method
DmaapSimProvider prov2 = new DmaapSimProvider(params);
prov2.start();
- prov2.stop();
+ assertThatCode(() -> prov2.stop()).doesNotThrowAnyException();
}
@Test
public void testMakeTopicData() {
// use a real provider so we can test the real makeTopicData() method
DmaapSimProvider prov2 = new DmaapSimProvider(params);
- prov2.processDmaapMessageGet(TOPIC1, CONSUMER1, CONSUMER_ID1, 0, 0);
+ assertThatCode(() -> prov2.processDmaapMessageGet(TOPIC1, CONSUMER1, CONSUMER_ID1, 0, 0))
+ .doesNotThrowAnyException();
}
@Test
diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/MainTest.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/MainTest.java
index b8e285a99..7f4e4b116 100644
--- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/MainTest.java
+++ b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/sim/dmaap/startstop/MainTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
package org.onap.policy.sim.dmaap.startstop;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -88,7 +89,7 @@ public class MainTest {
@Test
public void testMain_Help() {
final String[] NormalParameters = {"-h"};
- Main.main(NormalParameters);
+ assertThatCode(() -> Main.main(NormalParameters)).doesNotThrowAnyException();
}
@Test