Examples of ODataRequest


Examples of org.apache.olingo.odata2.api.processor.ODataRequest

      pathInfo.setRequestUri(new URI(newRequestUri));
      pathInfo.setODataPathSegment(modifiedODataSegments);
    } catch (URISyntaxException e) {
      throw new ODataException(e);
    }
    ODataRequest modifiedRequest = ODataRequest.fromRequest(request).pathInfo(pathInfo).build();
    return modifiedRequest;
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataRequest

    }
  }

  @Override
  public String getRequestHeader(final String name) {
    ODataRequest request = (ODataRequest) parameterTable.get(ODATA_REQUEST);
    return request.getRequestHeaderValue(name);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataRequest

    return request.getRequestHeaderValue(name);
  }

  @Override
  public Map<String, List<String>> getRequestHeaders() {
    ODataRequest request = (ODataRequest) parameterTable.get(ODATA_REQUEST);
    return request.getRequestHeaders();
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataRequest

      final ODataHttpMethod method,
      final List<String> pathSegments,
      final Map<String, String> queryParameters,
      final List<String> acceptHeaders,
      final String requestContentType) throws ODataException {
    ODataRequest request = mock(ODataRequest.class);
    when(request.getMethod()).thenReturn(method);
    PathInfo pathInfo = mock(PathInfo.class);
    List<PathSegment> segments = new ArrayList<PathSegment>();
    for (final String pathSegment : pathSegments) {
      PathSegment segment = mock(PathSegment.class);
      when(segment.getPath()).thenReturn(pathSegment);
      segments.add(segment);
    }
    when(pathInfo.getODataSegments()).thenReturn(segments);
    when(request.getPathInfo()).thenReturn(pathInfo);
    when(request.getQueryParameters())
        .thenReturn(queryParameters == null ? new HashMap<String, String>() : queryParameters);
    when(request.getContentType()).thenReturn(requestContentType);
    when(request.getAcceptHeaders()).thenReturn(acceptHeaders);
    String acceptHeadersAsString = null;
    for (String string : acceptHeaders) {
      if (acceptHeadersAsString == null) {
        acceptHeadersAsString = string;
      } else {
        acceptHeadersAsString += ", " + string;
      }
    }
    when(request.getRequestHeaderValue("Accept")).thenReturn(acceptHeadersAsString);
    return request;
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataRequest

      final String requestContentType) throws ODataException {
    ODataServiceFactory serviceFactory = mock(ODataServiceFactory.class);
    final ODataService service = mockODataService(serviceFactory);
    when(serviceFactory.createService(any(ODataContext.class))).thenReturn(service);

    final ODataRequest request = mockODataRequest(method, pathSegments, queryParameters, requestContentType);
    final ODataContextImpl context = new ODataContextImpl(request, serviceFactory);

    return new ODataRequestHandler(serviceFactory, service, context).handle(request);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataRequest

    ODataServiceFactory serviceFactory = mock(ODataServiceFactory.class);
    final ODataService service = mockODataService(serviceFactory);
    when(serviceFactory.createService(any(ODataContext.class))).thenReturn(service);

    final ODataRequest request =
        mockODataRequest(method, pathSegments, queryParameters, acceptHeaders, requestContentType);
    final ODataContextImpl context = new ODataContextImpl(request, serviceFactory);

    final ODataResponse response = new ODataRequestHandler(serviceFactory, service, context).handle(request);
    assertNotNull(response);
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataRequest

  public void dataServiceVersion() throws Exception {
    ODataServiceFactory serviceFactory = mock(ODataServiceFactory.class);
    final ODataService service = mockODataService(serviceFactory);
    when(serviceFactory.createService(any(ODataContext.class))).thenReturn(service);

    ODataRequest request =
        mockODataRequest(ODataHttpMethod.GET, createPathSegments(UriType.URI0, false, false), null, null);
    ODataContextImpl context = new ODataContextImpl(request, serviceFactory);

    final ODataRequestHandler handler = new ODataRequestHandler(serviceFactory, service, context);

    when(request.getRequestHeaderValue(ODataHttpHeaders.DATASERVICEVERSION)).thenReturn("1.0");
    ODataResponse response = handler.handle(request);
    assertEquals(HttpStatusCodes.PAYMENT_REQUIRED, response.getStatus());

    when(request.getRequestHeaderValue(ODataHttpHeaders.DATASERVICEVERSION)).thenReturn("2.0");
    response = handler.handle(request);
    assertEquals(HttpStatusCodes.PAYMENT_REQUIRED, response.getStatus());

    when(request.getRequestHeaderValue(ODataHttpHeaders.DATASERVICEVERSION)).thenReturn("3.0");
    response = handler.handle(request);
    assertEquals(HttpStatusCodes.BAD_REQUEST, response.getStatus());

    when(request.getRequestHeaderValue(ODataHttpHeaders.DATASERVICEVERSION)).thenReturn("4.2");
    response = handler.handle(request);
    assertEquals(HttpStatusCodes.BAD_REQUEST, response.getStatus());

    when(request.getRequestHeaderValue(ODataHttpHeaders.DATASERVICEVERSION)).thenReturn("42");
    response = handler.handle(request);
    assertEquals(HttpStatusCodes.BAD_REQUEST, response.getStatus());

    when(request.getRequestHeaderValue(ODataHttpHeaders.DATASERVICEVERSION)).thenReturn("test.2.0");
    response = handler.handle(request);
    assertEquals(HttpStatusCodes.BAD_REQUEST, response.getStatus());
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataRequest

    }
  }

  @Override
  public String getRequestHeader(final String name) {
    ODataRequest request = (ODataRequest) parameterTable.get(ODATA_REQUEST);
    return request.getRequestHeaderValue(name);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.processor.ODataRequest

    return request.getRequestHeaderValue(name);
  }

  @Override
  public Map<String, List<String>> getRequestHeaders() {
    ODataRequest request = (ODataRequest) parameterTable.get(ODATA_REQUEST);
    return request.getRequestHeaders();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.