### Question:
MailProtocol { public MailRequest getRequest(ActiveSyncRequest request) throws IOException, QuotaExceededException { CollectionId collectionId = request.<CollectionId>getParameter("CollectionId"); ServerId serverId = request.<ServerId>getParameter("ItemId"); byte[] mailContent = streamBytes(request.getInputStream()); return new MailRequest(collectionId, serverId, getSaveInSentParameter(request) , mailContent); } @Inject  MailProtocol(OpushEmailConfiguration emailConfiguration); MailRequest getRequest(ActiveSyncRequest request); Document encodeErrorResponse(String namespace, MailRequestStatus requestStatus); SendEmailSyncRequest encodeRequest(MailRequest request);  }### Answer:
@Test public void testWithBigMessageMaxSize() throws IOException, QuotaExceededException { OpushEmailConfiguration emailConfiguration = createMock(OpushEmailConfiguration.class); ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getParameter("CollectionId")).andReturn(CollectionId.of(1)).once(); expect(request.getParameter("ItemId")).andReturn(CollectionId.of(1).serverId(1)).once(); expect(request.getInputStream()).andReturn(loadDataFile("bigEml.eml")).once(); expect(request.getParameter("SaveInSent")).andReturn("T").once(); expect(emailConfiguration.getMessageMaxSize()).andReturn(10485760).once(); replay(request, emailConfiguration); MailProtocol mailProtocol = new MailProtocol(emailConfiguration); mailProtocol.getRequest(request); verify(request, emailConfiguration); }
@Test(expected=QuotaExceededException.class) public void testWithSmallMessageMaxSize() throws IOException, QuotaExceededException { OpushEmailConfiguration emailConfiguration = createMock(OpushEmailConfiguration.class); ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getParameter("CollectionId")).andReturn(CollectionId.of(1)).once(); expect(request.getParameter("ItemId")).andReturn(CollectionId.of(1).serverId(1)).once(); expect(request.getInputStream()).andReturn(loadDataFile("bigEml.eml")).once(); expect(request.getParameter("SaveInSent")).andReturn("T").once(); expect(emailConfiguration.getMessageMaxSize()).andReturn(1024).once(); replay(request, emailConfiguration); MailProtocol mailProtocol = new MailProtocol(emailConfiguration); mailProtocol.getRequest(request); verify(request, emailConfiguration); }