Java Code Examples for org.apache.olingo.commons.api.data.ValueType#PRIMITIVE

The following examples show how to use org.apache.olingo.commons.api.data.ValueType#PRIMITIVE . 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: ODataJsonSerializerTest.java    From olingo-odata4 with Apache License 2.0 7 votes vote down vote up
@Test
public void primitivePropertyNull() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("PropertyString");
  final Property property = new Property("Edm.String", edmProperty.getName(), ValueType.PRIMITIVE, null);
  final String resultString = IOUtils
      .toString(serializer.primitive(metadata, (EdmPrimitiveType) edmProperty.getType(), property,
      PrimitiveSerializerOptions.with()
          .contextURL(ContextURL.with()
              .entitySet(edmEntitySet).keyPath("4242").navOrPropertyPath(edmProperty.getName())
              .build())
          .build()).getContent());
  Assert.assertEquals(
      "{\"@odata.context\":\"../$metadata#ESAllPrim(4242)/PropertyString\","
          +"\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\",\"value\":null}",
      resultString);
}
 
Example 2
Source File: ODataJsonSerializerv01Test.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Test
public void primitivePropertyNull() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("PropertyString");
  final Property property = new Property("Edm.String", edmProperty.getName(), ValueType.PRIMITIVE, null);
  final String resultString = IOUtils
      .toString(serializer.primitive(metadata, (EdmPrimitiveType) edmProperty.getType(), property,
      PrimitiveSerializerOptions.with()
          .contextURL(ContextURL.with()
              .entitySet(edmEntitySet).keyPath("4242").navOrPropertyPath(edmProperty.getName())
              .build())
          .build()).getContent());
  Assert.assertEquals(
      "{\"@context\":\"../$metadata#ESAllPrim(4242)/PropertyString\","
          +"\"@metadataEtag\":\"W/\\\"metadataETag\\\"\",\"value\":null}",
      resultString);
}
 
Example 3
Source File: ODataXmlSerializerTest.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Test
public void primitivePropertyNull() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("PropertyString");
  final Property property = new Property("Edm.String", edmProperty.getName(), ValueType.PRIMITIVE, null);
  String response = IOUtils.toString(serializer.primitive(metadata, (EdmPrimitiveType) edmProperty.getType(),
      property,
      PrimitiveSerializerOptions.with()
          .contextURL(ContextURL.with()
              .entitySet(edmEntitySet).keyPath("4242").navOrPropertyPath(edmProperty.getName())
              .build())
          .build()).getContent());
  String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
      + "<m:value xmlns:m=\"http://docs.oasis-open.org/odata/ns/metadata\" "
      + "m:context=\"../$metadata#ESAllPrim(4242)/PropertyString\" "
      + "m:metadata-etag=\"metadataETag\" "
      + "m:null=\"true\"></m:value>";
  Assert.assertEquals(expected, response);
}
 
Example 4
Source File: ODataXmlDeserializer.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private ValueType getValueType(final EdmType edmType, final boolean isCollection) {
  if (edmType instanceof EdmPrimitiveType) {
    if (edmType instanceof EdmEnumType) {
      return isCollection ? ValueType.COLLECTION_ENUM : ValueType.ENUM;
    } else {
      return isCollection ? ValueType.COLLECTION_PRIMITIVE : ValueType.PRIMITIVE;
    }
  } else if (edmType instanceof EdmComplexType) {
    return isCollection ? ValueType.COLLECTION_COMPLEX : ValueType.COMPLEX;
  } else {
    return ValueType.PRIMITIVE;
  }
}
 
Example 5
Source File: DataCreator.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
protected static Property createPrimitive(final String name, final Object value) {
  return new Property(null, name, ValueType.PRIMITIVE, value);
}
 
Example 6
Source File: DataCreator.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
protected static Property createDerived(final String name, final String type, final Object value) {
  return new Property(type, name, ValueType.PRIMITIVE, value);
}
 
Example 7
Source File: ResponseUtil.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
public static Property createPrimitive(final String name, final String type, final Object value) {
  return new Property(type, name, ValueType.PRIMITIVE, value);
}
 
Example 8
Source File: DataProvider.java    From olingo-odata4 with Apache License 2.0 4 votes vote down vote up
private Property createPrimitive(final String name, final Object value) {
  return new Property(null, name, ValueType.PRIMITIVE, value);
}