Resolve itest runbundles for Gson and Commons Lang upgrades and fix JsonParser deprecations (#10345)
* Resolve itest runbundles for Gson and Commons Lang upgrades * Fix JsonParser deprecations too * Fix feature verification Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -41,12 +41,10 @@ import com.google.gson.JsonSyntaxException;
|
||||
public final class RequestLogger {
|
||||
private final Logger logger = LoggerFactory.getLogger(RequestLogger.class);
|
||||
private final AtomicLong nextId = new AtomicLong();
|
||||
private final JsonParser parser;
|
||||
private final Gson gson;
|
||||
private final String prefix;
|
||||
|
||||
public RequestLogger(final String prefix, final Gson gson) {
|
||||
parser = new JsonParser();
|
||||
this.gson = gson;
|
||||
this.prefix = prefix;
|
||||
}
|
||||
@@ -133,7 +131,7 @@ public final class RequestLogger {
|
||||
|
||||
private String reformatJson(final String jsonString) {
|
||||
try {
|
||||
final JsonElement json = parser.parse(jsonString);
|
||||
final JsonElement json = JsonParser.parseString(jsonString);
|
||||
return gson.toJson(json);
|
||||
} catch (final JsonSyntaxException e) {
|
||||
logger.debug("Could not reformat malformed JSON due to '{}'", e.getMessage());
|
||||
|
||||
@@ -85,7 +85,6 @@ public class SensiboAccountHandler extends BaseBridgeHandler {
|
||||
public static String API_ENDPOINT = "https://home.sensibo.com/api";
|
||||
private final Logger logger = LoggerFactory.getLogger(SensiboAccountHandler.class);
|
||||
private final HttpClient httpClient;
|
||||
private final JsonParser jsonParser = new JsonParser();
|
||||
private final RequestLogger requestLogger;
|
||||
private final Gson gson;
|
||||
private SensiboModel model = new SensiboModel(0);
|
||||
@@ -207,7 +206,7 @@ public class SensiboAccountHandler extends BaseBridgeHandler {
|
||||
final ContentResponse contentResponse = request.send();
|
||||
final String responseJson = contentResponse.getContentAsString();
|
||||
if (contentResponse.getStatus() == HttpStatus.OK_200) {
|
||||
final JsonObject o = jsonParser.parse(responseJson).getAsJsonObject();
|
||||
final JsonObject o = JsonParser.parseString(responseJson).getAsJsonObject();
|
||||
final String overallStatus = o.get("status").getAsString();
|
||||
if ("success".equals(overallStatus)) {
|
||||
return gson.fromJson(o.get("result"), responseType);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.sensibo.internal;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
@@ -54,8 +54,7 @@ public class WireHelper {
|
||||
final String json = new String(WireHelper.class.getResourceAsStream(jsonClasspathName).readAllBytes(),
|
||||
StandardCharsets.UTF_8);
|
||||
|
||||
final JsonParser parser = new JsonParser();
|
||||
final JsonObject o = parser.parse(json).getAsJsonObject();
|
||||
final JsonObject o = JsonParser.parseString(json).getAsJsonObject();
|
||||
assertEquals("success", o.get("status").getAsString());
|
||||
|
||||
return gson.fromJson(o.get("result"), type);
|
||||
|
||||
Reference in New Issue
Block a user