Package org.apache.olingo.odata2.core.ep

Examples of org.apache.olingo.odata2.core.ep.JsonEntityProvider


    Map<String, ExpandSelectTreeNode> links = new HashMap<String, ExpandSelectTreeNode>();
    links.put("nb_Rooms", node2);
    ExpandSelectTreeNode node1 = Mockito.mock(ExpandSelectTreeNode.class);
    Mockito.when(node1.getLinks()).thenReturn(links);

    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, buildingData,
        EntityProviderWriteProperties.serviceRoot(URI.create(BASE_URI)).expandSelectTree(node1).build());
    final String json = verifyResponse(response);
    assertEquals("{\"d\":{\"__metadata\":{\"id\":\"" + BASE_URI + "Buildings('1')\","
        + "\"uri\":\"" + BASE_URI + "Buildings('1')\",\"type\":\"RefScenario.Building\"},"
        + "\"nb_Rooms\":{\"__deferred\":{\"uri\":\"" + BASE_URI + "Buildings('1')/nb_Rooms\"}}}}",
View Full Code Here


    Mockito.when(node1.getLinks()).thenReturn(links);

    Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
    callbacks.put("nb_Rooms", null);

    new JsonEntityProvider().writeEntry(entitySet, buildingData,
        EntityProviderWriteProperties.serviceRoot(URI.create(BASE_URI)).expandSelectTree(node1).callbacks(callbacks)
            .build());
  }
View Full Code Here

    EdmEntitySet employeesSet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
    EdmMapping mapping = employeesSet.getEntityType().getMapping();
    when(mapping.getMediaResourceSourceKey()).thenReturn(mediaResourceSourceKey);

    ODataResponse response = new JsonEntityProvider().writeEntry(employeesSet, employeeData, DEFAULT_PROPERTIES);
    String jsonString = verifyResponse(response);
    Gson gson = new Gson();
    StringMap<Object> jsonMap = gson.fromJson(jsonString, StringMap.class);
    jsonMap = (StringMap<Object>) jsonMap.get("d");
    jsonMap = (StringMap<Object>) jsonMap.get("__metadata");
View Full Code Here

    EdmMapping mapping = employeesSet.getEntityType().getMapping();
    when(mapping.getMediaResourceSourceKey()).thenReturn(mediaResourceSourceKey);
    when(mapping.getMediaResourceMimeTypeKey()).thenReturn(mediaResourceMimeTypeKey);
    when(mapping.getMimeType()).thenReturn(null);

    ODataResponse response = new JsonEntityProvider().writeEntry(employeesSet, employeeData, DEFAULT_PROPERTIES);
    String jsonString = verifyResponse(response);

    Gson gson = new Gson();
    StringMap<Object> jsonMap = gson.fromJson(jsonString, StringMap.class);
    jsonMap = (StringMap<Object>) jsonMap.get("d");
View Full Code Here

    EdmEntityType roomType = roomsSet.getEntityType();
    EdmMapping mapping = mock(EdmMapping.class);
    when(roomType.getMapping()).thenReturn(mapping);
    when(mapping.getMediaResourceSourceKey()).thenReturn(mediaResourceSourceKey);

    ODataResponse response = new JsonEntityProvider().writeEntry(roomsSet, roomData, DEFAULT_PROPERTIES);
    String jsonString = verifyResponse(response);
    Gson gson = new Gson();
    StringMap<Object> jsonMap = gson.fromJson(jsonString, StringMap.class);
    jsonMap = (StringMap<Object>) jsonMap.get("d");
    jsonMap = (StringMap<Object>) jsonMap.get("__metadata");
View Full Code Here

    EdmMapping mapping = mock(EdmMapping.class);
    when(roomType.getMapping()).thenReturn(mapping);
    when(mapping.getMediaResourceSourceKey()).thenReturn(mediaResourceSourceKey);
    when(mapping.getMediaResourceMimeTypeKey()).thenReturn(mediaResourceMimeTypeKey);

    ODataResponse response = new JsonEntityProvider().writeEntry(roomsSet, roomData, DEFAULT_PROPERTIES);
    String jsonString = verifyResponse(response);
    Gson gson = new Gson();
    StringMap<Object> jsonMap = gson.fromJson(jsonString, StringMap.class);
    jsonMap = (StringMap<Object>) jsonMap.get("d");
    jsonMap = (StringMap<Object>) jsonMap.get("__metadata");
View Full Code Here

    EdmEntitySet employeesSet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
    EdmMapping mapping = employeesSet.getEntityType().getMapping();
    when(mapping.getMediaResourceMimeTypeKey()).thenReturn(mediaResourceMimeTypeKey);
    when(mapping.getMimeType()).thenReturn(originalMimeTypeKey);

    ODataResponse response = new JsonEntityProvider().writeEntry(employeesSet, employeeData, DEFAULT_PROPERTIES);
    String jsonString = verifyResponse(response);

    Gson gson = new Gson();
    StringMap<Object> jsonMap = gson.fromJson(jsonString, StringMap.class);
    jsonMap = (StringMap<Object>) jsonMap.get("d");
View Full Code Here

  @Test
  public void singleSimpleType() throws Exception {
    final EdmFunctionImport functionImport =
        MockFacade.getMockEdm().getDefaultEntityContainer().getFunctionImport("MaximalAge");

    final ODataResponse response = new JsonEntityProvider().writeFunctionImport(functionImport, 42, null);
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertNull("EntitypProvider must not set content header", response.getContentHeader());

    final String json = StringHelper.inputStreamToString((InputStream) response.getEntity());
View Full Code Here

    cityData.put("CityName", "Å");
    Map<String, Object> locationData = new HashMap<String, Object>();
    locationData.put("City", cityData);
    locationData.put("Country", "NO");

    final ODataResponse response = new JsonEntityProvider().writeFunctionImport(functionImport, locationData, null);
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertNull("EntitypProvider must not set content header", response.getContentHeader());

    final String json = StringHelper.inputStreamToString((InputStream) response.getEntity());
View Full Code Here

  public void collectionOfSimpleTypes() throws Exception {
    final EdmFunctionImport functionImport =
        MockFacade.getMockEdm().getDefaultEntityContainer().getFunctionImport("AllUsedRoomIds");

    final ODataResponse response =
        new JsonEntityProvider().writeFunctionImport(functionImport, Arrays.asList("1", "2", "3"), null);
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertNull("EntitypProvider must not set content header", response.getContentHeader());

    final String json = StringHelper.inputStreamToString((InputStream) response.getEntity());
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.core.ep.JsonEntityProvider

Copyright © 2018 www.massapicom. 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.