You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/09/20 15:33:41 UTC
[19/59] [abbrv] Cleanup of core
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonPropertyConsumerTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonPropertyConsumerTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonPropertyConsumerTest.java
index 61ef209..8c00076 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonPropertyConsumerTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonPropertyConsumerTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;
@@ -74,23 +74,23 @@ public class JsonPropertyConsumerTest extends BaseTest {
when(edmProperty.getName()).thenReturn("Age");
when(edmProperty.isSimple()).thenReturn(true);
- //Byte
+ // Byte
JsonReader reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Byte.getEdmSimpleTypeInstance());
Map<String, Object> resultMap = execute(edmProperty, reader);
assertEquals(Short.valueOf("67"), resultMap.get("Age"));
- //SByte
+ // SByte
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.SByte.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals(Byte.valueOf("67"), resultMap.get("Age"));
- //Int16
+ // Int16
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Int16.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
assertEquals(Short.valueOf("67"), resultMap.get("Age"));
- //Int32
+ // Int32
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance());
resultMap = execute(edmProperty, reader);
@@ -104,64 +104,64 @@ public class JsonPropertyConsumerTest extends BaseTest {
when(edmProperty.isSimple()).thenReturn(true);
String simplePropertyJson;
- //DateTime
+ // 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
+ // 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
+ // 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
+ // 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"));
- //Int64
+ // 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
+ // 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"));
- //String
+ // 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
+ // 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
+ // 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
+ // Time
simplePropertyJson = "{\"d\":{\"Name\":\"PT23H32M3S\"}}";
reader = prepareReader(simplePropertyJson);
when(edmProperty.getType()).thenReturn(EdmSimpleTypeKind.Time.getEdmSimpleTypeInstance());
@@ -178,7 +178,9 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void simplePropertyOnOpenReader() throws Exception {
String simplePropertyJson = "{\"Name\":\"Team 1\"}";
JsonReader reader = prepareReader(simplePropertyJson);
- EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams").getEntityType().getProperty("Name");
+ EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams").getEntityType()
+ .getProperty("Name");
EntityPropertyInfo entityPropertyInfo = EntityInfoAggregator.create(edmProperty);
reader.beginObject();
reader.nextName();
@@ -195,11 +197,13 @@ public class JsonPropertyConsumerTest extends BaseTest {
String propertyValue = new String(chars);
String simplePropertyJson = "{\"d\":{\"Name\":\"" + propertyValue + "\"}}";
JsonReader reader = prepareReader(simplePropertyJson);
- final EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Room").getProperty("Name");
+ final EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Room").getProperty("Name");
EntityProviderReadProperties readProperties = mock(EntityProviderReadProperties.class);
when(readProperties.getTypeMappings()).thenReturn(null);
- Map<String, Object> resultMap = new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
+ Map<String, Object> resultMap =
+ new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
assertEquals(propertyValue, resultMap.get("Name"));
}
@@ -207,7 +211,8 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test
public void simplePropertyNull() throws Exception {
JsonReader reader = prepareReader("{\"Name\":null}");
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Room").getProperty("Name");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Room").getProperty("Name");
final Map<String, Object> resultMap = new JsonPropertyConsumer().readPropertyStandalone(reader, property, null);
assertTrue(resultMap.containsKey("Name"));
assertNull(resultMap.get("Name"));
@@ -216,7 +221,8 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test(expected = EntityProviderException.class)
public void simplePropertyNullValueNotAllowed() throws Exception {
JsonReader reader = prepareReader("{\"Age\":null}");
- EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+ EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
EdmFacets facets = mock(EdmFacets.class);
when(facets.isNullable()).thenReturn(false);
when(property.getFacets()).thenReturn(facets);
@@ -228,11 +234,13 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void simplePropertyWithNullMappingStandalone() throws Exception {
String simplePropertyJson = "{\"d\":{\"Age\":67}}";
JsonReader reader = prepareReader(simplePropertyJson);
- final EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+ final EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
EntityProviderReadProperties readProperties = mock(EntityProviderReadProperties.class);
when(readProperties.getTypeMappings()).thenReturn(null);
- Map<String, Object> resultMap = new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
+ Map<String, Object> resultMap =
+ new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
assertEquals(Integer.valueOf(67), resultMap.get("Age"));
}
@@ -241,11 +249,13 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void simplePropertyWithNullMappingStandaloneWithoutD() throws Exception {
String simplePropertyJson = "{\"Age\":67}";
JsonReader reader = prepareReader(simplePropertyJson);
- final EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+ final EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
EntityProviderReadProperties readProperties = mock(EntityProviderReadProperties.class);
when(readProperties.getTypeMappings()).thenReturn(null);
- Map<String, Object> resultMap = new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
+ Map<String, Object> resultMap =
+ new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
assertEquals(Integer.valueOf(67), resultMap.get("Age"));
}
@@ -254,11 +264,13 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void simplePropertyWithEmptyMappingStandalone() throws Exception {
String simplePropertyJson = "{\"d\":{\"Age\":67}}";
JsonReader reader = prepareReader(simplePropertyJson);
- final EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+ final EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
EntityProviderReadProperties readProperties = mock(EntityProviderReadProperties.class);
when(readProperties.getTypeMappings()).thenReturn(new HashMap<String, Object>());
- Map<String, Object> resultMap = new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
+ Map<String, Object> resultMap =
+ new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
assertEquals(Integer.valueOf(67), resultMap.get("Age"));
}
@@ -267,13 +279,15 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void simplePropertyWithStringToLongMappingStandalone() throws Exception {
String simplePropertyJson = "{\"d\":{\"Age\":67}}";
JsonReader reader = prepareReader(simplePropertyJson);
- final EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+ final EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
EntityProviderReadProperties readProperties = mock(EntityProviderReadProperties.class);
Map<String, Object> typeMappings = new HashMap<String, Object>();
typeMappings.put("Age", Long.class);
when(readProperties.getTypeMappings()).thenReturn(typeMappings);
- Map<String, Object> resultMap = new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
+ Map<String, Object> resultMap =
+ new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
assertEquals(Long.valueOf(67), resultMap.get("Age"));
}
@@ -282,27 +296,31 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void simplePropertyWithStringToNullMappingStandalone() throws Exception {
String simplePropertyJson = "{\"d\":{\"Age\":67}}";
JsonReader reader = prepareReader(simplePropertyJson);
- final EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+ final EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
EntityProviderReadProperties readProperties = mock(EntityProviderReadProperties.class);
Map<String, Object> typeMappings = new HashMap<String, Object>();
typeMappings.put("Age", null);
when(readProperties.getTypeMappings()).thenReturn(typeMappings);
- Map<String, Object> resultMap = new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
+ Map<String, Object> resultMap =
+ new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
assertEquals(Integer.valueOf(67), resultMap.get("Age"));
}
@Test(expected = EntityProviderException.class)
public void noContent() throws Exception {
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
JsonReader reader = prepareReader("{}");
new JsonPropertyConsumer().readPropertyStandalone(reader, property, null);
}
@Test(expected = EntityProviderException.class)
public void simplePropertyUnfinished() throws Exception {
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
JsonReader reader = prepareReader("{\"Age\":67");
new JsonPropertyConsumer().readPropertyStandalone(reader, property, null);
}
@@ -311,16 +329,20 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void simplePropertInvalidName() throws Exception {
String simplePropertyJson = "{\"d\":{\"Invalid\":67}}";
JsonReader reader = prepareReader(simplePropertyJson);
- final EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
+ final EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getEntityType("RefScenario", "Employee").getProperty("Age");
new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, null);
}
@Test
public void complexPropertyWithStringToStringMappingStandalone() throws Exception {
- final String complexPropertyJson = "{\"d\":{\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}}}";
+ final String complexPropertyJson =
+ "{\"d\":{\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"}," +
+ "\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}}}";
JsonReader reader = prepareReader(complexPropertyJson);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
EntityProviderReadProperties readProperties = mock(EntityProviderReadProperties.class);
Map<String, Object> innerMappings = new HashMap<String, Object>();
@@ -339,9 +361,14 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test
public void deepComplexPropertyWithStringToStringMappingStandalone() throws Exception {
- final String complexPropertyJson = "{\"d\":{\"Location\":{\"__metadata\":{\"type\":\"RefScenario.c_Location\"},\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"},\"Country\":\"Germany\"}}}";
+ final String complexPropertyJson =
+ "{\"d\":{\"Location\":{\"__metadata\":{\"type\":\"RefScenario.c_Location\"}," +
+ "\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\"," +
+ "\"CityName\":\"Heidelberg\"},\"Country\":\"Germany\"}}}";
JsonReader reader = prepareReader(complexPropertyJson);
- EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType().getProperty("Location");
+ EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType()
+ .getProperty("Location");
EntityProviderReadProperties readProperties = mock(EntityProviderReadProperties.class);
Map<String, Object> cityMappings = new HashMap<String, Object>();
@@ -352,7 +379,8 @@ public class JsonPropertyConsumerTest extends BaseTest {
mappings.put("Location", locationMappings);
when(readProperties.getTypeMappings()).thenReturn(mappings);
- final Map<String, Object> result = new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
+ final Map<String, Object> result =
+ new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, readProperties);
assertEquals(1, result.size());
@SuppressWarnings("unchecked")
@@ -368,9 +396,11 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test
public void complexPropertyOnOpenReader() throws Exception {
- final String complexPropertyJson = "{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}";
+ final String complexPropertyJson =
+ "{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}";
JsonReader reader = prepareReader(complexPropertyJson);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
EntityComplexPropertyInfo entityPropertyInfo = (EntityComplexPropertyInfo) EntityInfoAggregator.create(property);
JsonPropertyConsumer jpc = new JsonPropertyConsumer();
@@ -386,7 +416,8 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void complexPropertyOnOpenReaderWithNoMetadata() throws Exception {
final String complexPropertyJson = "{\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}";
JsonReader reader = prepareReader(complexPropertyJson);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
EntityComplexPropertyInfo entityPropertyInfo = (EntityComplexPropertyInfo) EntityInfoAggregator.create(property);
JsonPropertyConsumer jpc = new JsonPropertyConsumer();
@@ -400,9 +431,14 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test
public void deepComplexPropertyOnOpenReader() throws Exception {
- final String complexPropertyJson = "{\"__metadata\":{\"type\":\"RefScenario.c_Location\"},\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"},\"Country\":\"Germany\"}";
+ final String complexPropertyJson =
+ "{\"__metadata\":{\"type\":\"RefScenario.c_Location\"}," +
+ "\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\"," +
+ "\"CityName\":\"Heidelberg\"},\"Country\":\"Germany\"}";
JsonReader reader = prepareReader(complexPropertyJson);
- EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType().getProperty("Location");
+ EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType()
+ .getProperty("Location");
EntityComplexPropertyInfo entityPropertyInfo = (EntityComplexPropertyInfo) EntityInfoAggregator.create(edmProperty);
JsonPropertyConsumer jpc = new JsonPropertyConsumer();
@@ -421,7 +457,9 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test
public void simplePropertyStandalone() throws Exception {
String simplePropertyJson = "{\"d\":{\"Name\":\"Team 1\"}}";
- EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams").getEntityType().getProperty("Name");
+ EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams").getEntityType()
+ .getProperty("Name");
JsonReader reader = prepareReader(simplePropertyJson);
Map<String, Object> result = new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, null);
@@ -430,9 +468,12 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test
public void complexPropertyStandalone() throws Exception {
- final String complexPropertyJson = "{\"d\":{\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}}}";
+ final String complexPropertyJson =
+ "{\"d\":{\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"}," +
+ "\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}}}";
JsonReader reader = prepareReader(complexPropertyJson);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
final Map<String, Object> result = new JsonPropertyConsumer().readPropertyStandalone(reader, property, null);
@@ -445,9 +486,14 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test
public void deepComplexPropertyStandalone() throws Exception {
- final String complexPropertyJson = "{\"d\":{\"Location\":{\"__metadata\":{\"type\":\"RefScenario.c_Location\"},\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"},\"Country\":\"Germany\"}}}";
+ final String complexPropertyJson =
+ "{\"d\":{\"Location\":{\"__metadata\":{\"type\":\"RefScenario.c_Location\"}," +
+ "\"City\":{\"__metadata\":{\"type\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\"," +
+ "\"CityName\":\"Heidelberg\"},\"Country\":\"Germany\"}}}";
JsonReader reader = prepareReader(complexPropertyJson);
- EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType().getProperty("Location");
+ EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType()
+ .getProperty("Location");
JsonPropertyConsumer jpc = new JsonPropertyConsumer();
Map<String, Object> result = jpc.readPropertyStandalone(reader, edmProperty, null);
@@ -468,7 +514,8 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void complexPropertyWithInvalidChild() throws Exception {
String cityProperty = "{\"d\":{\"City\":{\"Invalid\":\"69124\",\"CityName\":\"Heidelberg\"}}}";
JsonReader reader = prepareReader(cityProperty);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
new JsonPropertyConsumer().readPropertyStandalone(reader, property, null);
}
@@ -477,7 +524,8 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void complexPropertyWithInvalidName() throws Exception {
String cityProperty = "{\"d\":{\"Invalid\":{\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}}}";
JsonReader reader = prepareReader(cityProperty);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
new JsonPropertyConsumer().readPropertyStandalone(reader, property, null);
}
@@ -486,7 +534,9 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void complexPropertyNull() throws Exception {
final String locationProperty = "{\"Location\":null}";
JsonReader reader = prepareReader(locationProperty);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType().getProperty("Location");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType()
+ .getProperty("Location");
final Map<String, Object> propertyData = new JsonPropertyConsumer().readPropertyStandalone(reader, property, null);
assertNotNull(propertyData);
@@ -499,7 +549,9 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void complexPropertyNullValueNotAllowed() throws Exception {
final String locationProperty = "{\"Location\":null}";
JsonReader reader = prepareReader(locationProperty);
- EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType().getProperty("Location");
+ EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees").getEntityType()
+ .getProperty("Location");
EdmFacets facets = mock(EdmFacets.class);
when(facets.isNullable()).thenReturn(false);
when(property.getFacets()).thenReturn(facets);
@@ -511,7 +563,8 @@ public class JsonPropertyConsumerTest extends BaseTest {
public void complexPropertyEmpty() throws Exception {
final String cityProperty = "{\"d\":{\"City\":{}}}";
JsonReader reader = prepareReader(cityProperty);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
final Map<String, Object> propertyData = new JsonPropertyConsumer().readPropertyStandalone(reader, property, null);
assertNotNull(propertyData);
@@ -524,9 +577,11 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test(expected = EntityProviderException.class)
public void complexPropertyMetadataInvalidTag() throws Exception {
- String complexPropertyJson = "{\"__metadata\":{\"invalid\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}";
+ String complexPropertyJson =
+ "{\"__metadata\":{\"invalid\":\"RefScenario.c_City\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}";
JsonReader reader = prepareReader(complexPropertyJson);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
EntityComplexPropertyInfo entityPropertyInfo = (EntityComplexPropertyInfo) EntityInfoAggregator.create(property);
new JsonPropertyConsumer().readPropertyValue(reader, entityPropertyInfo, null);
@@ -534,9 +589,11 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test(expected = EntityProviderException.class)
public void complexPropertyMetadataInvalidTypeContent() throws Exception {
- String complexPropertyJson = "{\"__metadata\":{\"type\":\"Invalid\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}";
+ String complexPropertyJson =
+ "{\"__metadata\":{\"type\":\"Invalid\"},\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"}";
JsonReader reader = prepareReader(complexPropertyJson);
- final EdmProperty property = (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
+ final EdmProperty property =
+ (EdmProperty) MockFacade.getMockEdm().getComplexType("RefScenario", "c_Location").getProperty("City");
EntityComplexPropertyInfo entityPropertyInfo = (EntityComplexPropertyInfo) EntityInfoAggregator.create(property);
new JsonPropertyConsumer().readPropertyValue(reader, entityPropertyInfo, null);
@@ -548,7 +605,8 @@ public class JsonPropertyConsumerTest extends BaseTest {
return reader;
}
- private Map<String, Object> execute(final EdmProperty edmProperty, final JsonReader reader) throws EntityProviderException {
+ private Map<String, Object> execute(final EdmProperty edmProperty, final JsonReader reader)
+ throws EntityProviderException {
JsonPropertyConsumer jpc = new JsonPropertyConsumer();
Map<String, Object> resultMap = jpc.readPropertyStandalone(reader, edmProperty, null);
return resultMap;
@@ -561,7 +619,9 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test(expected = EntityProviderException.class)
public void invalidDoubleClosingBrackets() throws Exception {
String simplePropertyJson = "{\"d\":{\"Name\":\"Team 1\"}}}";
- EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams").getEntityType().getProperty("Name");
+ EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams").getEntityType()
+ .getProperty("Name");
JsonReader reader = prepareReader(simplePropertyJson);
new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, null);
@@ -570,7 +630,9 @@ public class JsonPropertyConsumerTest extends BaseTest {
@Test(expected = EntityProviderException.class)
public void invalidDoubleClosingBracketsWithoutD() throws Exception {
String simplePropertyJson = "{\"Name\":\"Team 1\"}}";
- EdmProperty edmProperty = (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams").getEntityType().getProperty("Name");
+ EdmProperty edmProperty =
+ (EdmProperty) MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams").getEntityType()
+ .getProperty("Name");
JsonReader reader = prepareReader(simplePropertyJson);
new JsonPropertyConsumer().readPropertyStandalone(reader, edmProperty, null);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumerTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumerTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumerTest.java
index ba671dc..3b04e0f 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumerTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumerTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/ServiceDocumentConsumerTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/ServiceDocumentConsumerTest.java b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/ServiceDocumentConsumerTest.java
index d67354a..af916ad 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/ServiceDocumentConsumerTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/ServiceDocumentConsumerTest.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;