@Test void testGetEventsAt() { Map<String, EntityData> map = new HashMap<>(); when(this.dateEntity.getDate()).thenReturn(LocalDate.of(2018, 9, 20)); when(this.dateEntity.getString()).thenReturn(""); map.put("date", this.dateEntity); map.put("eventyear", null); when(this.environment.getCurrentLocalDateTime()).thenReturn(LocalDateTime.of(2018, 9, 21, 10, 00)); String response = this.speech.getEventsAt(map); assertThat(response, equalToIgnoringWhiteSpace("No events found for the 20th of september 2019.")); }
@Intent public String getEventsAt(Map<String, EntityData> entities) { List<CalendarEvent> events; List<String> eventList = new ArrayList<>(); String dateEntity = entities.get("date").getString(); LocalDateTime date = LocalDateTime.of(entities.get("date").getDate(), ZERO); if (entities.get("eventyear") == null && date.toLocalDate().isBefore(this.environment. getCurrentLocalDateTime().toLocalDate())) { date = date.withYear(this.environment.getCurrentLocalDateTime().getYear() + 1); } events = this.logic.getEventsAt(date); for (CalendarEvent event : events) { eventList.add(this.checkDate(date, event, false)); } if (dateEntity.equals("today") || dateEntity.equals("tomorrow")) { if (events.isEmpty()) { return "You have no events " + dateEntity + "."; } return "You have following events " + dateEntity +":\n" + String.join("\n", eventList); } if (events.isEmpty()) { return "No events found for the " + getDate(date) + " " + date.getYear() + "."; } return "You have following events on the " + getDate(date) + " " + date.getYear() + ":\n" + String.join("\n", eventList); }
CalendarSpeech { @Intent public String getEventsAt(Map<String, EntityData> entities) { List<CalendarEvent> events; List<String> eventList = new ArrayList<>(); String dateEntity = entities.get("date").getString(); LocalDateTime date = LocalDateTime.of(entities.get("date").getDate(), ZERO); if (entities.get("eventyear") == null && date.toLocalDate().isBefore(this.environment. getCurrentLocalDateTime().toLocalDate())) { date = date.withYear(this.environment.getCurrentLocalDateTime().getYear() + 1); } events = this.logic.getEventsAt(date); for (CalendarEvent event : events) { eventList.add(this.checkDate(date, event, false)); } if (dateEntity.equals("today") || dateEntity.equals("tomorrow")) { if (events.isEmpty()) { return "You have no events " + dateEntity + "."; } return "You have following events " + dateEntity +":\n" + String.join("\n", eventList); } if (events.isEmpty()) { return "No events found for the " + getDate(date) + " " + date.getYear() + "."; } return "You have following events on the " + getDate(date) + " " + date.getYear() + ":\n" + String.join("\n", eventList); } }
CalendarSpeech { @Intent public String getEventsAt(Map<String, EntityData> entities) { List<CalendarEvent> events; List<String> eventList = new ArrayList<>(); String dateEntity = entities.get("date").getString(); LocalDateTime date = LocalDateTime.of(entities.get("date").getDate(), ZERO); if (entities.get("eventyear") == null && date.toLocalDate().isBefore(this.environment. getCurrentLocalDateTime().toLocalDate())) { date = date.withYear(this.environment.getCurrentLocalDateTime().getYear() + 1); } events = this.logic.getEventsAt(date); for (CalendarEvent event : events) { eventList.add(this.checkDate(date, event, false)); } if (dateEntity.equals("today") || dateEntity.equals("tomorrow")) { if (events.isEmpty()) { return "You have no events " + dateEntity + "."; } return "You have following events " + dateEntity +":\n" + String.join("\n", eventList); } if (events.isEmpty()) { return "No events found for the " + getDate(date) + " " + date.getYear() + "."; } return "You have following events on the " + getDate(date) + " " + date.getYear() + ":\n" + String.join("\n", eventList); }  }
CalendarSpeech { @Intent public String getEventsAt(Map<String, EntityData> entities) { List<CalendarEvent> events; List<String> eventList = new ArrayList<>(); String dateEntity = entities.get("date").getString(); LocalDateTime date = LocalDateTime.of(entities.get("date").getDate(), ZERO); if (entities.get("eventyear") == null && date.toLocalDate().isBefore(this.environment. getCurrentLocalDateTime().toLocalDate())) { date = date.withYear(this.environment.getCurrentLocalDateTime().getYear() + 1); } events = this.logic.getEventsAt(date); for (CalendarEvent event : events) { eventList.add(this.checkDate(date, event, false)); } if (dateEntity.equals("today") || dateEntity.equals("tomorrow")) { if (events.isEmpty()) { return "You have no events " + dateEntity + "."; } return "You have following events " + dateEntity +":\n" + String.join("\n", eventList); } if (events.isEmpty()) { return "No events found for the " + getDate(date) + " " + date.getYear() + "."; } return "You have following events on the " + getDate(date) + " " + date.getYear() + ":\n" + String.join("\n", eventList); }  @Intent String getEvents(Map<String, EntityData> entities); @Intent String getEventsAt(Map<String, EntityData> entities); @Intent String setEvent(Map<String, EntityData> entities); String getDate(LocalDateTime date); static String ordinal(int i); String checkDate(LocalDateTime dayToCheck, CalendarEvent event, boolean withDate); String eventToString(LocalDateTime startDate, LocalDateTime endDate, CalendarEvent event, boolean withStartDate,
			boolean withEndDate, boolean withTime, OutputCase outputCase); String getCorrectTime(LocalDateTime localDateTime); LocalTime parseTo12Hour(LocalDateTime localDateTime); String dateOutput(LocalDateTime date, boolean withDate, boolean withTime); static OutputCase eventType(ChronoLocalDate date1, ChronoLocalDate date2, CalendarEvent event,
			OutputCase defaultCase); static boolean isAllDay(String allDayEntity); }
