@Test void testnumberMesagesImportant() { Map<String, EntityData> map = new HashMap<>(); when(this.important.getString()).thenReturn("important"); when(this.emailLogic.getNewMessageCount(true)).thenReturn(2); map.put("important", this.important); assertThat(this.speech.numberOfNewMails(map), equalTo("2 new important messages")); when(this.emailLogic.getNewMessageCount(true)).thenReturn(0); assertThat(this.speech.numberOfNewMails(map), equalTo("No important new messages")); }
@Intent() public String numberOfNewMails(Map<String, EntityData> entities) { try { if (entities.get(IMPORTANT) != null && entities.get(IMPORTANT).getString().contains(IMPORTANT)) { int count = this.logic.getNewMessageCount(true); if (count > 0) { return count + " new important messages"; } return NO_IMP_MAILS; } int count = this.logic.getNewMessageCount(false); if (count > 0) { return count + " new mails."; } return NO_MAILS; } catch (IllegalStateException ise) { return ise.getMessage(); } }
EMailSpeech { @Intent() public String numberOfNewMails(Map<String, EntityData> entities) { try { if (entities.get(IMPORTANT) != null && entities.get(IMPORTANT).getString().contains(IMPORTANT)) { int count = this.logic.getNewMessageCount(true); if (count > 0) { return count + " new important messages"; } return NO_IMP_MAILS; } int count = this.logic.getNewMessageCount(false); if (count > 0) { return count + " new mails."; } return NO_MAILS; } catch (IllegalStateException ise) { return ise.getMessage(); } } }
EMailSpeech { @Intent() public String numberOfNewMails(Map<String, EntityData> entities) { try { if (entities.get(IMPORTANT) != null && entities.get(IMPORTANT).getString().contains(IMPORTANT)) { int count = this.logic.getNewMessageCount(true); if (count > 0) { return count + " new important messages"; } return NO_IMP_MAILS; } int count = this.logic.getNewMessageCount(false); if (count > 0) { return count + " new mails."; } return NO_MAILS; } catch (IllegalStateException ise) { return ise.getMessage(); } }  }
EMailSpeech { @Intent() public String numberOfNewMails(Map<String, EntityData> entities) { try { if (entities.get(IMPORTANT) != null && entities.get(IMPORTANT).getString().contains(IMPORTANT)) { int count = this.logic.getNewMessageCount(true); if (count > 0) { return count + " new important messages"; } return NO_IMP_MAILS; } int count = this.logic.getNewMessageCount(false); if (count > 0) { return count + " new mails."; } return NO_MAILS; } catch (IllegalStateException ise) { return ise.getMessage(); } }  @Intent String connectToAmyMail(Map<String, EntityData> entities); @Intent String disconnect(Map<String, EntityData> entities); @Intent() String newMessages(Map<String, EntityData> entities); @Intent() String numberOfNewMails(Map<String, EntityData> entities); @Intent() String readRecentMails(Map<String, EntityData> entities); }
EMailSpeech { @Intent() public String numberOfNewMails(Map<String, EntityData> entities) { try { if (entities.get(IMPORTANT) != null && entities.get(IMPORTANT).getString().contains(IMPORTANT)) { int count = this.logic.getNewMessageCount(true); if (count > 0) { return count + " new important messages"; } return NO_IMP_MAILS; } int count = this.logic.getNewMessageCount(false); if (count > 0) { return count + " new mails."; } return NO_MAILS; } catch (IllegalStateException ise) { return ise.getMessage(); } }  @Intent String connectToAmyMail(Map<String, EntityData> entities); @Intent String disconnect(Map<String, EntityData> entities); @Intent() String newMessages(Map<String, EntityData> entities); @Intent() String numberOfNewMails(Map<String, EntityData> entities); @Intent() String readRecentMails(Map<String, EntityData> entities);  }