### Question:
ItemOperationsHandler extends WbxmlRequestHandler { @VisibleForTesting void sendResponse(Responder responder, Document document, ItemOperationsResponse response, boolean isGzip, boolean isMultipart) { if (isMultipart && response.hasFileReference()) { responder.sendMSSyncMultipartResponse(NAMESPACE, document, Arrays.asList(response.getAttachmentData()), isGzip); } else { responder.sendWBXMLResponse(NAMESPACE, document); } } @Inject protected  ItemOperationsHandler(IContentsImporter contentsImporter,
			IContentsExporter contentsExporter, ItemOperationsProtocol.Factory protocolFactory,
			WBXMLTools wbxmlTools, MailBackend mailBackend, 
			DOMDumper domDumper, FolderSnapshotDao folderSnapshotDao); @Override void process(IContinuation continuation, UserDataRequest udr,
			Document doc, ActiveSyncRequest request, Responder responder);  }### Answer:
@Test public void testSendResponseChooseMultipartIfMultipartAndFileReference() { Document document = DOMUtils.createDoc(null, "root"); boolean isMultipart = true; boolean isGzip = true; byte[] expectedData = new byte[]{1, 2, 3, 4}; FetchAttachmentResult fileReferenceFetch = new FetchAttachmentResult(); fileReferenceFetch.setAttch(expectedData); MailboxFetchResult mailboxFetchResult = new MailboxFetchResult(); mailboxFetchResult.setFetchAttachmentResult(fileReferenceFetch); ItemOperationsResponse response = new ItemOperationsResponse(); response.setMailboxFetchResult(mailboxFetchResult); Responder responder = createMock(Responder.class); responder.sendMSSyncMultipartResponse("ItemOperations", document, Lists.newArrayList(expectedData), true); expectLastCall(); replay(responder); itemOperationsHandler.sendResponse(responder, document, response, isGzip, isMultipart); verify(responder); }
@Test public void testSendResponseDoesntChooseMultipartIfMultipartButNoFileReference() { Document document = DOMUtils.createDoc(null, "root"); boolean isMultipart = true; boolean isGzip = true; MailboxFetchResult mailboxFetchResult = new MailboxFetchResult(); ItemOperationsResponse response = new ItemOperationsResponse(); response.setMailboxFetchResult(mailboxFetchResult); Responder responder = createMock(Responder.class); responder.sendWBXMLResponse("ItemOperations", document); expectLastCall(); replay(responder); itemOperationsHandler.sendResponse(responder, document, response, isGzip, isMultipart); verify(responder); }
@Test public void testSendResponseDoesntChooseMultipartIfNotMultipart() { Document document = DOMUtils.createDoc(null, "root"); boolean isMultipart = false; boolean isGzip = true; byte[] expectedData = new byte[]{1, 2, 3, 4}; FetchAttachmentResult fileReferenceFetch = new FetchAttachmentResult(); fileReferenceFetch.setAttch(expectedData); MailboxFetchResult mailboxFetchResult = new MailboxFetchResult(); mailboxFetchResult.setFetchAttachmentResult(fileReferenceFetch); ItemOperationsResponse response = new ItemOperationsResponse(); response.setMailboxFetchResult(mailboxFetchResult); Responder responder = createMock(Responder.class); responder.sendWBXMLResponse("ItemOperations", document); expectLastCall(); replay(responder); itemOperationsHandler.sendResponse(responder, document, response, isGzip, isMultipart); verify(responder); }