GlassEvent { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GlassEvent that = (GlassEvent) o; if (type != that.type) return false; if (value == null && that.value != null) return false; if (type.equals(Type.TOTAL_LINES_REMOVED) || type.equals(Type.WITHOUT_OVERFLOWN_LINES_REMOVED)) { if ((Integer)value > (Integer)that.value) return false; } else { if (!value.equals(that.value)) return false; } return true; } GlassEvent(Type type, T value); Type getType(); T getValue(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void shouldEqualsEventsWhenSameCountLinesRemovedInLinesRemovedEventType() { GlassEvent event = new GlassEvent(LINES_REMOVED, 4); assertTrue(event.equals(new GlassEvent(LINES_REMOVED, 4))); }
@Test public void shouldNotEqualsEventsWhenNotSameCountLinesRemovedInLinesRemovedEventType() { GlassEvent event = new GlassEvent(LINES_REMOVED, 4); assertFalse(event.equals(new GlassEvent(LINES_REMOVED, 3))); }
@Test public void shouldNotEqualsEventsWhenLessThanTotalCountLinesRemovedInTotalLinesRemovedEventType() { GlassEvent event = new GlassEvent(TOTAL_LINES_REMOVED, 4); assertFalse(event.equals(new GlassEvent(TOTAL_LINES_REMOVED, 3))); }
@Test public void shouldEqualsEventsWhenMoreThanOrEqualsToTotalCountLinesRemovedInTotalLinesRemovedEventType() { GlassEvent event = new GlassEvent(TOTAL_LINES_REMOVED, 4); assertTrue(event.equals(new GlassEvent(TOTAL_LINES_REMOVED, 4))); assertTrue(event.equals(new GlassEvent(TOTAL_LINES_REMOVED, 15))); }
@Test public void shouldNotEqualsEventsWhenDifferentEvents() { GlassEvent event = new GlassEvent(LINES_REMOVED, 4); assertFalse(event.equals(new GlassEvent(TOTAL_LINES_REMOVED, 4))); }
@Test public void shouldNotEqualsEventsWhenLessThanTotalCountLinesRemovedInWithoutOverflownLinesRemovedEventType() { GlassEvent event = new GlassEvent(WITHOUT_OVERFLOWN_LINES_REMOVED, 10); assertFalse(event.equals(new GlassEvent(WITHOUT_OVERFLOWN_LINES_REMOVED, 9))); }
@Test public void shouldEqualsEventsWhenMoreThanOrEqualsToTotalCountLinesRemovedInWithoutOverflownLinesRemovedEventType() { GlassEvent event = new GlassEvent(WITHOUT_OVERFLOWN_LINES_REMOVED, 10); assertTrue(event.equals(new GlassEvent(WITHOUT_OVERFLOWN_LINES_REMOVED, 10))); assertTrue(event.equals(new GlassEvent(WITHOUT_OVERFLOWN_LINES_REMOVED, 15))); }