diff options
author | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2019-03-04 11:54:25 -0500 |
---|---|---|
committer | Bilal Alsharifi <bilal.alsharifi@gmail.com> | 2019-03-04 11:54:25 -0500 |
commit | 6aa38653411257300a77a885064dc9ddda4cd35f (patch) | |
tree | 72ea420e134ca6ef5d0b937a8656ca657055c6b4 /android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java | |
parent | e59b00f4443f7d3e90c86bae562cde3decd95127 (diff) | |
download | sdl_android-6aa38653411257300a77a885064dc9ddda4cd35f.tar.gz |
Move sdl_android to a subfolder
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java')
-rw-r--r-- | android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java new file mode 100644 index 000000000..7e2faa3e4 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java @@ -0,0 +1,75 @@ +package com.smartdevicelink.test.rpc.responses; + +import java.util.Hashtable; + +import org.json.JSONException; +import org.json.JSONObject; + +import com.smartdevicelink.marshal.JsonRPCMarshaller; +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.rpc.ResetGlobalPropertiesResponse; +import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; +import com.smartdevicelink.test.json.rpc.JsonFileReader; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.ResetGlobalPropertiesResponse} + */ +public class ResetGlobalPropertiesResponseTest extends BaseRpcTests { + + @Override + protected RPCMessage createMessage(){ + return new ResetGlobalPropertiesResponse(); + } + + @Override + protected String getMessageType(){ + return RPCMessage.KEY_RESPONSE; + } + + @Override + protected String getCommandType(){ + return FunctionID.RESET_GLOBAL_PROPERTIES.toString(); + } + + @Override + protected JSONObject getExpectedParameters(int sdlVersion){ + return new JSONObject(); + } + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests + ResetGlobalPropertiesResponse msg = new ResetGlobalPropertiesResponse(); + assertNotNull(Test.NULL, msg); + testNullBase(msg); + } + + /** + * Tests a valid JSON construction of this RPC message. + */ + public void testJsonConstructor () { + JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType()); + assertNotNull(Test.NOT_NULL, commandJson); + + try { + Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); + ResetGlobalPropertiesResponse cmd = new ResetGlobalPropertiesResponse(hash); + + JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); + assertNotNull(Test.NOT_NULL, body); + + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + + } catch (JSONException e) { + e.printStackTrace(); + } + } +}
\ No newline at end of file |