@Test public void shouldReturnProperMailsForAutoComplete() { List<String> available = emailController.getAvailableMails("subject", "abc"); List<String> available2 = emailController.getAvailableMails("subject", "def"); List<String> available3 = emailController.getAvailableMails("subject", "abc@g"); assertNotNull(available); assertNotNull(available2); assertNotNull(available3); assertThat(available.size(), is(2)); assertThat(available2.size(), is(2)); assertThat(available3.size(), is(1)); assertThat(available3.get(0), is("abc@gmail.com")); }
@RequestMapping(value = "/emails/available/", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody public List<String> getAvailableMails(@RequestParam("autoComplete") String autoComplete, @RequestParam("term") String partialAddress) { List<String> availableAddress = new ArrayList<>(); if ("subject".equals(autoComplete) && emailCredentials(EmailRolesConstants.DETAILED_EMAIL_LOGS)) { availableAddress = getAllFromAddressContaining(partialAddress); List<String> availableAddress2 = getAllToAddressContaining(partialAddress); for (String address : availableAddress2) { if (!availableAddress.contains(address)) { availableAddress.add(address); } } } return availableAddress; }
EmailController { @RequestMapping(value = "/emails/available/", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody public List<String> getAvailableMails(@RequestParam("autoComplete") String autoComplete, @RequestParam("term") String partialAddress) { List<String> availableAddress = new ArrayList<>(); if ("subject".equals(autoComplete) && emailCredentials(EmailRolesConstants.DETAILED_EMAIL_LOGS)) { availableAddress = getAllFromAddressContaining(partialAddress); List<String> availableAddress2 = getAllToAddressContaining(partialAddress); for (String address : availableAddress2) { if (!availableAddress.contains(address)) { availableAddress.add(address); } } } return availableAddress; } }
EmailController { @RequestMapping(value = "/emails/available/", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody public List<String> getAvailableMails(@RequestParam("autoComplete") String autoComplete, @RequestParam("term") String partialAddress) { List<String> availableAddress = new ArrayList<>(); if ("subject".equals(autoComplete) && emailCredentials(EmailRolesConstants.DETAILED_EMAIL_LOGS)) { availableAddress = getAllFromAddressContaining(partialAddress); List<String> availableAddress2 = getAllToAddressContaining(partialAddress); for (String address : availableAddress2) { if (!availableAddress.contains(address)) { availableAddress.add(address); } } } return availableAddress; }  }
EmailController { @RequestMapping(value = "/emails/available/", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody public List<String> getAvailableMails(@RequestParam("autoComplete") String autoComplete, @RequestParam("term") String partialAddress) { List<String> availableAddress = new ArrayList<>(); if ("subject".equals(autoComplete) && emailCredentials(EmailRolesConstants.DETAILED_EMAIL_LOGS)) { availableAddress = getAllFromAddressContaining(partialAddress); List<String> availableAddress2 = getAllToAddressContaining(partialAddress); for (String address : availableAddress2) { if (!availableAddress.contains(address)) { availableAddress.add(address); } } } return availableAddress; }  @RequestMapping(value = "/emails", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody EmailRecords<? extends BasicEmailRecordDto> getEmails(GridSettings filter, HttpServletRequest request); @RequestMapping(value = "/emails/{mailid}", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody EmailRecords<EmailRecordDto> getEmail(@PathVariable int mailid); @RequestMapping(value = "/emails/months/", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody List<String> getAvailableMonths(); @RequestMapping(value = "/emails/export", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) void exportEmailLog(@RequestParam("range") String range,
                               @RequestParam(value = "month", required = false) String month,
                               HttpServletResponse response,
                               HttpServletRequest request); @RequestMapping(value = "/emails/available/", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody List<String> getAvailableMails(@RequestParam("autoComplete") String autoComplete,
                                          @RequestParam("term") String partialAddress); }
EmailController { @RequestMapping(value = "/emails/available/", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody public List<String> getAvailableMails(@RequestParam("autoComplete") String autoComplete, @RequestParam("term") String partialAddress) { List<String> availableAddress = new ArrayList<>(); if ("subject".equals(autoComplete) && emailCredentials(EmailRolesConstants.DETAILED_EMAIL_LOGS)) { availableAddress = getAllFromAddressContaining(partialAddress); List<String> availableAddress2 = getAllToAddressContaining(partialAddress); for (String address : availableAddress2) { if (!availableAddress.contains(address)) { availableAddress.add(address); } } } return availableAddress; }  @RequestMapping(value = "/emails", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody EmailRecords<? extends BasicEmailRecordDto> getEmails(GridSettings filter, HttpServletRequest request); @RequestMapping(value = "/emails/{mailid}", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody EmailRecords<EmailRecordDto> getEmail(@PathVariable int mailid); @RequestMapping(value = "/emails/months/", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody List<String> getAvailableMonths(); @RequestMapping(value = "/emails/export", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) void exportEmailLog(@RequestParam("range") String range,
                               @RequestParam(value = "month", required = false) String month,
                               HttpServletResponse response,
                               HttpServletRequest request); @RequestMapping(value = "/emails/available/", method = RequestMethod.GET) @PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE) @ResponseBody List<String> getAvailableMails(@RequestParam("autoComplete") String autoComplete,
                                          @RequestParam("term") String partialAddress);  }