[infrastructure] move infered nullness warnings to error and update EEA (#8949)

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
J-N-K
2020-11-12 21:07:11 +01:00
committed by GitHub
parent 0856a0b3f2
commit ba4c96d99d
155 changed files with 644 additions and 632 deletions

View File

@@ -20,6 +20,7 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -95,7 +96,8 @@ public class FoobotApiConnector {
URLEncoder.encode(username, StandardCharsets.UTF_8.toString()));
logger.debug("URL = {}", url);
return GSON.fromJson(request(url, apiKey), FOOTBOT_DEVICE_LIST_TYPE);
List<FoobotDevice> foobotDevices = GSON.fromJson(request(url, apiKey), FOOTBOT_DEVICE_LIST_TYPE);
return Objects.requireNonNull(foobotDevices);
} catch (JsonParseException | UnsupportedEncodingException e) {
throw new FoobotApiException(0, e.getMessage());
}

View File

@@ -17,6 +17,7 @@ import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
@@ -53,6 +54,7 @@ public class FoobotDeviceHandlerTest {
final FoobotJsonData sensorData = connector.getSensorData("1234");
assertNotNull(sensorData, "No sensor data read");
Objects.requireNonNull(sensorData);
assertEquals(handler.sensorDataToState("temperature", sensorData), new QuantityType(12.345, SIUnits.CELSIUS));
assertEquals(handler.sensorDataToState("gpi", sensorData), new DecimalType(5.6789012));
}