From: guillaume.lambert Date: Wed, 6 May 2020 15:06:51 +0000 (+0200) Subject: Enforce Spotbugs in test-common module X-Git-Tag: 1.2.0~103 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=57e72c9a6325ccead6c9387fd0ba1bca668f8c60;p=transportpce.git Enforce Spotbugs in test-common module by fixing remaining SpotBugs issues JIRA: TRNSPRTPCE-216 TRNSPRTPCE-248 TRNSPRTPCE-265 Signed-off-by: guillaume.lambert Change-Id: Ie2e8493a3c2d2acd29a782cabaf037e99c7fd28d --- diff --git a/test-common/pom.xml b/test-common/pom.xml index 2c16475a2..f636a90ae 100644 --- a/test-common/pom.xml +++ b/test-common/pom.xml @@ -36,10 +36,4 @@ - - - - false - - diff --git a/test-common/src/main/java/org/opendaylight/transportpce/test/AbstractDeviceTest.java b/test-common/src/main/java/org/opendaylight/transportpce/test/AbstractDeviceTest.java index 3321a7f3e..ccb2546c9 100644 --- a/test-common/src/main/java/org/opendaylight/transportpce/test/AbstractDeviceTest.java +++ b/test-common/src/main/java/org/opendaylight/transportpce/test/AbstractDeviceTest.java @@ -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<>()); } /** diff --git a/test-common/src/main/java/org/opendaylight/transportpce/test/DeviceWrapper.java b/test-common/src/main/java/org/opendaylight/transportpce/test/DeviceWrapper.java index 2c07cad3a..fa1fd7c32 100644 --- a/test-common/src/main/java/org/opendaylight/transportpce/test/DeviceWrapper.java +++ b/test-common/src/main/java/org/opendaylight/transportpce/test/DeviceWrapper.java @@ -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(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); } }