summaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2023-09-28 14:25:43 +0100
committeradheli.tavares <adheli.tavares@est.tech>2023-09-29 10:30:58 +0100
commitcf36274c5ae0bc569ec7ebe2cb4e8f579763cc14 (patch)
treec9a9403714185944ca9ad0f93cd1478072b748b2 /policy-endpoints/src/test
parent349b4ae7179173f9261d9a432094cb55dc433820 (diff)
Fix security vulnerabilities
- iq nexus vulnerabilities - sonar security hotspots and code smell Issue-ID: POLICY-4761 Issue-ID: POLICY-4833 Change-Id: Iab2e07d2ee7b90031bc5a30210ce7d3f5a47b3fd Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'policy-endpoints/src/test')
-rw-r--r--policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
index 94e7c0c7..86b32e69 100644
--- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
+++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java
@@ -26,6 +26,7 @@ import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -66,7 +67,7 @@ public class BusConsumerTest extends TopicTestBase {
}
@Test
- public void testFetchingBusConsumer() throws InterruptedException {
+ public void testFetchingBusConsumer() {
// should not be negative
var cons = new FetchingBusConsumerImpl(makeBuilder().fetchTimeout(-1).build());
assertThat(cons.getSleepTime()).isEqualTo(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH);
@@ -174,7 +175,7 @@ public class BusConsumerTest extends TopicTestBase {
@Test
public void testCambriaConsumerWrapperClose() {
CambriaConsumerWrapper cons = new CambriaConsumerWrapper(builder.build());
- assertThatCode(() -> cons.close()).doesNotThrowAnyException();
+ assertThatCode(cons::close).doesNotThrowAnyException();
}
@Test
@@ -183,7 +184,7 @@ public class BusConsumerTest extends TopicTestBase {
}
@Test
- public void testDmaapConsumerWrapper() throws Exception {
+ public void testDmaapConsumerWrapper() {
// verify that different wrappers can be built
assertThatCode(() -> new DmaapAafConsumerWrapper(makeBuilder().build())).doesNotThrowAnyException();
}
@@ -229,7 +230,7 @@ public class BusConsumerTest extends TopicTestBase {
}
@Test
- public void testDmaapConsumerWrapperClose() throws Exception {
+ public void testDmaapConsumerWrapperClose() {
assertThatCode(() -> new DmaapAafConsumerWrapper(makeBuilder().build()).close()).doesNotThrowAnyException();
}
@@ -301,18 +302,18 @@ public class BusConsumerTest extends TopicTestBase {
}
@Test
- public void testKafkaConsumerWrapper() throws Exception {
+ public void testKafkaConsumerWrapper() {
// verify that different wrappers can be built
assertThatCode(() -> new KafkaConsumerWrapper(makeKafkaBuilder().build())).doesNotThrowAnyException();
}
@Test(expected = IllegalArgumentException.class)
- public void testKafkaConsumerWrapper_InvalidTopic() throws Exception {
+ public void testKafkaConsumerWrapper_InvalidTopic() {
new KafkaConsumerWrapper(makeBuilder().topic(null).build());
}
- @Test(expected = java.lang.IllegalStateException.class)
- public void testKafkaConsumerWrapperFetch() throws Exception {
+ @Test
+ public void testKafkaConsumerWrapperFetch() {
//Setup Properties for consumer
Properties kafkaProps = new Properties();
@@ -331,17 +332,17 @@ public class BusConsumerTest extends TopicTestBase {
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(kafkaProps);
kafka.consumer = consumer;
- assertFalse(kafka.fetch().iterator().hasNext());
+ assertThrows(java.lang.IllegalStateException.class, () -> kafka.fetch().iterator().hasNext());
consumer.close();
}
@Test
- public void testKafkaConsumerWrapperClose() throws Exception {
+ public void testKafkaConsumerWrapperClose() {
assertThatCode(() -> new KafkaConsumerWrapper(makeKafkaBuilder().build()).close()).doesNotThrowAnyException();
}
@Test
- public void testKafkaConsumerWrapperToString() throws Exception {
+ public void testKafkaConsumerWrapperToString() {
assertNotNull(new KafkaConsumerWrapper(makeKafkaBuilder().build()) {}.toString());
}
@@ -352,7 +353,7 @@ public class BusConsumerTest extends TopicTestBase {
}
@Override
- public Iterable<String> fetch() throws IOException {
+ public Iterable<String> fetch() {
return null;
}
}