-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1583 from LuxoftSDL/feature/0255_enchance_body_in…
…formation [0255] Enchance body information
- Loading branch information
Showing
12 changed files
with
1,140 additions
and
7 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
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
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
65 changes: 65 additions & 0 deletions
65
..._android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DoorStatusTests.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,65 @@ | ||
package com.smartdevicelink.test.rpc.datatypes; | ||
|
||
import com.smartdevicelink.marshal.JsonRPCMarshaller; | ||
import com.smartdevicelink.proxy.rpc.DoorStatus; | ||
import com.smartdevicelink.proxy.rpc.Grid; | ||
import com.smartdevicelink.proxy.rpc.RoofStatus; | ||
import com.smartdevicelink.proxy.rpc.enums.DoorStatusType; | ||
import com.smartdevicelink.test.JsonUtils; | ||
import com.smartdevicelink.test.TestValues; | ||
import com.smartdevicelink.test.Validator; | ||
|
||
import junit.framework.TestCase; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.Hashtable; | ||
import java.util.Iterator; | ||
|
||
public class DoorStatusTests extends TestCase { | ||
private DoorStatus msg; | ||
|
||
@Override | ||
public void setUp() { | ||
msg = new DoorStatus(TestValues.GENERAL_GRID, TestValues.GENERAL_DOOR_STATUS_TYPE); | ||
} | ||
|
||
public void testRpcValues() { | ||
// Test Values | ||
Grid location = msg.getLocation(); | ||
DoorStatusType status = msg.getStatus(); | ||
|
||
// Valid Tests | ||
assertEquals(TestValues.MATCH, TestValues.GENERAL_GRID, location); | ||
assertEquals(TestValues.MATCH, TestValues.GENERAL_DOOR_STATUS_TYPE, status); | ||
} | ||
|
||
public void testJson() { | ||
JSONObject reference = new JSONObject(); | ||
|
||
try { | ||
reference.put(RoofStatus.KEY_STATUS, TestValues.GENERAL_DOOR_STATUS_TYPE); | ||
reference.put(RoofStatus.KEY_LOCATION, TestValues.JSON_GRID); | ||
|
||
JSONObject underTest = msg.serializeJSON(); | ||
assertEquals(TestValues.MATCH, reference.length(), underTest.length()); | ||
|
||
Iterator<?> iterator = reference.keys(); | ||
while (iterator.hasNext()) { | ||
String key = (String) iterator.next(); | ||
if (key.equals(RoofStatus.KEY_LOCATION)) { | ||
Hashtable<String, Object> hs1 = JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(reference, key)); | ||
Hashtable<String, Object> hs2 = JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key)); | ||
|
||
assertTrue(Validator.validateGrid(new Grid(hs1), new Grid(hs2))); | ||
|
||
} else { | ||
assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); | ||
} | ||
} | ||
} catch (JSONException e) { | ||
fail(TestValues.JSON_FAIL); | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
..._android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/GateStatusTests.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,65 @@ | ||
package com.smartdevicelink.test.rpc.datatypes; | ||
|
||
import com.smartdevicelink.marshal.JsonRPCMarshaller; | ||
import com.smartdevicelink.proxy.rpc.GateStatus; | ||
import com.smartdevicelink.proxy.rpc.Grid; | ||
import com.smartdevicelink.proxy.rpc.RoofStatus; | ||
import com.smartdevicelink.proxy.rpc.enums.DoorStatusType; | ||
import com.smartdevicelink.test.JsonUtils; | ||
import com.smartdevicelink.test.TestValues; | ||
import com.smartdevicelink.test.Validator; | ||
|
||
import junit.framework.TestCase; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.Hashtable; | ||
import java.util.Iterator; | ||
|
||
public class GateStatusTests extends TestCase { | ||
private GateStatus msg; | ||
|
||
@Override | ||
public void setUp() { | ||
msg = new GateStatus(TestValues.GENERAL_GRID, TestValues.GENERAL_DOOR_STATUS_TYPE); | ||
} | ||
|
||
public void testRpcValues() { | ||
// Test Values | ||
Grid location = msg.getLocation(); | ||
DoorStatusType status = msg.getStatus(); | ||
|
||
// Valid Tests | ||
assertEquals(TestValues.MATCH, TestValues.GENERAL_GRID, location); | ||
assertEquals(TestValues.MATCH, TestValues.GENERAL_DOOR_STATUS_TYPE, status); | ||
} | ||
|
||
public void testJson() { | ||
JSONObject reference = new JSONObject(); | ||
|
||
try { | ||
reference.put(RoofStatus.KEY_STATUS, TestValues.GENERAL_DOOR_STATUS_TYPE); | ||
reference.put(RoofStatus.KEY_LOCATION, TestValues.JSON_GRID); | ||
|
||
JSONObject underTest = msg.serializeJSON(); | ||
assertEquals(TestValues.MATCH, reference.length(), underTest.length()); | ||
|
||
Iterator<?> iterator = reference.keys(); | ||
while (iterator.hasNext()) { | ||
String key = (String) iterator.next(); | ||
if (key.equals(RoofStatus.KEY_LOCATION)) { | ||
Hashtable<String, Object> hs1 = JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(reference, key)); | ||
Hashtable<String, Object> hs2 = JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key)); | ||
|
||
assertTrue(Validator.validateGrid(new Grid(hs1), new Grid(hs2))); | ||
|
||
} else { | ||
assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); | ||
} | ||
} | ||
} catch (JSONException e) { | ||
fail(TestValues.JSON_FAIL); | ||
} | ||
} | ||
} |
Oops, something went wrong.