aboutsummaryrefslogtreecommitdiffstats
path: root/utils-test
diff options
context:
space:
mode:
authorwaynedunican <wayne.dunican@est.tech>2024-08-12 21:18:12 +0100
committerwaynedunican <wayne.dunican@est.tech>2024-08-13 09:21:16 +0100
commit63d23a4aa0f3aeae9d6470b95dfa8f87b2d85aa8 (patch)
tree74aa5c14f66dc5760eb00ea8f18c278174cbc56e /utils-test
parent34cad0af615db1ed4b85b8e4e1b77d0948289eed (diff)
Fix sonar issues in common
- SONAR Fix instanceOf issues - SONAR Remove public modifiers - SONAR Remove unused imports - SONAR Remove exceptions that can't be thrown from method body Issue-ID: POLICY-5106 Change-Id: I745d0101036d3421f02db22481514be0b79f5103 Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'utils-test')
-rw-r--r--utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java6
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/io/SerializerTest.java2
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/security/SelfSignedKeyStoreTest.java12
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeMultiTest.java12
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeTest.java4
-rw-r--r--utils-test/src/test/java/org/onap/policy/common/utils/time/WorkItemTest.java20
6 files changed, 28 insertions, 28 deletions
diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java b/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java
index 0787872c..1cc16263 100644
--- a/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java
+++ b/utils-test/src/main/java/org/onap/policy/common/utils/security/SelfSignedKeyStore.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +37,6 @@ import java.security.cert.CertificateException;
import java.util.Arrays;
import java.util.Date;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
import lombok.Getter;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.Extension;
@@ -77,7 +77,7 @@ public class SelfSignedKeyStore {
* @throws IOException if an I/O error occurs
* @throws InterruptedException if an interrupt occurs
*/
- public SelfSignedKeyStore() throws IOException, InterruptedException {
+ public SelfSignedKeyStore() throws IOException {
this(RELATIVE_PATH);
}
@@ -89,7 +89,7 @@ public class SelfSignedKeyStore {
* @throws IOException if an I/O error occurs
* @throws InterruptedException if an interrupt occurs
*/
- public SelfSignedKeyStore(String relativePath) throws IOException, InterruptedException {
+ public SelfSignedKeyStore(String relativePath) throws IOException {
keystoreName = System.getProperty("user.dir") + "/" + relativePath;
// use existing file if it isn't too old
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/io/SerializerTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/io/SerializerTest.java
index 25461daf..602df359 100644
--- a/utils-test/src/test/java/org/onap/policy/common/utils/io/SerializerTest.java
+++ b/utils-test/src/test/java/org/onap/policy/common/utils/io/SerializerTest.java
@@ -361,7 +361,7 @@ class SerializerTest {
@Test
void testRoundTrip() throws Exception {
- MyObject obj1 = new MyObject(3);
+ MyObject obj1 = new MyObject(4);
MyObject obj2 = Serializer.roundTrip(obj1);
assertEquals(obj1.value, obj2.value);
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/security/SelfSignedKeyStoreTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/security/SelfSignedKeyStoreTest.java
index 8a3dfe39..1af69cd0 100644
--- a/utils-test/src/test/java/org/onap/policy/common/utils/security/SelfSignedKeyStoreTest.java
+++ b/utils-test/src/test/java/org/onap/policy/common/utils/security/SelfSignedKeyStoreTest.java
@@ -57,7 +57,7 @@ public class SelfSignedKeyStoreTest {
}
@Test
- public void testSelfSignedKeyStore() throws Exception {
+ void testSelfSignedKeyStore() throws Exception {
SelfSignedKeyStore ks = new SelfSignedKeyStore();
assertThat(ks.getKeystoreName()).isEqualTo(defaultName);
@@ -65,7 +65,7 @@ public class SelfSignedKeyStoreTest {
}
@Test
- public void testSelfSignedKeyStoreString() throws IOException, InterruptedException {
+ void testSelfSignedKeyStoreString() throws IOException, InterruptedException {
String relName = "target/my-keystore";
String altName = saveUserDir + "/" + relName;
File altFile = new File(altName);
@@ -82,7 +82,7 @@ public class SelfSignedKeyStoreTest {
* Tests the constructor, when the keystore already exists.
*/
@Test
- public void testSelfSignedKeyStoreStringExists() throws Exception {
+ void testSelfSignedKeyStoreStringExists() throws Exception {
new SelfSignedKeyStore();
assertThat(defaultKeystore).exists();
@@ -109,7 +109,7 @@ public class SelfSignedKeyStoreTest {
* Tests the constructor, when the SAN file is not found.
*/
@Test
- public void testSelfSignedKeyStoreStringNoSanFile() {
+ void testSelfSignedKeyStoreStringNoSanFile() {
assertThatThrownBy(() -> new SelfSignedKeyStore() {
@Override
protected String getKeystoreSanName() {
@@ -122,13 +122,13 @@ public class SelfSignedKeyStoreTest {
* Tests the constructor, when write fails.
*/
@Test
- public void testSelfSignedKeyStoreStringWriteFailure() {
+ void testSelfSignedKeyStoreStringWriteFailure() {
assertThatThrownBy(() -> new SelfSignedKeyStore("target/unknown/path/to/keystore"))
.isInstanceOf(IOException.class);
}
@Test
- public void testGetKeystoreName() throws Exception {
+ void testGetKeystoreName() throws Exception {
String relpath = SelfSignedKeyStore.RELATIVE_PATH;
// append the first part of the relative path to user.dir
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeMultiTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeMultiTest.java
index f6d1e6a4..1b9728d4 100644
--- a/utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeMultiTest.java
+++ b/utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeMultiTest.java
@@ -115,7 +115,7 @@ class TestTimeMultiTest {
}
@Test
- void testDestroy() throws InterruptedException {
+ void testDestroy() {
// this won't interrupt
multi.enqueue(new WorkItem(multi, DELAY_MS));
@@ -193,7 +193,7 @@ class TestTimeMultiTest {
}
@Test
- void testWaitUntilCallable() throws InterruptedException {
+ void testWaitUntilCallable() {
multi.enqueue(new WorkItem(multi, DELAY_MS));
multi.enqueue(new WorkItem(multi, DELAY_MS * 2));
multi.enqueue(new WorkItem(multi, DELAY_MS * 3));
@@ -238,7 +238,7 @@ class TestTimeMultiTest {
}
@Test
- void testWaitUntilCallable_ConditionThrowsEx() throws InterruptedException {
+ void testWaitUntilCallable_ConditionThrowsEx() {
multi = new TestTimeMulti();
Callable<Boolean> callable = () -> {
@@ -253,7 +253,7 @@ class TestTimeMultiTest {
}
@Test
- void testWaitUntilCallable_NeverSatisfied() throws InterruptedException {
+ void testWaitUntilCallable_NeverSatisfied() {
multi = new TestTimeMulti(SHORT_WAIT_MS);
final long realBegin = System.currentTimeMillis();
@@ -263,7 +263,7 @@ class TestTimeMultiTest {
}
@Test
- void testWaitUntilLongTimeUnitCallable() throws InterruptedException {
+ void testWaitUntilLongTimeUnitCallable() {
multi.enqueue(new WorkItem(multi, DELAY_MS));
multi.enqueue(new WorkItem(multi, DELAY_MS * 2));
multi.enqueue(new WorkItem(multi, DELAY_MS * 3));
@@ -280,7 +280,7 @@ class TestTimeMultiTest {
}
@Test
- void testWaitUntilLongTimeUnitCallable_PseudoTimeExpires() throws InterruptedException {
+ void testWaitUntilLongTimeUnitCallable_PseudoTimeExpires() {
multi.enqueue(new WorkItem(multi, DELAY_MS));
multi.enqueue(new WorkItem(multi, DELAY_MS * 2));
multi.enqueue(new WorkItem(multi, DELAY_MS * 3));
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeTest.java
index c3b69eb3..dbf077c5 100644
--- a/utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeTest.java
+++ b/utils-test/src/test/java/org/onap/policy/common/utils/time/TestTimeTest.java
@@ -26,10 +26,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
-public class TestTimeTest {
+class TestTimeTest {
@Test
- public void test() throws Exception {
+ void test() throws Exception {
TestTime tm = new TestTime();
TestTime tm2 = new TestTime();
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/time/WorkItemTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/time/WorkItemTest.java
index f0229ca9..a5683a64 100644
--- a/utils-test/src/test/java/org/onap/policy/common/utils/time/WorkItemTest.java
+++ b/utils-test/src/test/java/org/onap/policy/common/utils/time/WorkItemTest.java
@@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-public class WorkItemTest {
+class WorkItemTest {
private TestTime currentTime;
private WorkItem item;
@@ -40,7 +40,7 @@ public class WorkItemTest {
}
@Test
- public void testWorkItem() {
+ void testWorkItem() {
assertThatIllegalArgumentException().isThrownBy(() -> new WorkItem(currentTime, -1));
// should not throw an exception
@@ -48,22 +48,22 @@ public class WorkItemTest {
}
@Test
- public void testGetDelay() {
+ void testGetDelay() {
assertEquals(1, item.getDelay());
}
@Test
- public void testWasCancelled() {
+ void testWasCancelled() {
assertFalse(item.wasCancelled());
}
@Test
- public void testBumpNextTime() {
+ void testBumpNextTime() {
assertFalse(item.bumpNextTime());
}
@Test
- public void testBumpNextTimeLong() {
+ void testBumpNextTimeLong() {
assertThatIllegalArgumentException().isThrownBy(() -> item.bumpNextTime(-1));
long cur = currentTime.getMillis();
@@ -77,24 +77,24 @@ public class WorkItemTest {
}
@Test
- public void testInterrupt() {
+ void testInterrupt() {
item.interrupt();
assertFalse(Thread.interrupted());
}
@Test
- public void testIsAssociatedWith() {
+ void testIsAssociatedWith() {
assertFalse(item.isAssociatedWith(this));
}
@Test
- public void testFire() {
+ void testFire() {
// ensure no exception is thrown
assertThatCode(() -> item.fire()).doesNotThrowAnyException();
}
@Test
- public void testGetNextMs() {
+ void testGetNextMs() {
assertEquals(currentTime.getMillis() + 1, item.getNextMs());
assertEquals(currentTime.getMillis() + 10, new WorkItem(currentTime, 10).getNextMs());
}