forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openhab#62 Correctly check if long poll response is valid
GSON will not return null if there is no "result" field, but will just set the "result" member to null. Signed-off-by: Christian Oeing <christian.oeing@slashgames.org>
- Loading branch information
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...est/java/org/openhab/binding/boschshc/internal/devices/bridge/dto/LongPollResultTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.boschshc.internal.devices.bridge.dto; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.google.gson.Gson; | ||
|
||
/** | ||
* Unit tests for LongPollResult | ||
* | ||
* @author Christian Oeing - Initial contribution | ||
*/ | ||
public class LongPollResultTest { | ||
private final Gson gson = new Gson(); | ||
|
||
@Test | ||
public void NoResultsForErrorResult() { | ||
LongPollResult longPollResult = gson.fromJson( | ||
"{\"jsonrpc\":\"2.0\", \"error\": { \"code\":-32001, \"message\":\"No subscription with id: e8fei62b0-0\" } }", | ||
LongPollResult.class); | ||
assertEquals(null, longPollResult.result); | ||
} | ||
} |