AlertEventService extends AbstractEventService implements AlertMailEventService { @Override @SuppressWarnings("unchecked") public List<EventModel> findEventsByTypeAndDate(EventModel.EventType eventType, Date date) { List<EventTbl> eventTbls = eventDao.findEventsByTypeAndDate(eventType.name(), date); if(eventTbls == null || eventTbls.isEmpty()) { return Lists.newLinkedList(); } return transferToEventModels(eventTbls, new Function<String, String>() { @Override public String apply(String s) { return s; } }); }  @Override void insert(EventModel eventModel); @Override @SuppressWarnings("unchecked") List<EventModel> findEventsByTypeAndDate(EventModel.EventType eventType, Date date); @Override List<EventModel> getLastHourAlertEvent();  }
@Test public void findEventsByTypeAndDate() { Date date = new Date(); service.insert(new EventModel().setEventType(EventModel.EventType.UNKNOWN).setEventDetail("test") .setEventOperation(ALERT_TYPE.CLIENT_INCONSIS.name()).setLastUpdate(new Date())); service.insert(new EventModel().setEventType(EventModel.EventType.ALERT_EMAIL).setEventDetail("test2") .setEventOperation(ALERT_TYPE.CLIENT_INCONSIS.name()).setLastUpdate(new Date())); List<EventModel> events = service.findEventsByTypeAndDate(EventModel.EventType.ALERT_EMAIL, date); Assert.assertEquals(1, events.size()); Assert.assertEquals(ALERT_TYPE.CLIENT_INCONSIS.name(), events.get(0).getEventOperation()); events = service.findEventsByTypeAndDate(EventModel.EventType.ALERT_EMAIL, DateTimeUtils.getMinutesLaterThan(date, 120)); Assert.assertTrue(events.isEmpty()); }