@Test public void testGetMessageThrowsFolderNotFoundException() throws Exception { PowerMockito.mockStatic(SSLUtils.class); when(SSLUtils.createMessageStore(any(GetMailInput.class))).thenReturn(storeMock); doReturn(folderMock).when(storeMock).getFolder(anyString()); doReturn(false).when(folderMock).exists(); serviceSpy.input = inputBuilder.build(); exception.expect(Exception.class); exception.expectMessage(ExceptionMsgs.THE_SPECIFIED_FOLDER_DOES_NOT_EXIST_ON_THE_REMOTE_SERVER); serviceSpy.getMessage(); }
protected Message getMessage() throws Exception { store = SSLUtils.createMessageStore(input); Folder folder = store.getFolder(input.getFolder()); if (!folder.exists()) { throw new Exception(ExceptionMsgs.THE_SPECIFIED_FOLDER_DOES_NOT_EXIST_ON_THE_REMOTE_SERVER); } folder.open(getFolderOpenMode()); if (input.getMessageNumber() > folder.getMessageCount()) { throw new IndexOutOfBoundsException("message value was: " + input.getMessageNumber() + " there are only " + folder.getMessageCount() + ExceptionMsgs.COUNT_MESSAGES_IN_FOLDER_ERROR_MESSAGE); } return folder.getMessage(input.getMessageNumber()); }
GetMailMessageService { protected Message getMessage() throws Exception { store = SSLUtils.createMessageStore(input); Folder folder = store.getFolder(input.getFolder()); if (!folder.exists()) { throw new Exception(ExceptionMsgs.THE_SPECIFIED_FOLDER_DOES_NOT_EXIST_ON_THE_REMOTE_SERVER); } folder.open(getFolderOpenMode()); if (input.getMessageNumber() > folder.getMessageCount()) { throw new IndexOutOfBoundsException("message value was: " + input.getMessageNumber() + " there are only " + folder.getMessageCount() + ExceptionMsgs.COUNT_MESSAGES_IN_FOLDER_ERROR_MESSAGE); } return folder.getMessage(input.getMessageNumber()); } }
GetMailMessageService { protected Message getMessage() throws Exception { store = SSLUtils.createMessageStore(input); Folder folder = store.getFolder(input.getFolder()); if (!folder.exists()) { throw new Exception(ExceptionMsgs.THE_SPECIFIED_FOLDER_DOES_NOT_EXIST_ON_THE_REMOTE_SERVER); } folder.open(getFolderOpenMode()); if (input.getMessageNumber() > folder.getMessageCount()) { throw new IndexOutOfBoundsException("message value was: " + input.getMessageNumber() + " there are only " + folder.getMessageCount() + ExceptionMsgs.COUNT_MESSAGES_IN_FOLDER_ERROR_MESSAGE); } return folder.getMessage(input.getMessageNumber()); }  }
GetMailMessageService { protected Message getMessage() throws Exception { store = SSLUtils.createMessageStore(input); Folder folder = store.getFolder(input.getFolder()); if (!folder.exists()) { throw new Exception(ExceptionMsgs.THE_SPECIFIED_FOLDER_DOES_NOT_EXIST_ON_THE_REMOTE_SERVER); } folder.open(getFolderOpenMode()); if (input.getMessageNumber() > folder.getMessageCount()) { throw new IndexOutOfBoundsException("message value was: " + input.getMessageNumber() + " there are only " + folder.getMessageCount() + ExceptionMsgs.COUNT_MESSAGES_IN_FOLDER_ERROR_MESSAGE); } return folder.getMessage(input.getMessageNumber()); }  Map<String, String> execute(GetMailMessageInput getMailMessageInput); }
GetMailMessageService { protected Message getMessage() throws Exception { store = SSLUtils.createMessageStore(input); Folder folder = store.getFolder(input.getFolder()); if (!folder.exists()) { throw new Exception(ExceptionMsgs.THE_SPECIFIED_FOLDER_DOES_NOT_EXIST_ON_THE_REMOTE_SERVER); } folder.open(getFolderOpenMode()); if (input.getMessageNumber() > folder.getMessageCount()) { throw new IndexOutOfBoundsException("message value was: " + input.getMessageNumber() + " there are only " + folder.getMessageCount() + ExceptionMsgs.COUNT_MESSAGES_IN_FOLDER_ERROR_MESSAGE); } return folder.getMessage(input.getMessageNumber()); }  Map<String, String> execute(GetMailMessageInput getMailMessageInput);  }