Entry extends BaseMessage { public long getTimeStamp() { if (date > 1000000) { return Math.round(date); } if (sysTime != null) { try { final Date date = DateUtil.tolerantFromISODateString(sysTime); return date.getTime(); } catch (Exception e) { } } if (dateString != null) { try { final Date date = DateUtil.tolerantFromISODateString(dateString); return date.getTime(); } catch (Exception e) { } } return -1; }  long getTimeStamp(); @Expose
    public String _id; @Expose
    public double date; @Expose
    public String dateString; @Expose
    public double delta; @Expose
    public String device; @Expose
    public String direction; @Expose
    public double filtered; @Expose
    public int noise; @Expose
    public int rssi; @Expose
    public int sgv; @Expose
    public String sysTime; @Expose
    public String type; @Expose
    public double unfiltered; }
@Test public void getTimeStamp_notSet() { Entry entry = new Entry(); long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(-1); }
@Test public void getTimeStamp_dateStringParser_Invalid() { Entry entry = new Entry(); entry.dateString = "XXX"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(-1); }
@Test public void getTimeStamp_dateStringParser_NoMillis_Iso() { Entry entry = new Entry(); entry.dateString = "2019-06-29T19:52:01Z"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561837921000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 19:52:01 UTC 2019"); }
@Test public void getTimeStamp_dateStringParser_Iso() { Entry entry = new Entry(); entry.dateString = "2019-06-29T19:52:01.123Z"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561837921000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 19:52:01 UTC 2019"); }
@Test public void getTimeStamp_dateStringParser_DifferentTime_Iso() { Entry entry = new Entry(); entry.dateString = "2019-06-29T19:52:01.456Z"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561837921000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 19:52:01 UTC 2019"); }
@Test public void getTimeStamp_dateStringParser_Iso2() { Entry entry = new Entry(); entry.dateString = "2019-06-29T19:52:01+0200"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561830721000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 17:52:01 UTC 2019"); }
@Test public void getTimeStamp_dateStringParser_Iso3() { Entry entry = new Entry(); entry.dateString = "2019-06-29T19:52+0200"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561830720000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 17:52:00 UTC 2019"); }
@Test public void getTimeStamp_sysTimeParser_Invalid() { Entry entry = new Entry(); entry.sysTime = "XXX"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(-1); }
@Test public void getTimeStamp_sysTimeParser_NoMillis_Iso() { Entry entry = new Entry(); entry.sysTime = "2019-06-29T19:52:01Z"; entry.dateString = "XXX"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561837921000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 19:52:01 UTC 2019"); }
@Test public void getTimeStamp_sysTimeParser_Iso() { Entry entry = new Entry(); entry.sysTime = "2019-06-29T19:52:01.123Z"; entry.dateString = "XXX"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561837921000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 19:52:01 UTC 2019"); }
@Test public void getTimeStamp_sysTimeParser_DifferentTime_Iso() { Entry entry = new Entry(); entry.sysTime = "2019-06-29T19:52:01.456Z"; entry.dateString = "XXX"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561837921000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 19:52:01 UTC 2019"); }
@Test public void getTimeStamp_sysTimeParser_Iso2() { Entry entry = new Entry(); entry.sysTime = "2019-06-29T19:52:01+0200"; entry.dateString = "XXX"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561830721000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 17:52:01 UTC 2019"); }
@Test public void getTimeStamp_sysTimeParser_Iso3() { Entry entry = new Entry(); entry.sysTime = "2019-06-29T19:52+0200"; entry.dateString = "XXX"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(1561830720000L); assertThat(new Date(timeStamp).toString()).isEqualTo("Sat Jun 29 17:52:00 UTC 2019"); }
@Test public void getTimestamp_date_low_aka_invalid() { Entry entry = new Entry(); entry.date = 10000; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(-1); }
@Test public void getTimestamp_date_valid() { Entry entry = new Entry(); entry.date = 2000000; entry.sysTime = "XXX"; entry.dateString = "XXX"; long timeStamp = entry.getTimeStamp(); assertThat(timeStamp).isEqualTo(2000000); }