diff options
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java')
-rw-r--r-- | android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java index 15a902a84..a6def432b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataConsentTests.java @@ -7,22 +7,28 @@ import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataConsent; import com.smartdevicelink.proxy.rpc.enums.ModuleType; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; -import com.smartdevicelink.test.Test; +import com.smartdevicelink.test.TestValues; import com.smartdevicelink.test.json.rpc.JsonFileReader; import org.json.JSONException; import org.json.JSONObject; +import org.junit.Test; import java.util.Hashtable; import java.util.List; +import static android.support.test.InstrumentationRegistry.getTargetContext; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertNull; +import static junit.framework.TestCase.fail; public class GetInteriorVehicleDataConsentTests extends BaseRpcTests { @Override protected RPCMessage createMessage() { GetInteriorVehicleDataConsent msg = new GetInteriorVehicleDataConsent(); - msg.setModuleType(Test.GENERAL_MODULETYPE); - msg.setModuleIds(Test.GENERAL_STRING_LIST); + msg.setModuleType(TestValues.GENERAL_MODULETYPE); + msg.setModuleIds(TestValues.GENERAL_STRING_LIST); return msg; } @@ -30,10 +36,10 @@ public class GetInteriorVehicleDataConsentTests extends BaseRpcTests { protected JSONObject getExpectedParameters(int sdlVersion) { JSONObject result = new JSONObject(); try { - result.put(GetInteriorVehicleDataConsent.KEY_MODULE_TYPE, Test.GENERAL_MODULETYPE); - result.put(GetInteriorVehicleDataConsent.KEY_MODULE_ID, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST)); + result.put(GetInteriorVehicleDataConsent.KEY_MODULE_TYPE, TestValues.GENERAL_MODULETYPE); + result.put(GetInteriorVehicleDataConsent.KEY_MODULE_ID, JsonUtils.createJsonArray(TestValues.GENERAL_STRING_LIST)); } catch (JSONException e) { - fail(Test.JSON_FAIL); + fail(TestValues.JSON_FAIL); } return result; } @@ -48,45 +54,47 @@ public class GetInteriorVehicleDataConsentTests extends BaseRpcTests { return RPCMessage.KEY_REQUEST; } + @Test public void testRpcValues() { ModuleType type = ((GetInteriorVehicleDataConsent) msg).getModuleType(); List<String> ids = ((GetInteriorVehicleDataConsent) msg).getModuleIds(); //valid tests - assertEquals(Test.MATCH, Test.GENERAL_MODULETYPE, type); - assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST, ids); + assertEquals(TestValues.MATCH, TestValues.GENERAL_MODULETYPE, type); + assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING_LIST, ids); //null tests GetInteriorVehicleDataConsent msg = new GetInteriorVehicleDataConsent(); - assertNull(Test.NULL, msg.getModuleType()); - assertNull(Test.NULL, msg.getModuleIds()); + assertNull(TestValues.NULL, msg.getModuleType()); + assertNull(TestValues.NULL, msg.getModuleIds()); //test require param constructor - GetInteriorVehicleDataConsent msg2 = new GetInteriorVehicleDataConsent(Test.GENERAL_MODULETYPE, Test.GENERAL_STRING_LIST); - assertEquals(Test.MATCH, Test.GENERAL_MODULETYPE, msg2.getModuleType()); - assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST, msg2.getModuleIds()); + GetInteriorVehicleDataConsent msg2 = new GetInteriorVehicleDataConsent(TestValues.GENERAL_MODULETYPE, TestValues.GENERAL_STRING_LIST); + assertEquals(TestValues.MATCH, TestValues.GENERAL_MODULETYPE, msg2.getModuleType()); + assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING_LIST, msg2.getModuleIds()); } + @Test public void testJsonConstructor() { - JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType()); - assertNotNull(Test.NOT_NULL, commandJson); + JSONObject commandJson = JsonFileReader.readId(getTargetContext(), getCommandType(), getMessageType()); + assertNotNull(TestValues.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); GetInteriorVehicleDataConsent cmd = new GetInteriorVehicleDataConsent(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull(Test.NOT_NULL, body); + assertNotNull(TestValues.NOT_NULL, 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()); + 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(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, GetInteriorVehicleDataConsent.KEY_MODULE_TYPE).toString(), cmd.getModuleType().toString()); - assertEquals(Test.MATCH, JsonUtils.readStringListFromJsonObject(parameters, GetInteriorVehicleDataConsent.KEY_MODULE_ID), cmd.getModuleIds()); + assertEquals(TestValues.MATCH, JsonUtils.readObjectFromJsonObject(parameters, GetInteriorVehicleDataConsent.KEY_MODULE_TYPE).toString(), cmd.getModuleType().toString()); + assertEquals(TestValues.MATCH, JsonUtils.readStringListFromJsonObject(parameters, GetInteriorVehicleDataConsent.KEY_MODULE_ID), cmd.getModuleIds()); } catch (JSONException e) { - fail(Test.JSON_FAIL); + fail(TestValues.JSON_FAIL); } } |