ODataBatchParser extends AbstractParser { @Override protected Object processEntity(String bodyText) throws ODataException { return new ODataBatchRequestParser().parseBatch(bodyText); } ODataBatchParser(ODataRequestContext request, ODataParser uriParser);   }
@Test public void testSimpleBatch() throws Exception { requestBuilder.setUri(odataUri.serviceRoot() + "/$batch").setMethod(ODataRequest.Method.POST); preparePostRequestContext(REQUEST_ENTITY_PATH); ODataBatchParser parser = new ODataBatchParser(context, new ODataParserImpl()); ODataBatchRequestContent batchRequestContent = (ODataBatchRequestContent) parser.processEntity( context.getRequest().getBodyText(StandardCharsets.UTF_8.name())); List<ODataRequestComponent> batchRequestComponents = Lists.newArrayList( JavaConverters.asJavaCollection(batchRequestContent.requestComponents())); assertFalse(batchRequestComponents.isEmpty()); assertEquals(1, batchRequestComponents.size()); assertTrue(batchRequestComponents.get(0) instanceof BatchRequestComponent); BatchRequestComponent batchRequestComponent = (BatchRequestComponent) batchRequestComponents.get(0); Map<String, String> batchRequestComponentHeaders = JavaConverters.mapAsJavaMap( batchRequestComponent.getHeaders().headers()); assertEquals(2, batchRequestComponentHeaders.size()); assertEquals("localhost", batchRequestComponentHeaders.get("Host")); assertEquals("binary", batchRequestComponentHeaders.get("Content-Transfer-Encoding")); Map<String, String> batchRequestComponentDetails = JavaConverters.mapAsJavaMap( batchRequestComponent.getRequestDetails()); assertEquals(4, batchRequestComponentDetails.size()); assertEquals("GET", batchRequestComponentDetails.get("RequestType")); assertEquals("Customers('ALFKI')", batchRequestComponentDetails.get("RequestEntity")); assertEquals("/service/", batchRequestComponentDetails.get("RelativePath")); assertEquals("", batchRequestComponentDetails.get("RequestBody")); }