use of com.fitpay.android.webview.events.RtmMessage in project fitpay-android-sdk by fitpay.
the class RtmParserTest method testWebAppVersionSameWrongData.
@Test
public void testWebAppVersionSameWrongData() {
String rtmMsgStr = "{\"callbackId\":\"0\",\"type\":\"version\"}";
RtmMessage msg = Constants.getGson().fromJson(rtmMsgStr, RtmMessage.class);
int webAppRtmVersion = RtmType.RTM_VERSION;
String errorMsg = null;
try {
RtmParserImpl.parse(wvci, webAppRtmVersion, msg);
} catch (IllegalStateException e) {
errorMsg = e.getMessage();
}
assertEquals("missing required message data", errorMsg);
}
use of com.fitpay.android.webview.events.RtmMessage in project fitpay-android-sdk by fitpay.
the class RtmParserTest method testWebAppVersionHigher.
@Test
public void testWebAppVersionHigher() {
String rtmMsgStr = "{\"callbackId\":\"0\",\"data\":\"{\\\"version\\\":3}\",\"type\":\"version\"}";
RtmMessage msg = Constants.getGson().fromJson(rtmMsgStr, RtmMessage.class);
int webAppRtmVersion = RtmType.RTM_VERSION + 1;
String errorMsg = null;
try {
RtmParserImpl.parse(wvci, webAppRtmVersion, msg);
} catch (IllegalStateException e) {
errorMsg = e.getMessage();
}
assertEquals("WebApp RTM version:" + webAppRtmVersion + " is not supported", errorMsg);
}
use of com.fitpay.android.webview.events.RtmMessage in project fitpay-android-sdk by fitpay.
the class UnrecognizedMessageTest method testUnrecognizedRtmMessage.
@Test
public void testUnrecognizedRtmMessage() {
String rtmMsgStr = "{\"callbackId\":\"10\",\"data\":\"{\\\"resource\\\":\\\"The Truth Is Out There\\\"}\",\"type\":\"somethingUnknown\"}";
RtmMessage msg = Constants.getGson().fromJson(rtmMsgStr, RtmMessage.class);
RxBus.getInstance().post(msg);
try {
FPLog.d("UnrecognizedMessageTest", "start:" + System.currentTimeMillis());
latch.await(30, TimeUnit.SECONDS);
FPLog.d("UnrecognizedMessageTest", "end:" + System.currentTimeMillis());
} catch (InterruptedException e) {
FPLog.d("UnrecognizedMessageTest", "exception:" + System.currentTimeMillis());
e.printStackTrace();
}
assertNotNull("unrecognized message shouldn't be null", message);
UnrecognizedRtmData data = Constants.getGson().fromJson(message.getJsonData(), UnrecognizedRtmData.class);
assertEquals("unrecognized message data should be equal", "The Truth Is Out There", data.resource);
}
use of com.fitpay.android.webview.events.RtmMessage in project fitpay-android-sdk by fitpay.
the class RtmParserTest method testWebAppVersionLower.
@Test
public void testWebAppVersionLower() {
String rtmMsgStr = "{\"callbackId\":\"0\",\"data\":\"{\\\"version\\\":3}\",\"type\":\"version\"}";
RtmMessage msg = Constants.getGson().fromJson(rtmMsgStr, RtmMessage.class);
int webAppRtmVersion = 2;
String errorMsg = null;
try {
RtmParserImpl.parse(wvci, webAppRtmVersion, msg);
} catch (IllegalStateException e) {
errorMsg = e.getMessage();
}
Assert.assertNull(errorMsg);
}
use of com.fitpay.android.webview.events.RtmMessage in project fitpay-android-sdk by fitpay.
the class RtmParserTest method testWebAppVersionSameNoMethod.
@Ignore("needs to be rewritten, we don't throw exceptions anymore... needs to listen to RxBus instead for the unrecognized message")
@Test
public void testWebAppVersionSameNoMethod() {
String rtmMsgStr = "{\"callbackId\":\"9\",\"data\":\"{\\\"next\\\":\\\"\\\\/walletAccess\\\",\\\"previous\\\":\\\"\\\\/cards\\\"}\",\"type\":\"navigationStart\"}";
RtmMessage msg = Constants.getGson().fromJson(rtmMsgStr, RtmMessage.class);
int webAppRtmVersion = 3;
String errorMsg = "";
try {
RtmParserImpl.parse(wvci, webAppRtmVersion, msg);
} catch (IllegalStateException e) {
errorMsg = e.getMessage();
}
assertEquals("unsupported action value navigationStart", errorMsg);
}
Aggregations