[OLINGO-1062]Fix deserialization of empty collections
This commit is contained in:
parent
aa9a12d82a
commit
47a6775c7e
|
@ -131,6 +131,9 @@ public abstract class ClientCsdlDynamicExpression extends CsdlDynamicExpression
|
|||
} else if (COLLECTION.equals(jp.getCurrentName())) {
|
||||
jp.nextToken();
|
||||
expression = jp.readValueAs(ClientCsdlCollection.class);
|
||||
if(expression == null) {
|
||||
expression = new ClientCsdlCollection();
|
||||
}
|
||||
} else if (IF.equals(jp.getCurrentName())) {
|
||||
jp.nextToken();
|
||||
jp.nextToken();
|
||||
|
|
|
@ -77,6 +77,7 @@ import org.apache.olingo.commons.api.edm.provider.annotation.CsdlExpression;
|
|||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression.LogicalOrComparisonExpressionType;
|
||||
//CHECKSTYLE:ON
|
||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPath;
|
||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPropertyValue;
|
||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlRecord;
|
||||
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlUrlRef;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
|
@ -1213,4 +1214,27 @@ public class MetadataTest extends AbstractTest {
|
|||
annotation = annotations.getAnnotation(term, null);
|
||||
assertNotNull(annotation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void metadataWithEmptyCollection() throws Exception {
|
||||
InputStream input = getClass().getResourceAsStream("empty-collection-metadata.xml");
|
||||
final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML).toMetadata(input);
|
||||
|
||||
CsdlSchema schema = metadata.getSchema("Foo");
|
||||
assertNotNull(schema);
|
||||
|
||||
CsdlAnnotations annotations = schema.getAnnotationGroup("Foo.EntityContainer/Bar", null);
|
||||
assertNotNull(annotations);
|
||||
|
||||
CsdlAnnotation annotation = annotations.getAnnotation("Capabilities.FilterRestrictions");
|
||||
assertNotNull(annotation);
|
||||
|
||||
CsdlPropertyValue value = annotation.getExpression()
|
||||
.asDynamic().asRecord().getPropertyValues().get(0);
|
||||
assertNotNull(value);
|
||||
|
||||
CsdlExpression collection = value.getValue();
|
||||
assertNotNull(value);
|
||||
assertEquals(new CsdlCollection(), collection);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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
|
||||
|
||||
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.
|
||||
-->
|
||||
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
|
||||
<edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Capabilities.V1.xml">
|
||||
<edmx:Include Alias="Capabilities" Namespace="Org.OData.Capabilities.V1"/>
|
||||
</edmx:Reference>
|
||||
<edmx:DataServices>
|
||||
<Schema Namespace="Foo" xmlns="http://docs.oasis-open.org/odata/ns/edm">
|
||||
<EntityContainer Name="EntityContainer">
|
||||
<EntitySet Name="Bar" EntityType="Foo.Bar"/>
|
||||
</EntityContainer>
|
||||
<EntityType Name="Bar">
|
||||
<Key>
|
||||
<PropertyRef Name="ID"/>
|
||||
</Key>
|
||||
<Property Name="ID" Type="Edm.Guid" Nullable="false"/>
|
||||
</EntityType>
|
||||
<Annotations Target="Foo.EntityContainer/Bar">
|
||||
<Annotation Term="Capabilities.FilterRestrictions">
|
||||
<Record Type="Capabilities.FilterRestrictionsType">
|
||||
<PropertyValue Property="NonFilterableProperties">
|
||||
<Collection/>
|
||||
</PropertyValue>
|
||||
</Record>
|
||||
</Annotation>
|
||||
</Annotations>
|
||||
</Schema>
|
||||
</edmx:DataServices>
|
||||
</edmx:Edmx>
|
Loading…
Reference in New Issue