[OLINGO-1283]Facet info for Function Import parameters not honored
authorArchana Rai <archana.rai@sap.com>
Mon, 20 Aug 2018 12:44:33 +0000 (18:14 +0530)
committerArchana Rai <archana.rai@sap.com>
Mon, 20 Aug 2018 12:44:33 +0000 (18:14 +0530)
odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlPropertyConsumer.java
odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumerTest.java

index 8a052cb..557191c 100644 (file)
@@ -159,7 +159,7 @@ public class XmlPropertyConsumer {
 
       if (TRUE.equals(nullAttribute)) {
         if ((readProperties == null || readProperties.isValidatingFacets()) && propertyInfo.isMandatory()) {
-          throw new EntityProviderException(EntityProviderException.INVALID_PROPERTY_VALUE.addContent(name));
+          throw new EdmSimpleTypeException(EdmSimpleTypeException.VALUE_NULL_NOT_ALLOWED.addContent(name));
         }
         reader.nextTag();
       } else if (propertyInfo.isComplex()) {
index b8ba340..4f51fcd 100644 (file)
@@ -2033,7 +2033,23 @@ public class XmlEntityConsumerTest extends AbstractXmlConsumerTest {
     assertTrue(properties.containsKey("EntryDate"));
     assertNull(properties.get("EntryDate"));
   }
-
+  
+  @Test(expected = EntityProviderException.class)
+  public void readEntryNullId() throws Exception {
+    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
+    final String content = EMPLOYEE_1_XML.replace("<d:EmployeeId>1</d:EmployeeId>",
+        "<d:EmployeeId m:null='true' />");
+    InputStream contentBody = createContentAsStream(content);
+    try {
+      new XmlEntityConsumer().readEntry(entitySet, contentBody, EntityProviderReadProperties.init().mergeSemantic(
+          true).build());
+    } catch (EntityProviderException e) {
+      assertEquals(EntityProviderException.EXCEPTION_OCCURRED.getKey(), e.getMessageReference().getKey());
+      assertEquals("EdmSimpleTypeException", e.getMessageReference().getContent().get(0));
+      throw e;
+    }
+  }
+  
   @Test(expected = EntityProviderException.class)
   public void readEntryTooManyValues() throws Exception {
     // prepare