@Test public void processShouldGetAnnotationsAndReturnCompleteResponseWithTheLongestEntryInfoWhenLimitMaxsize() throws Exception { when(mockMailboxManager.getAllAnnotations(inbox, mailboxSession)).thenReturn(ImmutableList.of(PRIVATE_ANNOTATION, SHARED_ANNOTATION, PRIVATE_GRANDCHILD_ANNOTATION)); processor.process(annotationRequestBuilder.maxsize(Optional.of(10)).build(), mockResponder, mockImapSession); verify(mockStatusResponseFactory, times(1)).taggedOk(any(String.class), any(ImapCommand.class), humanTextCaptor.capture(), captorResponsecode.capture()); verify(mockResponder, times(2)).respond(captorAnnotationResponse.capture()); verifyNoMoreInteractions(mockResponder); assertThat(humanTextCaptor.getAllValues()).containsOnly(HumanReadableText.COMPLETED); assertThat(captorResponsecode.getAllValues()).containsOnly(ResponseCode.longestMetadataEntry(22)); }
@Test public void responseCodeShouldBuildTheLongestEntryForMetadata() { assertThat(StatusResponse.ResponseCode.longestMetadataEntry(1024).getCode()).isEqualTo("METADATA LONGENTRIES"); assertThat(StatusResponse.ResponseCode.longestMetadataEntry(1024).getNumber()).isEqualTo(1024); } }
private void respond(String tag, ImapCommand command, Responder responder, String mailboxName, List<MailboxAnnotation> mailboxAnnotations, Optional<Integer> maxsize, Optional<Integer> maximumOversizedSize) { if (maximumOversizedSize.isPresent()) { responder.respond(new AnnotationResponse(mailboxName, filterItemsBySize(mailboxAnnotations, maxsize))); okComplete(command, tag, ResponseCode.longestMetadataEntry(maximumOversizedSize.get()), responder); } else { responder.respond(new AnnotationResponse(mailboxName, mailboxAnnotations)); okComplete(command, tag, responder); } }