CalendarSpeech { @Intent public String getEventsAt(Map<String, EntityData> entities) { List<CalendarEvent> events; List<String> eventList = new ArrayList<>(); String dateEntity = entities.get("date").getString(); LocalDateTime date = LocalDateTime.of(entities.get("date").getDate(), ZERO); if (entities.get("eventyear") == null && date.toLocalDate().isBefore(this.environment. getCurrentLocalDateTime().toLocalDate())) { date = date.withYear(this.environment.getCurrentLocalDateTime().getYear() + 1); } events = this.logic.getEventsAt(date); for (CalendarEvent event : events) { eventList.add(this.checkDate(date, event, false)); } if (dateEntity.equals("today") || dateEntity.equals("tomorrow")) { if (events.isEmpty()) { return "You have no events " + dateEntity + "."; } return "You have following events " + dateEntity +":\n" + String.join("\n", eventList); } if (events.isEmpty()) { return "No events found for the " + getDate(date) + " " + date.getYear() + "."; } return "You have following events on the " + getDate(date) + " " + date.getYear() + ":\n" + String.join("\n", eventList); }  @Intent String getEvents(Map<String, EntityData> entities); @Intent String getEventsAt(Map<String, EntityData> entities); @Intent String setEvent(Map<String, EntityData> entities); String getDate(LocalDateTime date); static String ordinal(int i); String checkDate(LocalDateTime dayToCheck, CalendarEvent event, boolean withDate); String eventToString(LocalDateTime startDate, LocalDateTime endDate, CalendarEvent event, boolean withStartDate,
			boolean withEndDate, boolean withTime, OutputCase outputCase); String getCorrectTime(LocalDateTime localDateTime); LocalTime parseTo12Hour(LocalDateTime localDateTime); String dateOutput(LocalDateTime date, boolean withDate, boolean withTime); static OutputCase eventType(ChronoLocalDate date1, ChronoLocalDate date2, CalendarEvent event,
			OutputCase defaultCase); static boolean isAllDay(String allDayEntity);  }