@Test
  public void invalidAbsoluteUri() throws URISyntaxException {
    final ODataBatchRequest request =
        getClient().getBatchRequestFactory().getBatchRequest(SERVICE_URI);

    final BatchManager payload = request.payloadManager();
    final URI uri = new URI(SERVICE_URI + "../ESAllPrim(32767)");
    final ODataEntityRequest<ClientEntity> queryReq =
        getClient().getRetrieveRequestFactory().getEntityRequest(uri);
    queryReq.setFormat(ContentType.JSON);
    payload.addRequest(queryReq);

    // Fetch result
    final ODataBatchResponse response = payload.getResponse();
    assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());

    final Iterator<ODataBatchResponseItem> bodyIterator = response.getBody();
    assertTrue(bodyIterator.hasNext());

    ODataBatchResponseItem item = bodyIterator.next();
    assertFalse(item.isChangeset());

    final ODataResponse oDataResponse = item.next();
    assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), oDataResponse.getStatusCode());
  }
  private void appendGetRequest(
      final BatchManager manager, final String segment, final Object key, final boolean isRelative)
      throws URISyntaxException {
    final URIBuilder targetURI = getClient().newURIBuilder(SERVICE_URI);
    targetURI.appendEntitySetSegment(segment).appendKeySegment(key);
    final URI uri =
        (isRelative) ? new URI(SERVICE_URI).relativize(targetURI.build()) : targetURI.build();

    ODataEntityRequest<ClientEntity> queryReq =
        getClient().getRetrieveRequestFactory().getEntityRequest(uri);
    queryReq.setFormat(ContentType.JSON);
    manager.addRequest(queryReq);
  }
  @Test(expected = HttpClientException.class)
  public void invalidAbsoluteRequest() throws URISyntaxException {
    final ODataBatchRequest request =
        getClient().getBatchRequestFactory().getBatchRequest(SERVICE_URI);

    final BatchManager payload = request.payloadManager();
    final URI uri = new URI("/ESAllPrim(32767)");
    final ODataEntityRequest<ClientEntity> queryReq =
        getClient().getRetrieveRequestFactory().getEntityRequest(uri);
    queryReq.setFormat(ContentType.JSON);
    payload.addRequest(queryReq);

    // Fetch result
    payload.getResponse();
  }