@Test public void testTimedOutResolutionEvent() throws JSONException { ResolutionEvent event = ResolutionEvent.messageResolution("schedule ID", message, ResolutionInfo.timedOut(), 15000); JsonMap expectedResolutionInfo = JsonMap.newBuilder() .put("type", "timed_out") .put("display_time", Event.millisecondsToSecondsString(15000)) .build(); verifyEvent(expectedResolutionInfo, event); }
static ResolutionEvent messageResolution(@NonNull String scheduleId, @NonNull InAppMessage message, ResolutionInfo resolutionInfo, long displayMilliseconds) { displayMilliseconds = displayMilliseconds > 0 ? displayMilliseconds : 0; JsonMap.Builder resolutionDataBuilder = JsonMap.newBuilder() .put(RESOLUTION_TYPE, resolutionInfo.getType()) .put(DISPLAY_TIME, millisecondsToSecondsString(displayMilliseconds)); if (ResolutionInfo.RESOLUTION_BUTTON_CLICK.equals(resolutionInfo.getType()) && resolutionInfo.getButtonInfo() != null) { String description = resolutionInfo.getButtonInfo().getLabel().getText(); if (description != null && description.length() > MAX_BUTTON_DESCRIPTION_LENGTH) { description = description.substring(0, MAX_BUTTON_DESCRIPTION_LENGTH); } resolutionDataBuilder.put(BUTTON_ID, resolutionInfo.getButtonInfo().getId()) .put(BUTTON_DESCRIPTION, description); } return new ResolutionEvent(scheduleId, message, resolutionDataBuilder.build()); }
ResolutionEvent extends InAppMessageEvent { static ResolutionEvent messageResolution(@NonNull String scheduleId, @NonNull InAppMessage message, ResolutionInfo resolutionInfo, long displayMilliseconds) { displayMilliseconds = displayMilliseconds > 0 ? displayMilliseconds : 0; JsonMap.Builder resolutionDataBuilder = JsonMap.newBuilder() .put(RESOLUTION_TYPE, resolutionInfo.getType()) .put(DISPLAY_TIME, millisecondsToSecondsString(displayMilliseconds)); if (ResolutionInfo.RESOLUTION_BUTTON_CLICK.equals(resolutionInfo.getType()) && resolutionInfo.getButtonInfo() != null) { String description = resolutionInfo.getButtonInfo().getLabel().getText(); if (description != null && description.length() > MAX_BUTTON_DESCRIPTION_LENGTH) { description = description.substring(0, MAX_BUTTON_DESCRIPTION_LENGTH); } resolutionDataBuilder.put(BUTTON_ID, resolutionInfo.getButtonInfo().getId()) .put(BUTTON_DESCRIPTION, description); } return new ResolutionEvent(scheduleId, message, resolutionDataBuilder.build()); } }
ResolutionEvent extends InAppMessageEvent { static ResolutionEvent messageResolution(@NonNull String scheduleId, @NonNull InAppMessage message, ResolutionInfo resolutionInfo, long displayMilliseconds) { displayMilliseconds = displayMilliseconds > 0 ? displayMilliseconds : 0; JsonMap.Builder resolutionDataBuilder = JsonMap.newBuilder() .put(RESOLUTION_TYPE, resolutionInfo.getType()) .put(DISPLAY_TIME, millisecondsToSecondsString(displayMilliseconds)); if (ResolutionInfo.RESOLUTION_BUTTON_CLICK.equals(resolutionInfo.getType()) && resolutionInfo.getButtonInfo() != null) { String description = resolutionInfo.getButtonInfo().getLabel().getText(); if (description != null && description.length() > MAX_BUTTON_DESCRIPTION_LENGTH) { description = description.substring(0, MAX_BUTTON_DESCRIPTION_LENGTH); } resolutionDataBuilder.put(BUTTON_ID, resolutionInfo.getButtonInfo().getId()) .put(BUTTON_DESCRIPTION, description); } return new ResolutionEvent(scheduleId, message, resolutionDataBuilder.build()); } ResolutionEvent(@NonNull String scheduleId, @NonNull InAppMessage message, @NonNull JsonMap resolutionData);   ResolutionEvent(@NonNull JsonValue eventId, @NonNull String source, @NonNull JsonMap resolutionData); }
ResolutionEvent extends InAppMessageEvent { static ResolutionEvent messageResolution(@NonNull String scheduleId, @NonNull InAppMessage message, ResolutionInfo resolutionInfo, long displayMilliseconds) { displayMilliseconds = displayMilliseconds > 0 ? displayMilliseconds : 0; JsonMap.Builder resolutionDataBuilder = JsonMap.newBuilder() .put(RESOLUTION_TYPE, resolutionInfo.getType()) .put(DISPLAY_TIME, millisecondsToSecondsString(displayMilliseconds)); if (ResolutionInfo.RESOLUTION_BUTTON_CLICK.equals(resolutionInfo.getType()) && resolutionInfo.getButtonInfo() != null) { String description = resolutionInfo.getButtonInfo().getLabel().getText(); if (description != null && description.length() > MAX_BUTTON_DESCRIPTION_LENGTH) { description = description.substring(0, MAX_BUTTON_DESCRIPTION_LENGTH); } resolutionDataBuilder.put(BUTTON_ID, resolutionInfo.getButtonInfo().getId()) .put(BUTTON_DESCRIPTION, description); } return new ResolutionEvent(scheduleId, message, resolutionDataBuilder.build()); } ResolutionEvent(@NonNull String scheduleId, @NonNull InAppMessage message, @NonNull JsonMap resolutionData);   ResolutionEvent(@NonNull JsonValue eventId, @NonNull String source, @NonNull JsonMap resolutionData); @NonNull @Override final String getType(); @NonNull @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) JsonMap getEventData(); }
ResolutionEvent extends InAppMessageEvent { static ResolutionEvent messageResolution(@NonNull String scheduleId, @NonNull InAppMessage message, ResolutionInfo resolutionInfo, long displayMilliseconds) { displayMilliseconds = displayMilliseconds > 0 ? displayMilliseconds : 0; JsonMap.Builder resolutionDataBuilder = JsonMap.newBuilder() .put(RESOLUTION_TYPE, resolutionInfo.getType()) .put(DISPLAY_TIME, millisecondsToSecondsString(displayMilliseconds)); if (ResolutionInfo.RESOLUTION_BUTTON_CLICK.equals(resolutionInfo.getType()) && resolutionInfo.getButtonInfo() != null) { String description = resolutionInfo.getButtonInfo().getLabel().getText(); if (description != null && description.length() > MAX_BUTTON_DESCRIPTION_LENGTH) { description = description.substring(0, MAX_BUTTON_DESCRIPTION_LENGTH); } resolutionDataBuilder.put(BUTTON_ID, resolutionInfo.getButtonInfo().getId()) .put(BUTTON_DESCRIPTION, description); } return new ResolutionEvent(scheduleId, message, resolutionDataBuilder.build()); } ResolutionEvent(@NonNull String scheduleId, @NonNull InAppMessage message, @NonNull JsonMap resolutionData);   ResolutionEvent(@NonNull JsonValue eventId, @NonNull String source, @NonNull JsonMap resolutionData); @NonNull @Override final String getType(); @NonNull @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) JsonMap getEventData();  }