summaryrefslogtreecommitdiff
path: root/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java')
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java54
1 files changed, 31 insertions, 23 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java
index 8e9145b27..dd81627b4 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java
@@ -7,13 +7,19 @@ import com.smartdevicelink.proxy.rpc.PerformInteractionResponse;
import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
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 static android.support.test.InstrumentationRegistry.getContext;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertNull;
+import static junit.framework.TestCase.fail;
/**
* This is a unit test class for the SmartDeviceLink library project class :
@@ -25,9 +31,9 @@ public class PerformInteractionResponseTest extends BaseRpcTests {
protected RPCMessage createMessage() {
PerformInteractionResponse msg = new PerformInteractionResponse();
- msg.setChoiceID(Test.GENERAL_INT);
- msg.setTriggerSource(Test.GENERAL_TRIGGERSOURCE);
- msg.setManualTextEntry(Test.GENERAL_STRING);
+ msg.setChoiceID(TestValues.GENERAL_INT);
+ msg.setTriggerSource(TestValues.GENERAL_TRIGGERSOURCE);
+ msg.setManualTextEntry(TestValues.GENERAL_STRING);
return msg;
}
@@ -47,11 +53,11 @@ public class PerformInteractionResponseTest extends BaseRpcTests {
JSONObject result = new JSONObject();
try {
- result.put(PerformInteractionResponse.KEY_CHOICE_ID, Test.GENERAL_INT);
- result.put(PerformInteractionResponse.KEY_TRIGGER_SOURCE, Test.GENERAL_TRIGGERSOURCE);
- result.put(PerformInteractionResponse.KEY_MANUAL_TEXT_ENTRY, Test.GENERAL_STRING);
+ result.put(PerformInteractionResponse.KEY_CHOICE_ID, TestValues.GENERAL_INT);
+ result.put(PerformInteractionResponse.KEY_TRIGGER_SOURCE, TestValues.GENERAL_TRIGGERSOURCE);
+ result.put(PerformInteractionResponse.KEY_MANUAL_TEXT_ENTRY, TestValues.GENERAL_STRING);
} catch (JSONException e) {
- fail(Test.JSON_FAIL);
+ fail(TestValues.JSON_FAIL);
}
return result;
@@ -60,6 +66,7 @@ public class PerformInteractionResponseTest extends BaseRpcTests {
/**
* Tests the expected values of the RPC message.
*/
+ @Test
public void testRpcValues () {
// Test Values
Integer testId = ( (PerformInteractionResponse) msg).getChoiceID();
@@ -67,42 +74,43 @@ public class PerformInteractionResponseTest extends BaseRpcTests {
String testText = ( (PerformInteractionResponse) msg).getManualTextEntry();
// Valid Tests
- assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, testId);
- assertEquals(Test.MATCH, Test.GENERAL_TRIGGERSOURCE, testSource);
- assertEquals(Test.MATCH, Test.GENERAL_STRING, testText);
+ assertEquals(TestValues.MATCH, (Integer) TestValues.GENERAL_INT, testId);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_TRIGGERSOURCE, testSource);
+ assertEquals(TestValues.MATCH, TestValues.GENERAL_STRING, testText);
// Invalid/Null Tests
PerformInteractionResponse msg = new PerformInteractionResponse();
- assertNotNull(Test.NOT_NULL, msg);
+ assertNotNull(TestValues.NOT_NULL, msg);
testNullBase(msg);
- assertNull(Test.NULL, msg.getChoiceID());
- assertNull(Test.NULL, msg.getTriggerSource());
- assertNull(Test.NULL, msg.getManualTextEntry());
+ assertNull(TestValues.NULL, msg.getChoiceID());
+ assertNull(TestValues.NULL, msg.getTriggerSource());
+ assertNull(TestValues.NULL, msg.getManualTextEntry());
}
/**
* Tests a valid JSON construction of this RPC message.
*/
+ @Test
public void testJsonConstructor () {
- JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
- assertNotNull(Test.NOT_NULL, commandJson);
+ JSONObject commandJson = JsonFileReader.readId(getContext(), getCommandType(), getMessageType());
+ assertNotNull(TestValues.NOT_NULL, commandJson);
try {
Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
PerformInteractionResponse cmd = new PerformInteractionResponse(hash);
JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
- assertNotNull(Test.NOT_NULL, body);
+ assertNotNull(TestValues.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());
+ 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.readStringFromJsonObject(parameters, PerformInteractionResponse.KEY_MANUAL_TEXT_ENTRY), cmd.getManualTextEntry());
- assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, PerformInteractionResponse.KEY_TRIGGER_SOURCE), cmd.getTriggerSource().toString());
- assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, PerformInteractionResponse.KEY_CHOICE_ID), cmd.getChoiceID());
+ assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, PerformInteractionResponse.KEY_MANUAL_TEXT_ENTRY), cmd.getManualTextEntry());
+ assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, PerformInteractionResponse.KEY_TRIGGER_SOURCE), cmd.getTriggerSource().toString());
+ assertEquals(TestValues.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, PerformInteractionResponse.KEY_CHOICE_ID), cmd.getChoiceID());
} catch (JSONException e) {
e.printStackTrace();
}