Java Code Examples for org.apache.olingo.commons.api.format.ContentType#JSON_FULL_METADATA

The following examples show how to use org.apache.olingo.commons.api.format.ContentType#JSON_FULL_METADATA . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractUtilities.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
public AbstractUtilities(final Metadata metadata) throws IOException {
  this.metadata = metadata;
  fsManager = FSManager.instance();
  atomDeserializer = new FITAtomDeserializer();
  jsonDeserializer = new JsonDeserializer(true);
  atomSerializer = new AtomSerializer(true);
  jsonSerializer = new JsonSerializer(true, ContentType.JSON_FULL_METADATA);
}
 
Example 2
Source File: AbstractTestITCase.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
protected ClientEntity read(final ContentType contentType, final URI editLink) {
  final ODataEntityRequest<ClientEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(editLink);
  req.setFormat(contentType);

  final ODataRetrieveResponse<ClientEntity> res = req.execute();
  final ClientEntity entity = res.getBody();

  assertNotNull(entity);

  if (ContentType.JSON_FULL_METADATA == contentType || ContentType.APPLICATION_ATOM_XML == contentType) {
    assertEquals(req.getURI(), entity.getEditLink());
  }

  return entity;
}
 
Example 3
Source File: JsonSerializerTest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Test
public void testClientEntityJSONWithNull() throws ODataSerializerException {
  String expectedJson = "{\"@odata.type\":\"#test.testClientEntity\","
      + "\"[email protected]\":\"Int32\","
      + "\"testInt32\":12,"
      + "\"[email protected]\":\"Int32\""
      + ",\"testInt32Null\":null,"
      + "\"[email protected]\":\"String\","
      + "\"testString\":\"testString\","
      + "\"[email protected]\":\"String\","
      + "\"testStringNull\":null}";

  ODataClient odataClient = ODataClientFactory.getClient();
  ClientObjectFactory objFactory = odataClient.getObjectFactory();
  ClientEntity clientEntity = objFactory.newEntity(new FullQualifiedName("test", "testClientEntity"));

  clientEntity.getProperties().add(
      objFactory.newPrimitiveProperty(
          "testInt32",
          objFactory.newPrimitiveValueBuilder().buildInt32(12)));
  clientEntity.getProperties().add(
      objFactory.newPrimitiveProperty(
          "testInt32Null",
          objFactory.newPrimitiveValueBuilder().buildInt32(null)));
  clientEntity.getProperties().add(
      objFactory.newPrimitiveProperty(
          "testString",
          objFactory.newPrimitiveValueBuilder().buildString("testString")));
  clientEntity.getProperties().add(
      objFactory.newPrimitiveProperty(
          "testStringNull",
          objFactory.newPrimitiveValueBuilder().buildString(null)));

  JsonSerializer jsonSerializer = new JsonSerializer(false, ContentType.JSON_FULL_METADATA);

  StringWriter writer = new StringWriter();
  jsonSerializer.write(writer, odataClient.getBinder().getEntity(clientEntity));
  assertThat(writer.toString(), is(expectedJson));
}
 
Example 4
Source File: JSONTest.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
protected ContentType getODataMetadataFullFormat() {
  return ContentType.JSON_FULL_METADATA;
}