Author: echatellier Date: 2009-08-28 17:11:54 +0200 (Fri, 28 Aug 2009) New Revision: 2654 Modified: trunk/src/main/java/org/chorem/jtimer/entities/TimerAlert.java trunk/src/test/java/org/chorem/jtimer/entities/TimerAlertTest.java Log: Alert was not equals with null values. Alert editor can't remove null values alerts. Modified: trunk/src/main/java/org/chorem/jtimer/entities/TimerAlert.java =================================================================== --- trunk/src/main/java/org/chorem/jtimer/entities/TimerAlert.java 2009-08-27 14:38:07 UTC (rev 2653) +++ trunk/src/main/java/org/chorem/jtimer/entities/TimerAlert.java 2009-08-28 15:11:54 UTC (rev 2654) @@ -139,7 +139,12 @@ TimerAlert other = (TimerAlert) obj; result = duration == other.duration; - result &= type != null && type.equals(other.type); + if (type != null) { + result &= type.equals(other.type); + } + else { + result &= other.type == null; + } } return result; } Modified: trunk/src/test/java/org/chorem/jtimer/entities/TimerAlertTest.java =================================================================== --- trunk/src/test/java/org/chorem/jtimer/entities/TimerAlertTest.java 2009-08-27 14:38:07 UTC (rev 2653) +++ trunk/src/test/java/org/chorem/jtimer/entities/TimerAlertTest.java 2009-08-28 15:11:54 UTC (rev 2654) @@ -81,8 +81,21 @@ alert.setType(Type.REACH_TOTAL_TIME); Assert.assertEquals(alert, alert2); } - + /** + * Test equals with null values. + */ + @Test + public void testEqualsNull() { + + Assert.assertEquals(new TimerAlert(), new TimerAlert()); + + TimerAlert alert1 = new TimerAlert(); + alert1.setDuration(1); + Assert.assertFalse(alert1.equals(new TimerAlert())); + } + + /** * Test list content (hash code implementation). */ @Test