### Question:
ItemOperationsHandler extends WbxmlRequestHandler { @VisibleForTesting static boolean isAcceptMultipart(ActiveSyncRequest request) { return "T".equals(request.getHeader("MS-ASAcceptMultiPart")) || "T".equalsIgnoreCase(request.<String>getParameter("AcceptMultiPart")); } @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 testMSAcceptMultipartWhenExpectedValue() { ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getHeader("MS-ASAcceptMultiPart")).andReturn("T").anyTimes(); expect(request.getParameter("AcceptMultiPart")).andReturn(null).anyTimes(); replay(request); assertThat(ItemOperationsHandler.isAcceptMultipart(request)).isTrue(); verify(request); }
@Test public void testMSAcceptMultipartWhenTrue() { ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getHeader("MS-ASAcceptMultiPart")).andReturn("true").anyTimes(); expect(request.getParameter("AcceptMultiPart")).andReturn(null).anyTimes(); replay(request); assertThat(ItemOperationsHandler.isAcceptMultipart(request)).isFalse(); verify(request); }
@Test public void testMSAcceptMultipartWhenNull() { ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getHeader("MS-ASAcceptMultiPart")).andReturn(null).anyTimes(); expect(request.getParameter("AcceptMultiPart")).andReturn(null).anyTimes(); replay(request); assertThat(ItemOperationsHandler.isAcceptMultipart(request)).isFalse(); verify(request); }
@Test public void testMSAcceptMultipartWhenEmpty() { ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getHeader("MS-ASAcceptMultiPart")).andReturn("").anyTimes(); expect(request.getParameter("AcceptMultiPart")).andReturn(null).anyTimes(); replay(request); assertThat(ItemOperationsHandler.isAcceptMultipart(request)).isFalse(); verify(request); }
@Test public void testAcceptMultipartWhenExpectedValue() { ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getHeader("MS-ASAcceptMultiPart")).andReturn(null).anyTimes(); expect(request.getParameter("AcceptMultiPart")).andReturn("T").anyTimes(); replay(request); assertThat(ItemOperationsHandler.isAcceptMultipart(request)).isTrue(); verify(request); }
@Test public void testAcceptMultipartWhenTrue() { ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getHeader("MS-ASAcceptMultiPart")).andReturn(null).anyTimes(); expect(request.getParameter("AcceptMultiPart")).andReturn("true").anyTimes(); replay(request); assertThat(ItemOperationsHandler.isAcceptMultipart(request)).isFalse(); verify(request); }
@Test public void testAcceptMultipartWhenNull() { ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getHeader("MS-ASAcceptMultiPart")).andReturn(null).anyTimes(); expect(request.getParameter("AcceptMultiPart")).andReturn(null).anyTimes(); replay(request); assertThat(ItemOperationsHandler.isAcceptMultipart(request)).isFalse(); verify(request); }
@Test public void testAcceptMultipartWhenEmpty() { ActiveSyncRequest request = createMock(ActiveSyncRequest.class); expect(request.getHeader("MS-ASAcceptMultiPart")).andReturn(null).anyTimes(); expect(request.getParameter("AcceptMultiPart")).andReturn("").anyTimes(); replay(request); assertThat(ItemOperationsHandler.isAcceptMultipart(request)).isFalse(); verify(request); }