/** * Sets up a response with a single message */ private void setUpSingleMessageResponse() throws IOException { messageListResponse = new ListMessagesResponse() .setMessages(Collections.singletonList(INITIAL_MESSAGE)); when(messageListRequest.execute()).thenReturn(messageListResponse); when(get.execute()).thenReturn(FULL_MESSAGE); } }
inOrder.verify(get).execute();
try { getResponse = gmail.users().messages().get(USER, listMessage.getId()).setFormat("raw").execute(); } catch (IOException e) { return new ExportResult<>(e);
.execute(); LOGGER.fine("==Fetched message "+fetched.getId()); HashMap<String, MessagePart> toDownload = new HashMap<>();
/** * Retrieves the registration key among the unread emails * with {@code courseId} and {@code courseName} sent to the Gmail inbox. * * <p>After retrieving, marks the email as read. * * <p>If multiple emails of the same course are in the inbox, return the registration key presented in one of them. * * @return registration key (null if cannot be found). */ public String getRegistrationKeyFromUnreadEmails(String courseName, String courseId) throws IOException, MessagingException { List<Message> messageStubs = getListOfUnreadEmailOfUser(); for (Message messageStub : messageStubs) { Message message = service.users().messages().get(username, messageStub.getId()).setFormat("raw") .execute(); MimeMessage email = convertFromMessageToMimeMessage(message); if (isStudentCourseJoinRegistrationEmail(email, courseName, courseId)) { String body = getTextFromEmail(email); markMessageAsRead(messageStub); return getKey(body); } } return null; }