Examples of JsonEntityProvider


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

  @Test
  public void serializeNull() throws Exception {
    EdmProperty property =
        (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("ImageUrl");
    ODataResponse response = new JsonEntityProvider().writeProperty(property, null);
    assertEquals("{\"d\":{\"ImageUrl\":null}}", StringHelper.inputStreamToString((InputStream) response.getEntity()));

    property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
    response = new JsonEntityProvider().writeProperty(property, null);
    assertEquals("{\"d\":{\"Age\":null}}", StringHelper.inputStreamToString((InputStream) response.getEntity()));

    property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("EntryDate");
    response = new JsonEntityProvider().writeProperty(property, null);
    assertEquals("{\"d\":{\"EntryDate\":null}}", StringHelper.inputStreamToString((InputStream) response.getEntity()));

    property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Building").getProperty("Image");
    response = new JsonEntityProvider().writeProperty(property, null);
    assertEquals("{\"d\":{\"Image\":null}}", StringHelper.inputStreamToString((InputStream) response.getEntity()));
  }
View Full Code Here

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

  public void serializeDateTime() throws Exception {
    final EdmProperty property =
        (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("EntryDate");
    Calendar dateTime = Calendar.getInstance();
    dateTime.setTimeInMillis(-42);
    final ODataResponse response = new JsonEntityProvider().writeProperty(property, dateTime);
    assertEquals("{\"d\":{\"EntryDate\":\"\\/Date(-42)\\/\"}}", StringHelper.inputStreamToString((InputStream) response
        .getEntity()));
  }
View Full Code Here

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

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

    final ODataResponse response = new JsonEntityProvider().writeProperty(property, locationData);
    assertEquals("{\"d\":{\"Location\":{\"__metadata\":{\"type\":\"RefScenario.c_Location\"},"
        + "\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},"
        + "\"PostalCode\":\"8392\",\"CityName\":\"Å\"},\"Country\":\"NO\"}}}",
        StringHelper.inputStreamToString((InputStream) response.getEntity()));
  }
View Full Code Here

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

  @Test
  public void serializeComplexPropertyNull() throws Exception {
    final EdmProperty property =
        (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Location");
    final ODataResponse response = new JsonEntityProvider().writeProperty(property, null);
    assertEquals("{\"d\":{\"Location\":{\"__metadata\":{\"type\":\"RefScenario.c_Location\"},"
        + "\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},"
        + "\"PostalCode\":null,\"CityName\":null},\"Country\":null}}}",
        StringHelper.inputStreamToString((InputStream) response.getEntity()));
  }
View Full Code Here

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

    team2Data.put("isScrumTeam", false);
    List<Map<String, Object>> teamsData = new ArrayList<Map<String, Object>>();
    teamsData.add(team1Data);
    teamsData.add(team2Data);

    final ODataResponse response = new JsonEntityProvider().writeFeed(entitySet, teamsData, DEFAULT_PROPERTIES);
    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

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

  }

  @Test
  public void inlineCount() throws Exception {
    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Buildings");
    final ODataResponse response = new JsonEntityProvider().writeFeed(entitySet, new ArrayList<Map<String, Object>>(),
        EntityProviderWriteProperties.serviceRoot(URI.create(BASE_URI))
            .inlineCountType(InlineCount.ALLPAGES).inlineCount(42)
            .build());
    assertNotNull(response);
    assertNotNull(response.getEntity());
View Full Code Here

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

    roomData.put("Seats", 123);
    roomData.put("Version", 1);
    List<Map<String, Object>> roomsData = new ArrayList<Map<String, Object>>();
    roomsData.add(roomData);

    final ODataResponse response = new JsonEntityProvider().writeFeed(entitySet, roomsData,
        EntityProviderWriteProperties.serviceRoot(URI.create(BASE_URI)).nextLink("Rooms?$skiptoken=2").build());
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertNull("EntitypProvider must not set content header", response.getContentHeader());
View Full Code Here

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

  @Test
  public void serviceDocumentEmpty() throws Exception {
    Edm edm = mock(Edm.class);
    EdmServiceMetadata metadata = mock(EdmServiceMetadata.class);
    when(edm.getServiceMetadata()).thenReturn(metadata);
    final ODataResponse response = new JsonEntityProvider().writeServiceDocument(edm, "http://host:80/service/");
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertNull("EntitypProvider must not set content header", response.getContentHeader());
    assertEquals(ODataServiceVersion.V10, response.getHeader(ODataHttpHeaders.DATASERVICEVERSION));
View Full Code Here

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

    when(entitySetInfo1.getEntitySetUri()).thenReturn(URI.create("EntitySet"));
    EdmEntitySetInfo entitySetInfo2 = mock(EdmEntitySetInfo.class);
    when(entitySetInfo2.getEntitySetUri()).thenReturn(URI.create("Container2.EntitySet2"));
    when(metadata.getEntitySetInfos()).thenReturn(Arrays.asList(entitySetInfo1, entitySetInfo2));
    when(edm.getServiceMetadata()).thenReturn(metadata);
    final ODataResponse response = new JsonEntityProvider().writeServiceDocument(edm, "http://host:80/service/");
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertNull("EntitypProvider must not set content header", response.getContentHeader());
    assertEquals(ODataServiceVersion.V10, response.getHeader(ODataHttpHeaders.DATASERVICEVERSION));
View Full Code Here

Examples of org.exoplatform.services.rest.impl.provider.JsonEntityProvider

      StreamOutputEntityProvider soep = new StreamOutputEntityProvider();
      addMessageBodyReader(soep);
      addMessageBodyWriter(soep);

      JsonEntityProvider jsep = new JsonEntityProvider();
      addMessageBodyReader(jsep);
      addMessageBodyWriter(jsep);

      // per-request mode , Providers should be injected
      addMessageBodyReader(JAXBElementEntityProvider.class);
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.