@Test public void changeSetODataContentResponse() throws Exception { List<ODataResponsePart> parts = new ArrayList<ODataResponsePart>(); ServiceMetadata serviceMetadata = mock(ServiceMetadata.class); final EdmEntityType edmEntityType = mock(EdmEntityType.class); EntityIterator entityCollection = new EntityIterator() { @Override public Entity next() { return null; } @Override public boolean hasNext() { return false; } }; SerializerStreamResult serializerResult = OData.newInstance(). createSerializer(ContentType.APPLICATION_JSON).entityCollectionStreamed( serviceMetadata, edmEntityType, entityCollection, EntityCollectionSerializerOptions.with().contextURL (ContextURL.with().oDataPath("http: ODataResponse response = new ODataResponse(); response.setODataContent(serializerResult.getODataContent()); response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode()); response.setHeader(HttpHeader.CONTENT_ID, "1"); parts.add(new ODataResponsePart(response, true)); BatchResponseSerializer serializer = new BatchResponseSerializer(); final InputStream content = serializer.serialize(parts, BOUNDARY); assertNotNull(content); final BatchLineReader reader = new BatchLineReader(content); final List<String> body = reader.toList(); reader.close(); int line = 0; assertEquals(14, body.size()); assertEquals("--" + BOUNDARY + CRLF, body.get(line++)); assertTrue(body.get(line++).startsWith("Content-Type: multipart/mixed; boundary=changeset_")); assertEquals(CRLF, body.get(line++)); assertTrue(body.get(line++).startsWith("--changeset_")); assertEquals("Content-Type: application/http" + CRLF, body.get(line++)); assertEquals("Content-Transfer-Encoding: binary" + CRLF, body.get(line++)); assertEquals("Content-ID: 1" + CRLF, body.get(line++)); assertEquals(CRLF, body.get(line++)); assertEquals("HTTP/1.1 204 No Content" + CRLF, body.get(line++)); assertEquals("Content-Length: 47" + CRLF, body.get(line++)); assertEquals(CRLF, body.get(line++)); assertEquals("{\"@odata.context\":\"../../$metadata\",\"value\":[]}" + CRLF, body.get(line++)); assertTrue(body.get(line++).startsWith("--changeset_")); assertEquals("--" + BOUNDARY + "--" + CRLF, body.get(line++)); }
public InputStream serialize(final List<ODataResponsePart> responses, final String boundary) throws BatchSerializerException { BodyBuilder builder = createBody(responses, boundary); return new ByteArrayInputStream(builder.getContent()); }
BatchResponseSerializer { public InputStream serialize(final List<ODataResponsePart> responses, final String boundary) throws BatchSerializerException { BodyBuilder builder = createBody(responses, boundary); return new ByteArrayInputStream(builder.getContent()); } }
BatchResponseSerializer { public InputStream serialize(final List<ODataResponsePart> responses, final String boundary) throws BatchSerializerException { BodyBuilder builder = createBody(responses, boundary); return new ByteArrayInputStream(builder.getContent()); }  }
BatchResponseSerializer { public InputStream serialize(final List<ODataResponsePart> responses, final String boundary) throws BatchSerializerException { BodyBuilder builder = createBody(responses, boundary); return new ByteArrayInputStream(builder.getContent()); }  InputStream serialize(final List<ODataResponsePart> responses, final String boundary); }
BatchResponseSerializer { public InputStream serialize(final List<ODataResponsePart> responses, final String boundary) throws BatchSerializerException { BodyBuilder builder = createBody(responses, boundary); return new ByteArrayInputStream(builder.getContent()); }  InputStream serialize(final List<ODataResponsePart> responses, final String boundary);  }