-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[0255] Enchance body information #1583
Merged
bilal-alsharifi
merged 8 commits into
smartdevicelink:develop
from
LuxoftSDL:feature/0255_enchance_body_information
Jan 26, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KostyaBoss You can add this line below line 34:
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KostyaBoss Below line 35 you can bring back the line:
assertEquals(TestValues.MATCH, TestValues.GENERAL_DOOR_STATUS_TYPE, status);