diff options
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java')
-rw-r--r-- | android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java index d4af2d0da..54d806e08 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DeleteFileTests.java @@ -22,85 +22,85 @@ 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.DeleteFile} */ -public class DeleteFileTests extends BaseRpcTests{ - +public class DeleteFileTests extends BaseRpcTests { + @Override - protected RPCMessage createMessage(){ + protected RPCMessage createMessage() { DeleteFile msg = new DeleteFile(); - msg.setSdlFileName(TestValues.GENERAL_STRING); + msg.setSdlFileName(TestValues.GENERAL_STRING); return msg; } @Override - protected String getMessageType(){ + protected String getMessageType() { return RPCMessage.KEY_REQUEST; } @Override - protected String getCommandType(){ + protected String getCommandType() { return FunctionID.DELETE_FILE.toString(); } @Override - protected JSONObject getExpectedParameters(int sdlVersion){ + protected JSONObject getExpectedParameters(int sdlVersion) { JSONObject result = new JSONObject(); - try{ - result.put(DeleteFile.KEY_SDL_FILE_NAME, TestValues.GENERAL_STRING); - }catch(JSONException e){ - fail(TestValues.JSON_FAIL); + try { + result.put(DeleteFile.KEY_SDL_FILE_NAME, TestValues.GENERAL_STRING); + } 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 - String testFilename = ( (DeleteFile) msg ).getSdlFileName(); - - // Valid Tests - assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testFilename); - - // Invalid/Null Tests - DeleteFile msg = new DeleteFile(); - assertNotNull(TestValues.NOT_NULL, msg); - testNullBase(msg); - - assertNull(TestValues.NULL, msg.getSdlFileName()); + public void testRpcValues() { + // Test Values + String testFilename = ((DeleteFile) msg).getSdlFileName(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testFilename); + + // Invalid/Null Tests + DeleteFile msg = new DeleteFile(); + assertNotNull(TestValues.NOT_NULL, msg); + testNullBase(msg); + + assertNull(TestValues.NULL, msg.getSdlFileName()); } /** * 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); - DeleteFile cmd = new DeleteFile(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.readStringFromJsonObject(parameters, DeleteFile.KEY_SDL_FILE_NAME), cmd.getSdlFileName()); - } 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); + DeleteFile cmd = new DeleteFile(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.readStringFromJsonObject(parameters, DeleteFile.KEY_SDL_FILE_NAME), cmd.getSdlFileName()); + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); + } } }
\ No newline at end of file |