SetQuotaCommandParser extends AbstractImapCommandParser { @Override protected ImapMessage decode(ImapRequestLineReader request, Tag tag, ImapSession session) throws DecodingException { final String quotaRoot = request.atom(); SetQuotaRequest setQuotaRequest = new SetQuotaRequest(tag, quotaRoot); request.nextWordChar(); while (request.nextChar() == '(') { request.consume(); String resource = request.atom(); request.nextWordChar(); long limit = request.number(true); request.nextWordChar(); request.consumeChar(')'); setQuotaRequest.addResourceLimit(resource, limit); while (request.nextChar() == ' ') { request.consume(); } } request.eol(); return setQuotaRequest; } SetQuotaCommandParser(StatusResponseFactory statusResponseFactory);   }
@Test public void testQuotaParsing() throws DecodingException { SetQuotaCommandParser parser = new SetQuotaCommandParser(mock(StatusResponseFactory.class)); String commandString = "quotaRoot (STORAGE 512) ( MESSAGE 1024 ) \n"; InputStream inputStream = new ByteArrayInputStream(commandString.getBytes()); ImapRequestStreamLineReader lineReader = new ImapRequestStreamLineReader(inputStream, null); SetQuotaRequest request = (SetQuotaRequest) parser.decode(lineReader, TAG, null); assertThat(request.getQuotaRoot()).isEqualTo("quotaRoot"); List<SetQuotaRequest.ResourceLimit> list = request.getResourceLimits(); assertThat(list.get(0).getResource()).isEqualTo("STORAGE"); assertThat(list.get(0).getLimit()).isEqualTo(512); assertThat(list.get(1).getResource()).isEqualTo("MESSAGE"); assertThat(list.get(1).getLimit()).isEqualTo(1024); assertThat(list.size()).isEqualTo(2); }