Examples of ODataService


Examples of org.apache.olingo.odata2.api.ODataService

      negotiateContentTypeCharset(final String requestType, final String supportedType, final boolean asFormat)
          throws SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException,
          ODataException {

    ODataServiceFactory factory = mock(ODataServiceFactory.class);
    ODataService service = Mockito.mock(ODataService.class);
    Dispatcher dispatcher = new Dispatcher(factory, service);

    UriInfoImpl uriInfo = new UriInfoImpl();
    uriInfo.setUriType(UriType.URI1); //
    if (asFormat) {
      uriInfo.setFormat(requestType);
    }

    Mockito.when(service.getSupportedContentTypes(Matchers.any(Class.class))).thenReturn(Arrays.asList(supportedType));
    EntitySetProcessor processor = Mockito.mock(EntitySetProcessor.class);
    ODataResponse response = Mockito.mock(ODataResponse.class);
    Mockito.when(response.getContentHeader()).thenReturn(supportedType);
    Mockito.when(processor.readEntitySet(uriInfo, supportedType)).thenReturn(response);
    Mockito.when(service.getEntitySetProcessor()).thenReturn(processor);

    InputStream content = null;
    ODataResponse odataResponse =
        dispatcher.dispatch(ODataHttpMethod.GET, uriInfo, content, requestType, supportedType);
    assertEquals(supportedType, odataResponse.getContentHeader());
View Full Code Here

Examples of org.apache.olingo.odata2.api.ODataService

public class AnnotationServiceFactoryImplTest {

  @Test
  public void createFromPackage() throws ODataException {
    AnnotationServiceFactoryImpl factory = new AnnotationServiceFactoryImpl();
    ODataService service = factory.createAnnotationService(Building.class.getPackage().getName());

    Assert.assertNotNull(service);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ODataService

    annotatedClasses.add(Employee.class);
    annotatedClasses.add(Manager.class);
    annotatedClasses.add(Photo.class);
    annotatedClasses.add(Room.class);
    annotatedClasses.add(Team.class);
    ODataService service = factory.createAnnotationService(annotatedClasses);

    Assert.assertNotNull(service);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ODataService

    AnnotationServiceFactoryImpl factory = new AnnotationServiceFactoryImpl();

    final Collection<Class<?>> notAnnotatedClasses = new ArrayList<Class<?>>();
    notAnnotatedClasses.add(String.class);
    notAnnotatedClasses.add(Long.class);
    ODataService service = factory.createAnnotationService(notAnnotatedClasses);

    Assert.assertNotNull(service);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ODataService

    request = ODataRequest.fromRequest(request).method(method).build();

    ODataContextImpl context = new ODataContextImpl(request, serviceFactory);
    context.setParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT, httpRequest);
   
    ODataService service = serviceFactory.createService(context);

    service.getProcessor().setContext(context);
    context.setService(service);

    ODataRequestHandler requestHandler = new ODataRequestHandler(serviceFactory, service, context);

    final ODataResponse odataResponse = requestHandler.handle(request);
View Full Code Here

Examples of org.apache.olingo.odata2.api.ODataService

public class AnnotationServiceFactoryImplTest {

  @Test
  public void createFromPackage() throws ODataException {
    AnnotationServiceFactoryImpl factory = new AnnotationServiceFactoryImpl();
    ODataService service = factory.createAnnotationService(Building.class.getPackage().getName());

    Assert.assertNotNull(service);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ODataService

    annotatedClasses.add(Employee.class);
    annotatedClasses.add(Manager.class);
    annotatedClasses.add(Photo.class);
    annotatedClasses.add(Room.class);
    annotatedClasses.add(Team.class);
    ODataService service = factory.createAnnotationService(annotatedClasses);

    Assert.assertNotNull(service);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ODataService

    AnnotationServiceFactoryImpl factory = new AnnotationServiceFactoryImpl();

    final Collection<Class<?>> notAnnotatedClasses = new ArrayList<Class<?>>();
    notAnnotatedClasses.add(String.class);
    notAnnotatedClasses.add(Long.class);
    ODataService service = factory.createAnnotationService(notAnnotatedClasses);

    Assert.assertNotNull(service);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ODataService

    String tmp[] = host.split(":", 2);
    String port = (tmp.length == 2 && tmp[1] != null) ? tmp[1] : "80";

    // access and validation in synchronized block
    synchronized (PORT_2_SERVICE) {
      final ODataService service = PORT_2_SERVICE.get(port);
      if (service == null) {
        throw new IllegalArgumentException("no static service set for JUnit test");
      }
      return service;
    }
View Full Code Here

Examples of org.apache.olingo.odata2.api.ODataService

    List<String> acceptHeaders = new ArrayList<String>(0);
    return mockODataRequest(method, pathSegments, queryParameters, acceptHeaders, requestContentType);
  }

  private ODataService mockODataService(final ODataServiceFactory serviceFactory) throws ODataException {
    ODataService service = DispatcherTest.getMockService();
    when(service.getEntityDataModel()).thenReturn(edm);
    when(service.getProcessor()).thenReturn(mock(ODataProcessor.class));
    when(serviceFactory.createService(any(ODataContext.class))).thenReturn(service);

    when(service.getSupportedContentTypes(BatchProcessor.class)).thenReturn(
        Arrays.asList(HttpContentType.MULTIPART_MIXED));

    when(service.getSupportedContentTypes(EntityProcessor.class)).thenReturn(Arrays.asList(
        HttpContentType.APPLICATION_ATOM_XML_ENTRY_UTF8,
        HttpContentType.APPLICATION_ATOM_XML_UTF8,
        HttpContentType.APPLICATION_JSON,
        HttpContentType.APPLICATION_JSON_VERBOSE,
        HttpContentType.APPLICATION_JSON_UTF8,
        HttpContentType.APPLICATION_JSON_UTF8_VERBOSE,
        HttpContentType.APPLICATION_XML_UTF8));

    final List<String> jsonAndXml = Arrays.asList(
        HttpContentType.APPLICATION_JSON,
        HttpContentType.APPLICATION_JSON_VERBOSE,
        HttpContentType.APPLICATION_JSON_UTF8,
        HttpContentType.APPLICATION_JSON_UTF8_VERBOSE,
        HttpContentType.APPLICATION_XML_UTF8);
    when(service.getSupportedContentTypes(FunctionImportProcessor.class)).thenReturn(jsonAndXml);
    when(service.getSupportedContentTypes(EntityLinkProcessor.class)).thenReturn(jsonAndXml);
    when(service.getSupportedContentTypes(EntityLinksProcessor.class)).thenReturn(jsonAndXml);
    when(service.getSupportedContentTypes(EntitySimplePropertyProcessor.class)).thenReturn(jsonAndXml);
    when(service.getSupportedContentTypes(EntityComplexPropertyProcessor.class)).thenReturn(jsonAndXml);

    final List<String> wildcard = Arrays.asList(HttpContentType.WILDCARD);
    when(service.getSupportedContentTypes(EntityMediaProcessor.class)).thenReturn(wildcard);
    when(service.getSupportedContentTypes(EntitySimplePropertyValueProcessor.class)).thenReturn(wildcard);
    when(service.getSupportedContentTypes(FunctionImportValueProcessor.class)).thenReturn(wildcard);

    when(service.getSupportedContentTypes(EntitySetProcessor.class)).thenReturn(Arrays.asList(
        HttpContentType.APPLICATION_ATOM_XML_FEED_UTF8,
        HttpContentType.APPLICATION_ATOM_XML_UTF8,
        HttpContentType.APPLICATION_JSON,
        HttpContentType.APPLICATION_JSON_VERBOSE,
        HttpContentType.APPLICATION_JSON_UTF8,
        HttpContentType.APPLICATION_JSON_UTF8_VERBOSE,
        HttpContentType.APPLICATION_XML_UTF8));

    when(service.getSupportedContentTypes(MetadataProcessor.class)).thenReturn(Arrays.asList(
        HttpContentType.APPLICATION_XML_UTF8));

    when(service.getSupportedContentTypes(ServiceDocumentProcessor.class)).thenReturn(Arrays.asList(
        HttpContentType.APPLICATION_ATOM_SVC_UTF8,
        HttpContentType.APPLICATION_JSON,
        HttpContentType.APPLICATION_JSON_VERBOSE,
        HttpContentType.APPLICATION_JSON_UTF8,
        HttpContentType.APPLICATION_JSON_UTF8_VERBOSE,
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.