Enforce Spotbugs in test-common module 95/91095/1
authorguillaume.lambert <guillaume.lambert@orange.com>
Wed, 6 May 2020 15:06:51 +0000 (17:06 +0200)
committerGilles Thouenon <gilles.thouenon@orange.com>
Fri, 10 Jul 2020 12:40:57 +0000 (14:40 +0200)
by fixing remaining SpotBugs issues

JIRA: TRNSPRTPCE-216 TRNSPRTPCE-248 TRNSPRTPCE-265
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: Ie2e8493a3c2d2acd29a782cabaf037e99c7fd28d

test-common/pom.xml
test-common/src/main/java/org/opendaylight/transportpce/test/AbstractDeviceTest.java
test-common/src/main/java/org/opendaylight/transportpce/test/DeviceWrapper.java

index 2c16475a291d0219197ee9da13c8acc4cb2410cd..f636a90aea88e45d783987e86d78862566f2163f 100644 (file)
         </dependency>
     </dependencies>
 
-<!-- checkstyle and spotbugds enforced by odlparent since Magnesium -->
-  <properties>
-    <!-- odlparent.checkstyle.enforce>false</odlparent.checkstyle.enforce -->
-    <odlparent.spotbugs.enforce>false</odlparent.spotbugs.enforce>
-  </properties>
-
 </project>
index 3321a7f3e95163c24dc35fc49d175e81fd812543..ccb2546c9c3c33d6bc0733174489228f27f2ade9 100644 (file)
@@ -9,9 +9,9 @@ package org.opendaylight.transportpce.test;
 
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
 import java.io.InputStream;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -33,7 +33,7 @@ public abstract class AbstractDeviceTest {
      * {@link AbstractDeviceTest#internalStorage} as asynchronized {@link Map}.
      */
     public AbstractDeviceTest() {
-        this.internalStorage = Collections.synchronizedMap(Maps.newHashMap());
+        this.internalStorage = Collections.synchronizedMap(new HashMap<>());
     }
 
     /**
index 2c07cad3a78731540916c3603f5be56373c62e07..fa1fd7c326fca022dd2643eeb3525b93b26d90b1 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.transportpce.test;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
@@ -71,7 +73,7 @@ public final class DeviceWrapper {
      *
      * @return the domDataBroker
      */
-    public DOMDataBroker getDomDataBroker() {
+    public DOMDataBroker getDeviceDomDataBroker() {
         return domDataBroker;
     }
 
@@ -95,8 +97,8 @@ public final class DeviceWrapper {
      */
     public static DeviceWrapper createDeviceWrapper(@Nonnull String key, @Nonnull InputStream initialDataXmlInputStream,
             @Nonnull QName intialDataQName) {
-        Preconditions.checkNotNull(initialDataXmlInputStream, "Input stream cannot be null");
-        Preconditions.checkNotNull(intialDataQName, "QName cannot be null");
+        requireNonNull(initialDataXmlInputStream, "Input stream cannot be null");
+        requireNonNull(intialDataQName, "QName cannot be null");
         return createDeviceWrapper(key, Lists.newArrayList(
                 new AbstractMap.SimpleEntry<QName, InputStream>(intialDataQName, initialDataXmlInputStream)));
     }
@@ -143,7 +145,7 @@ public final class DeviceWrapper {
         try {
             writeOnlyTransaction.commit().get();
         } catch (InterruptedException | ExecutionException e) {
-            LOG.error("This should be not reached {}", e.getMessage(), e);
+            LOG.error("This should be not reached ", e);
             throw new IllegalStateException(e);
         }
     }