diff options
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java')
-rw-r--r-- | android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java index 72401b9b1..74cfa67ae 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteCommandTests.java @@ -22,13 +22,13 @@ import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.fail; /** - * This is a unit test class for the SmartDeviceLink library project class : + * This is a unit test class for the SmartDeviceLink library project class : * {@link com.smartdevicelink.proxy.rpc.DeleteCommand} */ -public class DeleteCommandTests extends BaseRpcTests{ +public class DeleteCommandTests extends BaseRpcTests { @Override - protected RPCMessage createMessage(){ + protected RPCMessage createMessage() { DeleteCommand msg = new DeleteCommand(); msg.setCmdID(TestValues.GENERAL_INT); @@ -37,39 +37,39 @@ public class DeleteCommandTests extends BaseRpcTests{ } @Override - protected String getMessageType(){ + protected String getMessageType() { return RPCMessage.KEY_REQUEST; } @Override - protected String getCommandType(){ + protected String getCommandType() { return FunctionID.DELETE_COMMAND.toString(); } @Override - protected JSONObject getExpectedParameters(int sdlVersion){ + protected JSONObject getExpectedParameters(int sdlVersion) { JSONObject result = new JSONObject(); - try{ + try { result.put(DeleteCommand.KEY_CMD_ID, TestValues.GENERAL_INT); - }catch(JSONException e){ - fail(TestValues.JSON_FAIL); + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); } return result; } /** - * Tests the expected values of the RPC message. - */ + * Tests the expected values of the RPC message. + */ @Test - public void testRpcValues () { - // Test Values - int cmdId = ( (DeleteCommand) msg ).getCmdID(); - - // Valid Tests + public void testRpcValues() { + // Test Values + int cmdId = ((DeleteCommand) msg).getCmdID(); + + // Valid Tests assertEquals("Command ID didn't match input command ID.", TestValues.GENERAL_INT, cmdId); - + // Invalid/Null Tests DeleteCommand msg = new DeleteCommand(); assertNotNull(TestValues.NOT_NULL, msg); @@ -77,31 +77,30 @@ public class DeleteCommandTests extends BaseRpcTests{ assertNull(TestValues.MATCH, msg.getCmdID()); } - + /** * Tests a valid JSON construction of this RPC message. */ @Test - public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); - assertNotNull(TestValues.NOT_NULL, commandJson); - - try { - Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); - DeleteCommand cmd = new DeleteCommand(hash); - - JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull(TestValues.NOT_NULL, body); - - // Test everything in the json body. - assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - - JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); - assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, DeleteCommand.KEY_CMD_ID), cmd.getCmdID()); - } - catch (JSONException e) { - fail(TestValues.JSON_FAIL); - } + public void testJsonConstructor() { + JSONObject commandJson = JsonFileReader.readId(getInstrumentation().getTargetContext(), getCommandType(), getMessageType()); + assertNotNull(TestValues.NOT_NULL, commandJson); + + try { + Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); + DeleteCommand cmd = new DeleteCommand(hash); + + JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); + assertNotNull(TestValues.NOT_NULL, body); + + // Test everything in the json body. + assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + + JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); + assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, DeleteCommand.KEY_CMD_ID), cmd.getCmdID()); + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); + } } }
\ No newline at end of file |