UserNotification extends Model { public static UserNotification GetNotificationByType(String type) { if (legacy_types.contains(type)) { fixUpTable(); type = type + " = ?"; return new Select() .from(UserNotification.class) .where(type, true) .orderBy("_ID desc") .executeSingle(); } else { final String timestamp = PersistentStore.getString("UserNotification:timestamp:" + type); if (timestamp.equals("")) return null; final String message = PersistentStore.getString("UserNotification:message:" + type); if (message.equals("")) return null; UserNotification userNotification = new UserNotification(); userNotification.timestamp = Double.parseDouble(timestamp); userNotification.message = message; Log.d(TAG, "Workaround for: " + type + " " + userNotification.message + " timestamp: " + userNotification.timestamp); return userNotification; } }  static void fixUpTable(); static UserNotification lastBgAlert(); static UserNotification lastCalibrationAlert(); static UserNotification lastDoubleCalibrationAlert(); static UserNotification lastExtraCalibrationAlert(); static UserNotification GetNotificationByType(String type); static void DeleteNotificationByType(String type); static void snoozeAlert(String type, long snoozeMinutes); static UserNotification create(String message, String type, long timestamp); @Column(name = "timestamp", index = true)
    public double timestamp; @Column(name = "message")
    public String message; @Column(name = "bg_alert")
    public boolean bg_alert; @Column(name = "calibration_alert")
    public boolean calibration_alert; @Column(name = "double_calibration_alert")
    public boolean double_calibration_alert; @Column(name = "extra_calibration_alert")
    public boolean extra_calibration_alert; @Column(name = "bg_unclear_readings_alert")
    public boolean bg_unclear_readings_alert; @Column(name = "bg_missed_alerts")
    public boolean bg_missed_alerts; @Column(name = "bg_rise_alert")
    public boolean bg_rise_alert; @Column(name = "bg_fall_alert")
    public boolean bg_fall_alert; }
@Test public void getNonExistingLegacyNotification() { UserNotification calibrationAlert = UserNotification.GetNotificationByType("calibration_alert"); assertThat(calibrationAlert).isNull(); }
@Test public void getNonExistingNewNotification() { UserNotification calibrationAlert = UserNotification.GetNotificationByType("testAlert"); assertThat(calibrationAlert).isNull(); }