mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Fixed JsonParser deprecations (#2320)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
+5
-7
@@ -54,7 +54,6 @@ import org.openhab.core.library.items.DimmerItem;
|
||||
import org.openhab.core.library.items.StringItem;
|
||||
import org.openhab.core.library.items.SwitchItem;
|
||||
import org.openhab.core.test.java.JavaOSGiTest;
|
||||
import org.openhab.core.test.storage.VolatileStorageService;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
@@ -88,13 +87,13 @@ public class ItemResourceOSGiTest extends JavaOSGiTest {
|
||||
|
||||
@BeforeEach
|
||||
public void beforeEach() {
|
||||
registerService(new VolatileStorageService());
|
||||
registerVolatileStorageService();
|
||||
|
||||
itemResource = getService(RESTResource.class, ItemResource.class);
|
||||
assertNotNull(itemResource);
|
||||
|
||||
registerVolatileStorageService();
|
||||
managedItemProvider = getService(ManagedItemProvider.class);
|
||||
assertNotNull(managedItemProvider);
|
||||
|
||||
item1 = new SwitchItem(ITEM_NAME1);
|
||||
item2 = new SwitchItem(ITEM_NAME2);
|
||||
@@ -177,14 +176,13 @@ public class ItemResourceOSGiTest extends JavaOSGiTest {
|
||||
|
||||
@Test
|
||||
public void shouldIncludeRequestedFieldsOnly() throws Exception {
|
||||
JsonParser parser = new JsonParser();
|
||||
managedItemProvider.add(new SwitchItem("Switch"));
|
||||
itemResource.addTag("Switch", "MyTag");
|
||||
Response response = itemResource.getItems(uriInfo, httpHeaders, null, null, "MyTag", null, false, "type,name");
|
||||
|
||||
JsonElement result = parser
|
||||
.parse(new String(((InputStream) response.getEntity()).readAllBytes(), StandardCharsets.UTF_8));
|
||||
JsonElement expected = parser.parse("[{type: \"Switch\", name: \"Switch\"}]");
|
||||
JsonElement result = JsonParser
|
||||
.parseString(new String(((InputStream) response.getEntity()).readAllBytes(), StandardCharsets.UTF_8));
|
||||
JsonElement expected = JsonParser.parseString("[{type: \"Switch\", name: \"Switch\"}]");
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user