use of com.onesignal.OSNotificationAction in project OneSignal-Android-SDK by OneSignal.
the class MainOneSignalClassRunner method testOSNotificationOpenResultToJSONObject.
@Test
public void testOSNotificationOpenResultToJSONObject() throws Exception {
OSNotificationOpenResult osNotificationOpenResult = new OSNotificationOpenResult();
osNotificationOpenResult.notification = createTestOSNotification();
osNotificationOpenResult.action = new OSNotificationAction();
osNotificationOpenResult.action.type = OSNotificationAction.ActionType.Opened;
JSONObject testJsonObj = osNotificationOpenResult.toJSONObject();
JSONObject additionalData = testJsonObj.optJSONObject("notification").optJSONObject("payload").optJSONObject("additionalData");
Assert.assertEquals("bar", additionalData.optString("foo"));
JSONObject firstGroupedNotification = (JSONObject) testJsonObj.optJSONObject("notification").optJSONArray("groupedNotifications").get(0);
Assert.assertEquals("collapseId1", firstGroupedNotification.optString("collapseId"));
}
Aggregations