BgWatchData implements Comparable<BgWatchData> { @Override public boolean equals(Object that){ if(! (that instanceof BgWatchData)){ return false; } if (this.color != ((BgWatchData) that).color) return false; return this.timestamp == ((BgWatchData) that).timestamp; } BgWatchData(double aSgv, double aHigh, double aLow, long aTimestamp, int aColor);  BgWatchData(); @Override boolean equals(Object that); @Override int hashCode(); @Override int compareTo(BgWatchData that); public double sgv; public double high; public double low; public long timestamp; public int color; }
@Test public void bgWatchDataEqualsTest() { BgWatchData item1 = new BgWatchData( 88.0, 160.0, 90.0, WearUtilMocker.REF_NOW - Constants.MINUTE_IN_MS, 1 ); BgWatchData item2sameTimeSameColor = new BgWatchData( 123.0, 190, 90.0, WearUtilMocker.REF_NOW - Constants.MINUTE_IN_MS, 1 ); BgWatchData item3sameTimeSameDiffColor = new BgWatchData( 96.0, 190, 90.0, WearUtilMocker.REF_NOW - Constants.MINUTE_IN_MS, 0 ); BgWatchData item4differentTime = new BgWatchData( 88.0, 160.0, 90.0, WearUtilMocker.REF_NOW - Constants.MINUTE_IN_MS*2, 1 ); assertEquals(item1, item2sameTimeSameColor); assertNotEquals(item1, item3sameTimeSameDiffColor); assertNotEquals(item1, item4differentTime); assertFalse(item1.equals("aa bbb")); }