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:
@@ -36,7 +36,6 @@ import com.google.gson.JsonParser;
|
||||
public class TradfriCoapHandler implements CoapHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(TradfriCoapHandler.class);
|
||||
private final JsonParser parser = new JsonParser();
|
||||
|
||||
private @Nullable CoapCallback callback;
|
||||
private @Nullable CompletableFuture<String> future;
|
||||
@@ -70,7 +69,7 @@ public class TradfriCoapHandler implements CoapHandler {
|
||||
final CoapCallback callback = this.callback;
|
||||
if (callback != null) {
|
||||
try {
|
||||
callback.onUpdate(parser.parse(response.getResponseText()));
|
||||
callback.onUpdate(JsonParser.parseString(response.getResponseText()));
|
||||
callback.setStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
|
||||
} catch (JsonParseException e) {
|
||||
logger.warn("Observed value is no valid json: {}, {}", response.getResponseText(), e.getMessage());
|
||||
|
||||
@@ -17,7 +17,11 @@ import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -211,7 +215,7 @@ public class TradfriGatewayHandler extends BaseBridgeHandler implements CoapCall
|
||||
|
||||
if (gatewayResponse.isSuccess()) {
|
||||
responseText = gatewayResponse.getResponseText();
|
||||
json = new JsonParser().parse(responseText).getAsJsonObject();
|
||||
json = JsonParser.parseString(responseText).getAsJsonObject();
|
||||
preSharedKey = json.get(NEW_PSK_BY_GW).getAsString();
|
||||
|
||||
if (isNullOrEmpty(preSharedKey)) {
|
||||
@@ -323,7 +327,7 @@ public class TradfriGatewayHandler extends BaseBridgeHandler implements CoapCall
|
||||
deviceClient.setURI(gatewayInfoURI);
|
||||
deviceClient.asyncGet().thenAccept(data -> {
|
||||
logger.debug("requestGatewayInfo response: {}", data);
|
||||
JsonObject json = new JsonParser().parse(data).getAsJsonObject();
|
||||
JsonObject json = JsonParser.parseString(data).getAsJsonObject();
|
||||
String firmwareVersion = json.get(VERSION).getAsString();
|
||||
getThing().setProperty(Thing.PROPERTY_FIRMWARE_VERSION, firmwareVersion);
|
||||
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
|
||||
@@ -337,7 +341,7 @@ public class TradfriGatewayHandler extends BaseBridgeHandler implements CoapCall
|
||||
deviceClient.setURI(gatewayURI + "/" + instanceId);
|
||||
deviceClient.asyncGet().thenAccept(data -> {
|
||||
logger.debug("requestDeviceDetails response: {}", data);
|
||||
JsonObject json = new JsonParser().parse(data).getAsJsonObject();
|
||||
JsonObject json = JsonParser.parseString(data).getAsJsonObject();
|
||||
deviceUpdateListeners.forEach(listener -> listener.onUpdate(instanceId, json));
|
||||
});
|
||||
// restore root URI
|
||||
|
||||
@@ -107,7 +107,7 @@ public class TradfriDiscoveryServiceTest {
|
||||
@Test
|
||||
public void validDiscoveryResultWhiteLightW() {
|
||||
String json = "{\"9001\":\"TRADFRI bulb E27 W opal 1000lm\",\"9002\":1492856270,\"9020\":1507194357,\"9003\":65537,\"3311\":[{\"5850\":1,\"5851\":254,\"9003\":0}],\"9054\":0,\"5750\":2,\"9019\":1,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI bulb E27 W opal 1000lm\",\"2\":\"\",\"3\":\"1.2.214\",\"6\":1}}";
|
||||
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
|
||||
JsonObject data = JsonParser.parseString(json).getAsJsonObject();
|
||||
|
||||
discovery.onUpdate("65537", data);
|
||||
|
||||
@@ -123,7 +123,7 @@ public class TradfriDiscoveryServiceTest {
|
||||
@Test
|
||||
public void validDiscoveryResultWhiteLightWS() {
|
||||
String json = "{\"9001\":\"TRADFRI bulb E27 WS opal 980lm\",\"9002\":1492955148,\"9020\":1507200447,\"9003\":65537,\"3311\":[{\"5710\":26909,\"5850\":1,\"5851\":203,\"5707\":0,\"5708\":0,\"5709\":30140,\"5711\":370,\"5706\":\"f1e0b5\",\"9003\":0}],\"9054\":0,\"5750\":2,\"9019\":1,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI bulb E27 WS opal 980lm\",\"2\":\"\",\"3\":\"1.2.217\",\"6\":1}}";
|
||||
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
|
||||
JsonObject data = JsonParser.parseString(json).getAsJsonObject();
|
||||
|
||||
discovery.onUpdate("65537", data);
|
||||
|
||||
@@ -141,7 +141,7 @@ public class TradfriDiscoveryServiceTest {
|
||||
// We do not always receive a COLOR = "5706" attribute, even the light supports it - but the gateway does not
|
||||
// seem to have this information, if the bulb is unreachable.
|
||||
String json = "{\"9001\":\"TRADFRI bulb E27 WS opal 980lm\",\"9002\":1492955148,\"9020\":1506968670,\"9003\":65537,\"3311\":[{\"9003\":0}],\"9054\":0,\"5750\":2,\"9019\":0,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI bulb E27 WS opal 980lm\",\"2\":\"\",\"3\":\"1.2.217\",\"6\":1}}";
|
||||
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
|
||||
JsonObject data = JsonParser.parseString(json).getAsJsonObject();
|
||||
|
||||
discovery.onUpdate("65537", data);
|
||||
|
||||
@@ -157,7 +157,7 @@ public class TradfriDiscoveryServiceTest {
|
||||
@Test
|
||||
public void validDiscoveryResultColorLightCWS() {
|
||||
String json = "{\"9001\":\"TRADFRI bulb E27 CWS opal 600lm\",\"9002\":1505151864,\"9020\":1505433527,\"9003\":65550,\"9019\":1,\"9054\":0,\"5750\":2,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI bulb E27 CWS opal 600lm\",\"2\":\"\",\"3\":\"1.3.002\",\"6\":1},\"3311\":[{\"5850\":1,\"5708\":0,\"5851\":254,\"5707\":0,\"5709\":33137,\"5710\":27211,\"5711\":0,\"5706\":\"efd275\",\"9003\":0}]}";
|
||||
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
|
||||
JsonObject data = JsonParser.parseString(json).getAsJsonObject();
|
||||
|
||||
discovery.onUpdate("65550", data);
|
||||
|
||||
@@ -173,7 +173,7 @@ public class TradfriDiscoveryServiceTest {
|
||||
@Test
|
||||
public void validDiscoveryResultAlternativeColorLightCWS() {
|
||||
String json = "{\"3311\":[{\"5850\":1,\"5709\":32886,\"5851\":216,\"5707\":5309,\"5708\":52400,\"5710\":27217,\"5706\":\"efd275\",\"9003\":0}],\"9001\":\"Mushroom lamp\",\"9002\":1571036916,\"9020\":1571588312,\"9003\":65539,\"9054\":0,\"9019\":1,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI bulb E27 C\\/WS opal 600\",\"2\":\"\",\"3\":\"1.3.009\",\"6\":1},\"5750\":2}";
|
||||
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
|
||||
JsonObject data = JsonParser.parseString(json).getAsJsonObject();
|
||||
|
||||
discovery.onUpdate("65539", data);
|
||||
|
||||
@@ -189,7 +189,7 @@ public class TradfriDiscoveryServiceTest {
|
||||
@Test
|
||||
public void validDiscoveryResultRemoteControl() {
|
||||
String json = "{\"9001\":\"TRADFRI remote control\",\"9002\":1492843083,\"9020\":1506977986,\"9003\":65536,\"9054\":0,\"5750\":0,\"9019\":1,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI remote control\",\"2\":\"\",\"3\":\"1.2.214\",\"6\":3,\"9\":47},\"15009\":[{\"9003\":0}]}";
|
||||
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
|
||||
JsonObject data = JsonParser.parseString(json).getAsJsonObject();
|
||||
|
||||
discovery.onUpdate("65536", data);
|
||||
|
||||
@@ -205,7 +205,7 @@ public class TradfriDiscoveryServiceTest {
|
||||
@Test
|
||||
public void validDiscoveryResultWirelessDimmer() {
|
||||
String json = "{\"9001\":\"TRADFRI wireless dimmer\",\"9002\":1492843083,\"9020\":1506977986,\"9003\":65536,\"9054\":0,\"5750\":0,\"9019\":1,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI wireless dimmer\",\"2\":\"\",\"3\":\"1.2.214\",\"6\":3,\"9\":47},\"15009\":[{\"9003\":0}]}";
|
||||
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
|
||||
JsonObject data = JsonParser.parseString(json).getAsJsonObject();
|
||||
|
||||
discovery.onUpdate("65536", data);
|
||||
|
||||
@@ -221,7 +221,7 @@ public class TradfriDiscoveryServiceTest {
|
||||
@Test
|
||||
public void validDiscoveryResultMotionSensor() {
|
||||
String json = "{\"9001\":\"TRADFRI motion sensor\",\"9002\":1492955083,\"9020\":1507120083,\"9003\":65538,\"9054\":0,\"5750\":4,\"9019\":1,\"3\":{\"0\":\"IKEA of Sweden\",\"1\":\"TRADFRI motion sensor\",\"2\":\"\",\"3\":\"1.2.214\",\"6\":3,\"9\":60},\"3300\":[{\"9003\":0}]}";
|
||||
JsonObject data = new JsonParser().parse(json).getAsJsonObject();
|
||||
JsonObject data = JsonParser.parseString(json).getAsJsonObject();
|
||||
|
||||
discovery.onUpdate("65538", data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user