assertEquals(Integer.valueOf("67"), resultMap.get("Age"));
}
@Test
public void allStringSimplePropertyKinds() throws Exception {
EdmProperty edmProperty = mock(EdmProperty.class);
when(edmProperty.getName()).thenReturn("Name");
when(edmProperty.isSimple()).thenReturn(true);
String simplePropertyJson;
// DateTime
simplePropertyJson = "{\"d\":{\"Name\":\"\\/Date(915148800000)\\/\"}}";
JsonReader reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance());
Map<String, Object> resultMap = execute(edmProperty, reader);
Calendar entryDate = (Calendar) resultMap.get("Name");
assertEquals(Long.valueOf(915148800000l), Long.valueOf(entryDate.getTimeInMillis()));
// DateTimeOffset
simplePropertyJson = "{\"d\":{\"Name\":\"\\/Date(915148800000)\\/\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
entryDate = (Calendar) resultMap.get("Name");
assertEquals(Long.valueOf(915148800000l), Long.valueOf(entryDate.getTimeInMillis()));
// Decimal
simplePropertyJson = "{\"d\":{\"Name\":\"123456789\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Decimal.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals(BigDecimal.valueOf(Long.valueOf("123456789")), resultMap.get("Name"));
// Double
simplePropertyJson = "{\"d\":{\"Name\":\"123456789\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals(Double.valueOf("123456789"), resultMap.get("Name"));
// Double without "
simplePropertyJson = "{\"d\":{\"Name\":123456789}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Double.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals(Double.valueOf("123456789"), resultMap.get("Name"));
// Int64
simplePropertyJson = "{\"d\":{\"Name\":\"123456789\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Int64.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals(Long.valueOf("123456789"), resultMap.get("Name"));
// Single
simplePropertyJson = "{\"d\":{\"Name\":\"123456\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals(Float.valueOf("123456"), resultMap.get("Name"));
// Single without "
simplePropertyJson = "{\"d\":{\"Name\":123456}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Single.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals(Float.valueOf("123456"), resultMap.get("Name"));
// String
simplePropertyJson = "{\"d\":{\"Name\":\"123456789\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.String.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals("123456789", resultMap.get("Name"));
// Guid
simplePropertyJson = "{\"d\":{\"Name\":\"AABBCCDD-AABB-CCDD-EEFF-AABBCCDDEEFF\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals(UUID.fromString("aabbccdd-aabb-ccdd-eeff-aabbccddeeff"), resultMap.get("Name"));
// Binary
simplePropertyJson = "{\"d\":{\"Name\":\"qrvM\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertTrue(Arrays.equals(new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC },
(byte[]) resultMap.get("Name")));
// Time
simplePropertyJson = "{\"d\":{\"Name\":\"PT23H32M3S\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Time.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
Calendar dateTime = Calendar.getInstance();
dateTime.clear();
dateTime.set(Calendar.HOUR_OF_DAY, 23);
dateTime.set(Calendar.MINUTE, 32);