Skip to content

Commit

Permalink
Address review comments from @holgerfriedrich to remove SAT warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
  • Loading branch information
austvik committed Apr 1, 2024
1 parent 2b18fb2 commit 254346e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@
import static org.openhab.binding.airgradient.internal.AirGradientBindingConstants.DEFAULT_POLL_INTERVAL_LOCAL;
import static org.openhab.binding.airgradient.internal.AirGradientBindingConstants.THING_TYPE_API;

import java.net.InetAddress;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

import javax.jmdns.ServiceInfo;

Expand Down Expand Up @@ -103,22 +99,6 @@ public String getServiceType() {
return discoveryResult;
}

private static <T> Iterable<T> getIterableFromIterator(Iterator<T> iterator) {
return () -> iterator;
}

private String toString(Enumeration<String> strs) {
return String.join(", ", getIterableFromIterator(strs.asIterator()));
}

private String toString(String strs[]) {
return String.join(", ", strs);
}

private String toString(InetAddress strs[]) {
return String.join(", ", Stream.of(strs).map((a) -> a.toString()).toList());
}

@Override
public @Nullable ThingUID getThingUID(ServiceInfo si) {
logger.debug("Getting thing ID for: App: {} Host: {} Name: {} Port: {} Serial: {}", si.getApplication(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public List<Measure> getMeasures() {
} else if (CONTENTTYPE_OPENMETRICS.equals(contentType)) {
return parsePrometheus(stringResponse);
}

} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, response.getContentAsString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@NonNullByDefault
public class AirGradientAPIHandlerTest {

private static final AirGradientAPIConfiguration config = new AirGradientAPIConfiguration() {
private static final AirGradientAPIConfiguration TEST_CONFIG = new AirGradientAPIConfiguration() {
{
hostname = "abc123";
token = "def456";
Expand Down Expand Up @@ -154,7 +154,7 @@ public void setUp() {
Configuration configuration = Mockito.mock(Configuration.class);

Mockito.when(bridge.getConfiguration()).thenReturn(requireNonNull(configuration));
Mockito.when(configuration.as(AirGradientAPIConfiguration.class)).thenReturn(config);
Mockito.when(configuration.as(AirGradientAPIConfiguration.class)).thenReturn(TEST_CONFIG);

sut = new AirGradientAPIHandler(requireNonNull(bridge), requireNonNull(httpClientMock));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@NonNullByDefault
public class AirGradientLocationHandlerTest {

private static final Measure measure = new Measure() {
private static final Measure TEST_MEASURE = new Measure() {
{
locationId = "12345";
locationName = "Location name";
Expand Down Expand Up @@ -82,7 +82,7 @@ public void setUp() {
@Test
public void testSetMeasure() {
sut.setCallback(callbackMock);
sut.setMeasurment("test123", measure);
sut.setMeasurment("test123", TEST_MEASURE);

verify(callbackMock).stateUpdated(new ChannelUID(sut.getThing().getUID(), CHANNEL_WIFI),
new QuantityType<>("-59 dBm"));
Expand Down

0 comments on commit 254346e

Please sign in to comment.