AlertEventService extends AbstractEventService implements AlertMailEventService { @Override public List<EventModel> getLastHourAlertEvent() { return findEventsByTypeAndDate(EventModel.EventType.ALERT_EMAIL, DateTimeUtils.getHoursBeforeDate(new Date(), 1)); }  @Override void insert(EventModel eventModel); @Override @SuppressWarnings("unchecked") List<EventModel> findEventsByTypeAndDate(EventModel.EventType eventType, Date date); @Override List<EventModel> getLastHourAlertEvent();  }
@Test public void testGetLastHourAlertEvent() { service.insert(new EventModel().setEventType(EventModel.EventType.ALERT_EMAIL).setEventDetail("test") .setEventOperation(ALERT_TYPE.CLIENT_INCONSIS.name()).setLastUpdate(DateTimeUtils.getHoursBeforeDate(new Date(), 2))); service.insert(new EventModel().setEventType(EventModel.EventType.ALERT_EMAIL).setEventDetail("test2") .setEventOperation(ALERT_TYPE.CLIENT_INCONSIS.name())); List<EventModel> events = service.getLastHourAlertEvent(); Assert.assertEquals(1, events.size()); Assert.assertEquals(ALERT_TYPE.CLIENT_INCONSIS.name(), events.get(0).getEventOperation()); }