diff options
author | Jim Hahn <jrh3@att.com> | 2019-06-12 14:32:25 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-06-12 17:36:59 -0400 |
commit | ea262e6da52fd4da0733f02998f87aebaf502ddb (patch) | |
tree | a7cded567521f0141f31d9f8c185eccdaf2a8979 /utils-test/src/test/java/org/onap/policy/common/utils/io/SerializerTest.java | |
parent | e671e9fa5d09ec696cb24aeefaf10ddbc7c705d7 (diff) |
Apply simple sonar fixes
Note: A number of these were identified, by SonarLint, in the Test
classes, which are not typically scanned by Sonar.
Removed unnecessary imports.
Removed unneeded "throws Xxx".
Replaced lambda with method references.
Replaced duplicate strings with constants.
Replaced try-fail-catch with assert-j methods to eliminate sonar
complaints about duplicate failure messages.
Added missing @Override annotations.
Use map.computeIfAbsent() where appropriate.
Also fixed some minor checkstyle issues.
Removed unneeded "volatile" declarations.
Replaced some if-else constructs with "?:" construct, per sonar.
Replaced Object.wait() with CountDownLatch.await(); according to sonar
(and javadocs), Object.wait() can return due to "spurious wakeups".
Fixed issue whereby CryptoUtilsTest wouldn't run in my Eclipse.
Change-Id: Ib6b71ed65662cfd6209400dac57ed69279bf29ec
Issue-ID: POLICY-1791
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'utils-test/src/test/java/org/onap/policy/common/utils/io/SerializerTest.java')
-rw-r--r-- | utils-test/src/test/java/org/onap/policy/common/utils/io/SerializerTest.java | 15 |
1 files changed, 8 insertions, 7 deletions
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 ee66195c..95abd4db 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 @@ -44,6 +44,7 @@ import org.onap.policy.common.utils.io.Serializer.Factory; import org.powermock.reflect.Whitebox; public class SerializerTest { + private static final String FACTORY = "factory"; /** * Saved and restored when tests complete. Also restored at the start of each test. @@ -52,12 +53,12 @@ public class SerializerTest { @BeforeClass public static void setUpBeforeClass() { - saveFactory = Whitebox.getInternalState(Serializer.class, "factory"); + saveFactory = Whitebox.getInternalState(Serializer.class, FACTORY); } @AfterClass public static void tearDownAfterClass() { - Whitebox.setInternalState(Serializer.class, "factory", saveFactory); + Whitebox.setInternalState(Serializer.class, FACTORY, saveFactory); } @Before @@ -89,7 +90,7 @@ public class SerializerTest { } @Test - public void testSerialize_ArrayCloseEx() throws Exception { + public void testSerialize_ArrayCloseEx() { IOException ex = new IOException("testSerialize_ArrayCloseEx"); /* @@ -123,7 +124,7 @@ public class SerializerTest { } @Test - public void testSerialize_ObjectWriteEx() throws Exception { + public void testSerialize_ObjectWriteEx() { IOException ex = new IOException("testSerialize_ObjectWriteEx"); /* @@ -158,7 +159,7 @@ public class SerializerTest { @Override public void writeObject(Object object, ObjectOutputStream oos) throws IOException { - return; + // do nothing } }); @@ -205,7 +206,7 @@ public class SerializerTest { @Override public void writeObject(Object object, ObjectOutputStream oos) throws IOException { - return; + // do nothing } }); @@ -370,7 +371,7 @@ public class SerializerTest { * @param factory new factory to be set */ private void setFactory(Factory factory) { - Whitebox.setInternalState(Serializer.class, "factory", factory); + Whitebox.setInternalState(Serializer.class, FACTORY, factory); } /** |