Java Code Examples for org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind#Null
The following examples show how to use
org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind#Null .
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: EdmSimpleTypeTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void checkValueOfNull() throws Exception { for (EdmSimpleTypeKind kind : EdmSimpleTypeKind.values()) { if (kind == EdmSimpleTypeKind.Null) { continue; } final EdmSimpleType instance = kind.getEdmSimpleTypeInstance(); assertNull(instance.valueOfString(null, EdmLiteralKind.DEFAULT, null, instance.getDefaultType())); assertNull(instance.valueOfString(null, EdmLiteralKind.DEFAULT, getNullableFacets(true), instance .getDefaultType())); assertNull(instance.valueOfString(null, EdmLiteralKind.DEFAULT, getNullableFacets(null), instance .getDefaultType())); expectErrorInValueOfString(instance, null, EdmLiteralKind.DEFAULT, getNullableFacets(false), EdmSimpleTypeException.LITERAL_NULL_NOT_ALLOWED); expectErrorInValueOfString(instance, "", null, null, EdmSimpleTypeException.LITERAL_KIND_MISSING); } }
Example 2
Source File: EdmSimpleTypeTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void validate() throws Exception { for (EdmSimpleTypeKind kind : EdmSimpleTypeKind.values()) { if (kind == EdmSimpleTypeKind.Null) { continue; } final EdmSimpleType instance = kind.getEdmSimpleTypeInstance(); assertTrue(instance.validate(null, null, null)); assertTrue(instance.validate(null, null, getNullableFacets(null))); assertTrue(instance.validate(null, null, getNullableFacets(true))); assertFalse(instance.validate(null, null, getNullableFacets(false))); assertFalse(instance.validate("", null, null)); assertFalse(instance.validate("ä", EdmLiteralKind.DEFAULT, getUnicodeFacets(false))); assertFalse(instance.validate("ä", EdmLiteralKind.URI, null)); } assertTrue(EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance().validate("abcd", EdmLiteralKind.DEFAULT, getMaxLengthFacets(3))); assertFalse(EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance().validate("abcd", EdmLiteralKind.DEFAULT, getMaxLengthFacets(2))); assertTrue(EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance().validate("1.2", EdmLiteralKind.DEFAULT, getPrecisionScaleFacets(null, null))); assertFalse(EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance().validate("1.2", EdmLiteralKind.DEFAULT, getPrecisionScaleFacets(null, 0))); }
Example 3
Source File: EdmSimpleTypeTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void checkNull() throws Exception { for (EdmSimpleTypeKind kind : EdmSimpleTypeKind.values()) { if (kind == EdmSimpleTypeKind.Null) { continue; } final EdmSimpleType instance = kind.getEdmSimpleTypeInstance(); assertNull(instance.valueToString(null, EdmLiteralKind.DEFAULT, null)); assertNull(instance.valueToString(null, EdmLiteralKind.DEFAULT, getNullableFacets(true))); assertNull(instance.valueToString(null, EdmLiteralKind.DEFAULT, getNullableFacets(null))); expectErrorInValueToString(instance, null, EdmLiteralKind.DEFAULT, getNullableFacets(false), EdmSimpleTypeException.VALUE_NULL_NOT_ALLOWED); } }
Example 4
Source File: AnnotationHelper.java From olingo-odata2 with Apache License 2.0 | 4 votes |
public EdmSimpleTypeKind mapTypeKind(final org.apache.olingo.odata2.api.annotation.edm.EdmType type) { switch (type) { case BINARY: return EdmSimpleTypeKind.Binary; case BOOLEAN: return EdmSimpleTypeKind.Boolean; case BYTE: return EdmSimpleTypeKind.Byte; case COMPLEX: return EdmSimpleTypeKind.Null; case DATE_TIME: return EdmSimpleTypeKind.DateTime; case DATE_TIME_OFFSET: return EdmSimpleTypeKind.DateTimeOffset; case DECIMAL: return EdmSimpleTypeKind.Decimal; case DOUBLE: return EdmSimpleTypeKind.Double; case GUID: return EdmSimpleTypeKind.Guid; case INT16: return EdmSimpleTypeKind.Int16; case INT32: return EdmSimpleTypeKind.Int32; case INT64: return EdmSimpleTypeKind.Int64; case NULL: return EdmSimpleTypeKind.Null; case SBYTE: return EdmSimpleTypeKind.SByte; case SINGLE: return EdmSimpleTypeKind.Single; case STRING: return EdmSimpleTypeKind.String; case TIME: return EdmSimpleTypeKind.Time; default: throw new AnnotationRuntimeException("Unknown type '" + type + "' for mapping to EdmSimpleTypeKind."); } }