[OLINGO-1495]Uri parsing error for GET request on child entity with ID
This commit is contained in:
parent
79bd10f430
commit
b914808524
|
@ -310,6 +310,12 @@ public class ParserHelper {
|
|||
referencedNames.put(name, referencedName);
|
||||
}
|
||||
}
|
||||
for (final EdmKeyPropertyRef candidate : keyPropertyRefs) {
|
||||
final UriParameter simpleKey = simpleKey(tokenizer, candidate, edm, referringType, aliases);
|
||||
if (simpleKey != null) {
|
||||
keys.add(simpleKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (keyPropertyRefs.size() - referencedNames.size() == 1) {
|
||||
|
|
|
@ -292,6 +292,7 @@ public class EntityTypeProvider {
|
|||
.setName("ETMedia")
|
||||
.setKey(Arrays.asList(new CsdlPropertyRef().setName("PropertyInt16")))
|
||||
.setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable))
|
||||
.setNavigationProperties(Arrays.asList(PropertyProvider.navPropertyETMediaOne_ETKeyNavMany))
|
||||
.setHasStream(true);
|
||||
|
||||
} else if (entityTypeName.equals(nameETServerSidePaging)) {
|
||||
|
@ -430,6 +431,7 @@ public class EntityTypeProvider {
|
|||
new CsdlNavigationProperty()
|
||||
.setName("NavPropertyETKeyNavOne")
|
||||
.setType(nameETKeyNav)
|
||||
.setPartner("NavPropertyETTwoKeyNavMany")
|
||||
.setReferentialConstraints(Arrays.asList(
|
||||
new CsdlReferentialConstraint()
|
||||
.setProperty("PropertyInt16")
|
||||
|
|
|
@ -18,10 +18,13 @@
|
|||
*/
|
||||
package org.apache.olingo.server.tecsvc.provider;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
|
||||
import org.apache.olingo.commons.api.edm.provider.CsdlReferentialConstraint;
|
||||
|
||||
public class PropertyProvider {
|
||||
|
||||
|
@ -775,6 +778,7 @@ public class PropertyProvider {
|
|||
public static final CsdlNavigationProperty collectionNavPropertyETMediaMany_ETMedia = new CsdlNavigationProperty()
|
||||
.setName("NavPropertyETMediaMany")
|
||||
.setType(EntityTypeProvider.nameETMedia)
|
||||
.setPartner("NavPropertyETKeyNavOne")
|
||||
.setCollection(true);
|
||||
|
||||
public static final CsdlNavigationProperty collectionNavPropertyETTwoKeyNavMany_ETTwoKeyNav_WithPartnerERKeyNavOne =
|
||||
|
@ -853,6 +857,15 @@ public class PropertyProvider {
|
|||
.setType(EntityTypeProvider.nameETTwoPrim)
|
||||
.setNullable(false);
|
||||
|
||||
public static final CsdlNavigationProperty navPropertyETMediaOne_ETKeyNavMany = new CsdlNavigationProperty()
|
||||
.setName("NavPropertyETKeyNavOne")
|
||||
.setType(EntityTypeProvider.nameETKeyNav)
|
||||
.setPartner("NavPropertyETMediaMany")
|
||||
.setReferentialConstraints(Arrays.asList(
|
||||
new CsdlReferentialConstraint()
|
||||
.setProperty("PropertyInt16")
|
||||
.setReferencedProperty("PropertyInt16")));
|
||||
|
||||
public static final CsdlNavigationProperty navPropertyETAllPrimOne_ETAllPrim = new CsdlNavigationProperty()
|
||||
.setName("NavPropertyETAllPrimOne")
|
||||
.setType(EntityTypeProvider.nameETAllPrim);
|
||||
|
|
|
@ -1327,6 +1327,9 @@ public class ODataXmlSerializerTest {
|
|||
" <a:link rel=\"edit\" href=\"ESMedia(1)\"/>\n" +
|
||||
" <a:content type=\"image/svg+xml\" src=\"ESMedia(1)/$value\" />\n" +
|
||||
" <a:link rel=\"edit-media\" title=\"ESMedia\" href=\"ESMedia(1)/$value\"/>\n" +
|
||||
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETKeyNavOne\" "
|
||||
+ "type=\"application/atom+xml;type=feed\" title=\"NavPropertyETKeyNavOne\" "
|
||||
+ "href=\"ESMedia(1)/NavPropertyETKeyNavOne\"/>" +
|
||||
" <a:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETMedia\" />\n" +
|
||||
" <m:properties>\n" +
|
||||
|
@ -1366,6 +1369,9 @@ public class ODataXmlSerializerTest {
|
|||
" <a:link rel=\"edit\" href=\"ESMedia(1)\"/>\n" +
|
||||
" <a:content type=\"image/svg+xml\" src=\"ESMedia(1)/$value\" />\n" +
|
||||
" <a:link rel=\"edit-media\" title=\"ESMedia\" href=\"ESMedia(1)/$value\"/>\n" +
|
||||
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETKeyNavOne\" "
|
||||
+ "type=\"application/atom+xml;type=feed\" "
|
||||
+ "title=\"NavPropertyETKeyNavOne\" href=\"ESMedia(1)/NavPropertyETKeyNavOne\"/>" +
|
||||
" <a:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETMedia\" />\n" +
|
||||
" <m:properties>\n" +
|
||||
|
@ -1383,6 +1389,9 @@ public class ODataXmlSerializerTest {
|
|||
" <a:link rel=\"edit\" href=\"ESMedia(2)\"/>\n" +
|
||||
" <a:content type=\"image/svg+xml\" src=\"ESMedia(2)/$value\" />\n" +
|
||||
" <a:link rel=\"edit-media\" title=\"ESMedia\" href=\"ESMedia(2)/$value\"/>\n" +
|
||||
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETKeyNavOne\" "
|
||||
+ "type=\"application/atom+xml;type=feed\" "
|
||||
+ "title=\"NavPropertyETKeyNavOne\" href=\"ESMedia(2)/NavPropertyETKeyNavOne\"/>" +
|
||||
" <a:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETMedia\" />\n" +
|
||||
" <m:properties>\n" +
|
||||
|
@ -1400,6 +1409,9 @@ public class ODataXmlSerializerTest {
|
|||
" <a:link rel=\"edit\" href=\"ESMedia(3)\"/>\n" +
|
||||
" <a:content type=\"image/svg+xml\" src=\"ESMedia(3)/$value\" />\n" +
|
||||
" <a:link rel=\"edit-media\" title=\"ESMedia\" href=\"ESMedia(3)/$value\"/>\n" +
|
||||
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETKeyNavOne\" "
|
||||
+ "type=\"application/atom+xml;type=feed\" "
|
||||
+ "title=\"NavPropertyETKeyNavOne\" href=\"ESMedia(3)/NavPropertyETKeyNavOne\"/>" +
|
||||
" <a:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETMedia\" />\n" +
|
||||
" <m:properties>\n" +
|
||||
|
@ -1417,6 +1429,9 @@ public class ODataXmlSerializerTest {
|
|||
" <a:link rel=\"edit\" href=\"ESMedia(4)\"/>\n" +
|
||||
" <a:content type=\"image/svg+xml\" src=\"ESMedia(4)/$value\" />\n" +
|
||||
" <a:link rel=\"edit-media\" title=\"ESMedia\" href=\"ESMedia(4)/$value\"/>\n" +
|
||||
" <a:link rel=\"http://docs.oasis-open.org/odata/ns/related/NavPropertyETKeyNavOne\" "
|
||||
+ "type=\"application/atom+xml;type=feed\" "
|
||||
+ "title=\"NavPropertyETKeyNavOne\" href=\"ESMedia(4)/NavPropertyETKeyNavOne\"/>" +
|
||||
" <a:category scheme=\"http://docs.oasis-open.org/odata/ns/scheme\"\n" +
|
||||
" term=\"#olingo.odata.test1.ETMedia\" />\n" +
|
||||
" <m:properties>\n" +
|
||||
|
|
|
@ -117,6 +117,15 @@ public class UriParserTest {
|
|||
.isType(EntityTypeProvider.nameETTwoKeyNav)
|
||||
.isTypeFilterOnEntry(EntityTypeProvider.nameETBaseTwoKeyNav)
|
||||
.n().isRef();
|
||||
|
||||
testRes.run("ESKeyNav(1)/NavPropertyETTwoKeyNavMany(PropertyInt16=1,PropertyString='1')")
|
||||
.isEntityType("ETTwoKeyNav")
|
||||
.isKeyPredicateForNavSeg(0, "PropertyInt16", "1")
|
||||
.isKeyPredicateForNavSeg(1, "PropertyString", "'1'");
|
||||
|
||||
testRes.run("ESKeyNav(1)/NavPropertyETMediaMany(1)")
|
||||
.isEntityType("ETMedia")
|
||||
.isKeyPredicateForNavSeg(0, "PropertyInt16", "1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -23,6 +23,8 @@ import static org.junit.Assert.assertNotNull;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmElement;
|
||||
import org.apache.olingo.commons.api.edm.EdmType;
|
||||
|
@ -237,12 +239,27 @@ public class ResourceValidator implements TestValidator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ResourceValidator isKeyPredicateForNavSeg(final int index, final String name, final String text) {
|
||||
final UriParameter keyPredicate = getKeyPredicateForNavSegment(index);
|
||||
assertEquals(name, keyPredicate.getName());
|
||||
assertEquals(text, keyPredicate.getText());
|
||||
return this;
|
||||
}
|
||||
|
||||
private UriParameter getKeyPredicate(final int index) {
|
||||
assertTrue("invalid resource kind: " + uriPathInfo.getKind().toString(),
|
||||
uriPathInfo instanceof UriResourceWithKeysImpl);
|
||||
return ((UriResourceWithKeysImpl) uriPathInfo).getKeyPredicates().get(index);
|
||||
}
|
||||
|
||||
private UriParameter getKeyPredicateForNavSegment(final int index) {
|
||||
List<UriResource> uriResources = uriInfo.getUriResourceParts();
|
||||
UriResource lastSegment = uriResources.get(uriResources.size() - 1);
|
||||
assertTrue("invalid resource kind: " + lastSegment.getKind(),
|
||||
lastSegment instanceof UriResourceNavigation);
|
||||
return ((UriResourceNavigation)lastSegment).getKeyPredicates().get(index);
|
||||
}
|
||||
|
||||
public ResourceValidator isParameter(final int index, final String name, final String text) {
|
||||
isUriPathInfoKind(UriResourceKind.function);
|
||||
final UriParameter parameter = ((UriResourceFunction) uriPathInfo).getParameters().get(index);
|
||||
|
@ -320,6 +337,14 @@ public class ResourceValidator implements TestValidator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ResourceValidator isEntityType(final String name) {
|
||||
isUriPathInfoKind(UriResourceKind.entitySet);
|
||||
List<UriResource> uriResources = uriInfo.getUriResourceParts();
|
||||
UriResource lastSegment = uriResources.get(uriResources.size() - 1);
|
||||
assertEquals(name, ((UriResourceNavigation)lastSegment).getType().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceValidator isSingleton(final String name) {
|
||||
isUriPathInfoKind(UriResourceKind.singleton);
|
||||
assertEquals(name, ((UriResourceSingleton) uriPathInfo).getSingleton().getName());
|
||||
|
|
Loading…
Reference in New Issue