Examples of JsonEntityProvider


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

    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams");
    Map<String, Object> teamData = new HashMap<String, Object>();
    teamData.put("Id", "1");
    teamData.put("isScrumTeam", true);

    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, teamData, DEFAULT_PROPERTIES);
    final String json = verifyResponse(response);
    assertEquals("{\"d\":{\"__metadata\":{\"id\":\"" + BASE_URI + "Teams('1')\","
        + "\"uri\":\"" + BASE_URI + "Teams('1')\",\"type\":\"RefScenario.Team\"},"
        + "\"Id\":\"1\",\"Name\":null,\"isScrumTeam\":true,"
        + "\"nt_Employees\":{\"__deferred\":{\"uri\":\"" + BASE_URI + "Teams('1')/nt_Employees\"}}}}",
View Full Code Here

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

    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
    EntityProviderWriteProperties properties =
        EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).omitJsonWrapper(true).contentOnly(true)
            .build();
    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, employeeData, properties);
    Map<String, Object> employee =
        (Map<String, Object>) new Gson().fromJson(new InputStreamReader((InputStream) response.getEntity()), Map.class);
    assertNull(employee.get("__metadata"));
    assertNull(employee.get("ne_Manager"));
    assertNull(employee.get("ne_Team"));
View Full Code Here

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

    ExpandSelectTreeNode expandSelectTreeNode =
        ExpandSelectTreeNode.entitySet(entitySet).selectedProperties(selectedProperties).build();
    EntityProviderWriteProperties properties =
        EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).omitJsonWrapper(true).contentOnly(true)
            .expandSelectTree(expandSelectTreeNode).build();
    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, employeeData, properties);
    Map<String, Object> employee =
        (Map<String, Object>) new Gson().fromJson(new InputStreamReader((InputStream) response.getEntity()), Map.class);
    assertNull(employee.get("__metadata"));
    assertNull(employee.get("ne_Manager"));
    assertNull(employee.get("ne_Team"));
View Full Code Here

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

        ExpandSelectTreeNode.entitySet(entitySet).selectedProperties(selectedProperties).expandedLinks(expandedLinks)
            .build();
    EntityProviderWriteProperties properties =
        EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).omitJsonWrapper(true).contentOnly(true)
            .expandSelectTree(expandSelectTreeNode).build();
    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, employeeData, properties);
    Map<String, Object> employee =
        (Map<String, Object>) new Gson().fromJson(new InputStreamReader((InputStream) response.getEntity()), Map.class);
    assertNull(employee.get("__metadata"));
    assertNull(employee.get("ne_Manager"));
    assertNull(employee.get("ne_Team"));
View Full Code Here

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

    additinalLinks.put("ne_Manager", managerLink);

    EntityProviderWriteProperties properties =
        EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).omitJsonWrapper(true).contentOnly(true)
            .expandSelectTree(expandSelectTreeNode).additionalLinks(additinalLinks).build();
    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, employeeData, properties);
    // System.out.println(StringHelper.inputStreamToString((InputStream) response.getEntity()));
    Map<String, Object> employee =
        (Map<String, Object>) new Gson().fromJson(new InputStreamReader((InputStream) response.getEntity()), Map.class);
    assertNull(employee.get("__metadata"));
    assertNull(employee.get("ne_Team"));
View Full Code Here

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

    teamData.put("Id", "1");
    teamData.put("isScrumTeam", true);

    EntityProviderWriteProperties properties =
        EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).omitJsonWrapper(true).build();
    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, teamData, properties);
    final String json = verifyResponse(response);
    assertEquals("{\"__metadata\":{\"id\":\"" + BASE_URI + "Teams('1')\","
        + "\"uri\":\"" + BASE_URI + "Teams('1')\",\"type\":\"RefScenario.Team\"},"
        + "\"Id\":\"1\",\"Name\":null,\"isScrumTeam\":true,"
        + "\"nt_Employees\":{\"__deferred\":{\"uri\":\"" + BASE_URI + "Teams('1')/nt_Employees\"}}}",
View Full Code Here

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

  @Test(expected = EntityProviderException.class)
  public void entryWithNullData() throws Exception {
    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams");

    new JsonEntityProvider().writeEntry(entitySet, null, DEFAULT_PROPERTIES);
  }
View Full Code Here

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

  @Test(expected = EntityProviderException.class)
  public void entryWithEmptyData() throws Exception {
    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams");

    new JsonEntityProvider().writeEntry(entitySet, new HashMap<String, Object>(), DEFAULT_PROPERTIES);
  }
View Full Code Here

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

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

    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, buildingData,
        EntityProviderWriteProperties.serviceRoot(URI.create(BASE_URI)).expandSelectTree(node).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

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

    photoData.put("Id", 1);
    photoData.put("Type", "image/png");
    photoData.put("BinaryData", new byte[] { -1, 0, 1, 2 });
    photoData.put("getType", "image/png");

    final ODataResponse response = new JsonEntityProvider().writeEntry(entitySet, photoData, DEFAULT_PROPERTIES);
    final String json = verifyResponse(response);
    assertEquals("{\"d\":{\"__metadata\":{"
        + "\"id\":\"" + BASE_URI + "Container2.Photos(Id=1,Type='image%2Fpng')\","
        + "\"uri\":\"" + BASE_URI + "Container2.Photos(Id=1,Type='image%2Fpng')\","
        + "\"type\":\"RefScenario2.Photo\",\"etag\":\"W/\\\"1\\\"\",\"content_type\":\"image/png\","
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.