From 935a9b84b9ac2a6b2fafa73ac0ad7cfabf3f36c5 Mon Sep 17 00:00:00 2001 From: Christian Holzer Date: Thu, 16 Apr 2015 16:32:33 +0200 Subject: [PATCH] [OLINGO-424] Fix: The client proxy sets entity type segements to the right position --- .../commons/EntitySetInvocationHandler.java | 9 +- .../apache/olingo/fit/AbstractServices.java | 62 ++-- .../org/apache/olingo/fit/V4Services.java | 2 +- .../filter/(PersonID lt 4).full.json | 84 +++++ .../filter/(PersonID lt 4).xml | 68 ++++ .../feed.full.json | 333 ++++++++++++++++++ .../feed.xml | 219 ++++++++++++ .../olingo/fit/proxy/v4/FilterTestITCase.java | 23 +- 8 files changed, 770 insertions(+), 30 deletions(-) create mode 100644 fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Employee/filter/(PersonID lt 4).full.json create mode 100644 fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Employee/filter/(PersonID lt 4).xml create mode 100644 fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Person/feed.full.json create mode 100644 fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Person/feed.xml diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java index 6b7ff9c9a..2f943d6e7 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java @@ -169,20 +169,19 @@ public class EntitySetInvocationHandler< final Class oref = (Class) ClassUtils.extractTypeArg(this.collItemRef, AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class); - final URIBuilder uriBuilder = getClient().newURIBuilder(this.uri.build().toASCIIString()); - + if (!oref.equals(ref)) { - uriBuilder.appendDerivedEntityTypeSegment(new FullQualifiedName( + uri.appendDerivedEntityTypeSegment(new FullQualifiedName( ClassUtils.getNamespace(ref), ClassUtils.getEntityTypeName(ref)).toString()); } final List anns = new ArrayList(); - final Triple, URI, List> entitySet = fetchPartial(uriBuilder.build(), (Class) ref); + final Triple, URI, List> entitySet = fetchPartial(uri.build(), (Class) ref); anns.addAll(entitySet.getRight()); final EntityCollectionInvocationHandler entityCollectionHandler = new EntityCollectionInvocationHandler( - service, (List) entitySet.getLeft(), collTypeRef, this.baseURI, uriBuilder); + service, (List) entitySet.getLeft(), collTypeRef, this.baseURI, uri); entityCollectionHandler.setAnnotations(anns); entityCollectionHandler.nextPageURI = entitySet.getMiddle(); diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java index 01f0d924a..b04e7ed63 100644 --- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java +++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java @@ -927,23 +927,10 @@ public abstract class AbstractServices { return xml.createFaultResponse(accept, e); } } - - /** - * Retrieve entity set or function execution sample. - * - * @param accept Accept header. - * @param name entity set or function name. - * @param format format query option. - * @param count inlinecount query option. - * @param filter filter query option. - * @param orderby orderby query option. - * @param skiptoken skiptoken query option. - * @return entity set or function result. - */ + @GET - @Path("/{name}") - public Response getEntitySet( - @Context final UriInfo uriInfo, + @Path("/{name}/{type:[a-zA-Z].*}") + public Response getEntitySet(@Context final UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, @PathParam("name") final String name, @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top, @@ -952,8 +939,9 @@ public abstract class AbstractServices { @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count, @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter, @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby, - @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) { - + @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken, + @PathParam("type") final String type) { + try { final Accept acceptType; if (StringUtils.isNotBlank(format)) { @@ -971,13 +959,17 @@ public abstract class AbstractServices { if (acceptType == Accept.XML || acceptType == Accept.TEXT) { throw new UnsupportedMediaTypeException("Unsupported media type"); } - + // search for entitySet ... final String basePath = name + File.separatorChar; final StringBuilder builder = new StringBuilder(); builder.append(basePath); - + + if(type != null) { + builder.append(type).append(File.separatorChar); + } + if (StringUtils.isNotBlank(orderby)) { builder.append(Constants.get(ConstantKey.ORDERBY)).append(File.separatorChar). append(orderby).append(File.separatorChar); @@ -1039,6 +1031,36 @@ public abstract class AbstractServices { return xml.createFaultResponse(accept, e); } } + + + /** + * Retrieve entity set or function execution sample. + * + * @param accept Accept header. + * @param name entity set or function name. + * @param format format query option. + * @param count inlinecount query option. + * @param filter filter query option. + * @param orderby orderby query option. + * @param skiptoken skiptoken query option. + * @return entity set or function result. + */ + @GET + @Path("/{name}") + public Response getEntitySet( + @Context final UriInfo uriInfo, + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, + @PathParam("name") final String name, + @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top, + @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, + @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count, + @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter, + @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby, + @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) { + + return getEntitySet(uriInfo, accept, name, top, skip, format, count, filter, orderby, skiptoken, null); + } protected abstract void setInlineCount(final EntityCollection feed, final String count); diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java index 4a4100266..711cdf035 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java @@ -395,7 +395,7 @@ public class V4Services extends AbstractServices { ? super.getEntityInternal( uriInfo.getRequestUri().toASCIIString(), accept, "People", type, format, null, null) : super.getEntitySet(accept, "People", type) - : super.getEntitySet(uriInfo, accept, "People", top, skip, format, count, filter, orderby, skiptoken); + : super.getEntitySet(uriInfo, accept, "People", top, skip, format, count, filter, orderby, skiptoken, type); } @GET diff --git a/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Employee/filter/(PersonID lt 4).full.json b/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Employee/filter/(PersonID lt 4).full.json new file mode 100644 index 000000000..60ce2fead --- /dev/null +++ b/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Employee/filter/(PersonID lt 4).full.json @@ -0,0 +1,84 @@ +{ + "@odata.context": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/$metadata#People", + "value": + [ + { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Employee", + "@odata.id": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)", + "@odata.editLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee", + "PersonID": 3, + "FirstName": "Jacob", + "LastName": "Zip", + "MiddleName": null, + "HomeAddress": + { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Address", + "Street": "1 Microsoft Way", + "City": "Sydney", + "PostalCode": "98052" + }, + "Home@odata.type": "#GeographyPoint", + "Home": + { + "type": "Point", + "coordinates": + [ + 161.8, + 15 + ], + "crs": + { + "type": "name", + "properties": + { + "name": "EPSG:4326" + } + } + }, + "Numbers@odata.type": "#Collection(String)", + "Numbers": + [ + "333-333-3333" + ], + "Emails@odata.type": "#Collection(String)", + "Emails": + [ + null + ], + "DateHired@odata.type": "#DateTimeOffset", + "DateHired": "2010-12-13T00:00:00Z", + "Office@odata.type": "#GeographyPoint", + "Office": + { + "type": "Point", + "coordinates": + [ + 162, + 15 + ], + "crs": + { + "type": "name", + "properties": + { + "name": "EPSG:4326" + } + } + }, + "Parent@odata.associationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Parent/$ref", + "Parent@odata.navigationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Parent", + "Company@odata.associationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Company/$ref", + "Company@odata.navigationLink": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Company", + "#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress", + "target": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress" + }, + "#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress", + "target": "http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress" + } + } + ] +} \ No newline at end of file diff --git a/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Employee/filter/(PersonID lt 4).xml b/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Employee/filter/(PersonID lt 4).xml new file mode 100644 index 000000000..ff9c95243 --- /dev/null +++ b/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Employee/filter/(PersonID lt 4).xml @@ -0,0 +1,68 @@ + + + + http://odatae2etest.azurewebsites.net/javatest/DefaultService/People + + <updated>2014-05-08T16:18:03Z</updated> + <entry> + <id>http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)</id> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.Employee" scheme="http://docs.oasis-open.org/odata/ns/scheme" /> + <link rel="edit" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Parent" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://odatae2etest.azurewebsites.net/javatest/DefaultService/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Company" /> + <title /> + <updated>2014-05-08T16:18:03Z</updated> + <author> + <name /> + </author> + <content type="application/xml"> + <m:properties> + <d:PersonID m:type="Int32">3</d:PersonID> + <d:FirstName>Jacob</d:FirstName> + <d:LastName>Zip</d:LastName> + <d:MiddleName m:null="true" /> + <d:HomeAddress m:type="#Microsoft.Test.OData.Services.ODataWCFService.Address"> + <d:Street>1 Microsoft Way</d:Street> + <d:City>Sydney</d:City> + <d:PostalCode>98052</d:PostalCode> + </d:HomeAddress> + <d:Home m:type="GeographyPoint"> + <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> + <gml:pos>15 161.8</gml:pos> + </gml:Point> + </d:Home> + <d:Numbers m:type="#Collection(String)"> + <m:element>333-333-3333</m:element> + </d:Numbers> + <d:Emails m:type="#Collection(String)"> + <m:element m:null="true" /> + </d:Emails> + <d:DateHired m:type="DateTimeOffset">2010-12-13T00:00:00Z</d:DateHired> + <d:Office m:type="GeographyPoint"> + <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> + <gml:pos>15 162</gml:pos> + </gml:Point> + </d:Office> + </m:properties> + </content> + </entry> +</feed> \ No newline at end of file diff --git a/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Person/feed.full.json b/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Person/feed.full.json new file mode 100644 index 000000000..3e0dda8a4 --- /dev/null +++ b/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Person/feed.full.json @@ -0,0 +1,333 @@ +{ + "@odata.context": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#People", + "value": + [ + { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Customer", + "@odata.id": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)", + "@odata.editLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer", + "PersonID": 1, + "FirstName": "Bob", + "LastName": "Cat", + "MiddleName": null, + "HomeAddress": + { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.HomeAddress", + "Street": "1 Microsoft Way", + "City": "London", + "PostalCode": "98052", + "FamilyName": "Cats" + }, + "Home@odata.type": "#GeographyPoint", + "Home": + { + "type": "Point", + "coordinates": + [ + 23.1, + 32.1 + ], + "crs": + { + "type": "name", + "properties": + { + "name": "EPSG:4326" + } + } + }, + "Numbers@odata.type": "#Collection(String)", + "Numbers": + [ + "111-111-1111" + ], + "Emails@odata.type": "#Collection(String)", + "Emails": + [ + "abc@abc.com" + ], + "City": "London", + "Birthday@odata.type": "#DateTimeOffset", + "Birthday": "1957-04-03T00:00:00Z", + "TimeBetweenLastTwoOrders@odata.type": "#Duration", + "TimeBetweenLastTwoOrders": "PT0.0000001S", + "Parent@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent/$ref", + "Parent@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent", + "Orders@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders/$ref", + "Orders@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders", + "Company@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company/$ref", + "Company@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company", + "#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress" + }, + "#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress" + } + }, + { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Customer", + "@odata.id": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)", + "@odata.editLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer", + "PersonID": 2, + "FirstName": "Jill", + "LastName": "Jones", + "MiddleName": null, + "HomeAddress": null, + "Home@odata.type": "#GeographyPoint", + "Home": + { + "type": "Point", + "coordinates": + [ + 161.8, + 15 + ], + "crs": + { + "type": "name", + "properties": + { + "name": "EPSG:4326" + } + } + }, + "Numbers@odata.type": "#Collection(String)", + "Numbers": + [ + ], + "Emails@odata.type": "#Collection(String)", + "Emails": + [ + ], + "City": "Sydney", + "Birthday@odata.type": "#DateTimeOffset", + "Birthday": "1983-01-15T00:00:00Z", + "TimeBetweenLastTwoOrders@odata.type": "#Duration", + "TimeBetweenLastTwoOrders": "PT0.0000002S", + "Parent@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent/$ref", + "Parent@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent", + "Orders@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders/$ref", + "Orders@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders", + "Company@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company/$ref", + "Company@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company", + "#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress" + }, + "#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress" + } + }, + { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Employee", + "@odata.id": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)", + "@odata.editLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee", + "PersonID": 3, + "FirstName": "Jacob", + "LastName": "Zip", + "MiddleName": null, + "HomeAddress": + { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Address", + "Street": "1 Microsoft Way", + "City": "Sydney", + "PostalCode": "98052" + }, + "Home@odata.type": "#GeographyPoint", + "Home": + { + "type": "Point", + "coordinates": + [ + 161.8, + 15 + ], + "crs": + { + "type": "name", + "properties": + { + "name": "EPSG:4326" + } + } + }, + "Numbers@odata.type": "#Collection(String)", + "Numbers": + [ + "333-333-3333" + ], + "Emails@odata.type": "#Collection(String)", + "Emails": + [ + null + ], + "DateHired@odata.type": "#DateTimeOffset", + "DateHired": "2010-12-13T00:00:00Z", + "Office@odata.type": "#GeographyPoint", + "Office": + { + "type": "Point", + "coordinates": + [ + 162, + 15 + ], + "crs": + { + "type": "name", + "properties": + { + "name": "EPSG:4326" + } + } + }, + "Parent@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Parent/$ref", + "Parent@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Parent", + "Company@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Company/$ref", + "Company@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Company", + "#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress" + }, + "#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress" + } + }, + { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Employee", + "@odata.id": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)", + "@odata.editLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee", + "PersonID": 4, + "FirstName": "Elmo", + "LastName": "Rogers", + "MiddleName": null, + "HomeAddress": null, + "Home@odata.type": "#GeographyPoint", + "Home": + { + "type": "Point", + "coordinates": + [ + -61.8, + -15 + ], + "crs": + { + "type": "name", + "properties": + { + "name": "EPSG:4326" + } + } + }, + "Numbers@odata.type": "#Collection(String)", + "Numbers": + [ + "444-444-4444", + "555-555-5555", + "666-666-6666" + ], + "Emails@odata.type": "#Collection(String)", + "Emails": + [ + "def@def.org", + "lmn@lmn.com" + ], + "DateHired@odata.type": "#DateTimeOffset", + "DateHired": "2008-03-27T00:00:00Z", + "Office@odata.type": "#GeographyPoint", + "Office": + { + "type": "Point", + "coordinates": + [ + -62, + -15 + ], + "crs": + { + "type": "name", + "properties": + { + "name": "EPSG:4326" + } + } + }, + "Parent@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Parent/$ref", + "Parent@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Parent", + "Company@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Company/$ref", + "Company@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Company", + "#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress" + }, + "#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress" + } + }, + { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Person", + "@odata.id": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(5)", + "@odata.editLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(5)", + "PersonID": 5, + "FirstName": "Peter", + "LastName": "Bee", + "MiddleName": null, + "HomeAddress": null, + "Home@odata.type": "#GeographyPoint", + "Home": + { + "type": "Point", + "coordinates": + [ + -261.8, + -16 + ], + "crs": + { + "type": "name", + "properties": + { + "name": "EPSG:4326" + } + } + }, + "Numbers@odata.type": "#Collection(String)", + "Numbers": + [ + "555-555-5555" + ], + "Emails@odata.type": "#Collection(String)", + "Emails": + [ + "def@test.msn" + ], + "Parent@odata.associationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(5)/Parent/$ref", + "Parent@odata.navigationLink": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(5)/Parent", + "#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(5)/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress" + }, + "#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress": + { + "title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress", + "target": "http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(5)/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress" + } + } + ], + "odata.nextLink": "People?$skiptoken=5" +} \ No newline at end of file diff --git a/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Person/feed.xml b/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Person/feed.xml new file mode 100644 index 000000000..ee58f0a83 --- /dev/null +++ b/fit/src/main/resources/V40/People/Microsoft.Test.OData.Services.ODataWCFService.Person/feed.xml @@ -0,0 +1,219 @@ +<?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. + +--> +<feed xml:base="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/" + xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" + xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" + xmlns:georss="http://www.georss.org/georss" + xmlns:gml="http://www.opengis.net/gml" + m:context="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#People"> + <id>http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People</id> + <title /> + <updated>2014-03-20T14:31:00Z</updated> + <entry> + <id>http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)</id> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.Customer" scheme="http://docs.oasis-open.org/odata/ns/scheme" /> + <link rel="edit" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(1)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company" /> + <title /> + <updated>2014-03-20T14:31:00Z</updated> + <author> + <name /> + </author> + <content type="application/xml"> + <m:properties> + <d:PersonID m:type="Int32">1</d:PersonID> + <d:FirstName>Bob</d:FirstName> + <d:LastName>Cat</d:LastName> + <d:MiddleName m:null="true" /> + <d:HomeAddress m:type="#Microsoft.Test.OData.Services.ODataWCFService.HomeAddress"> + <d:Street>1 Microsoft Way</d:Street> + <d:City>London</d:City> + <d:PostalCode>98052</d:PostalCode> + <d:FamilyName>Cats</d:FamilyName> + </d:HomeAddress> + <d:Home m:type="GeographyPoint"> + <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> + <gml:pos>32.1 23.1</gml:pos> + </gml:Point> + </d:Home> + <d:Numbers m:type="#Collection(String)"> + <m:element>111-111-1111</m:element> + </d:Numbers> + <d:Emails m:type="#Collection(String)"> + <m:element>abc@abc.com</m:element> + </d:Emails> + <d:City>London</d:City> + <d:Birthday m:type="DateTimeOffset">1957-04-03T00:00:00Z</d:Birthday> + <d:TimeBetweenLastTwoOrders m:type="Duration">PT0.0000001S</d:TimeBetweenLastTwoOrders> + </m:properties> + </content> + </entry> + <entry> + <id>http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)</id> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.Customer" scheme="http://docs.oasis-open.org/odata/ns/scheme" /> + <link rel="edit" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(2)/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company" /> + <title /> + <updated>2014-03-20T14:31:00Z</updated> + <author> + <name /> + </author> + <content type="application/xml"> + <m:properties> + <d:PersonID m:type="Int32">2</d:PersonID> + <d:FirstName>Jill</d:FirstName> + <d:LastName>Jones</d:LastName> + <d:MiddleName m:null="true" /> + <d:HomeAddress m:null="true" /> + <d:Home m:type="GeographyPoint"> + <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> + <gml:pos>15 161.8</gml:pos> + </gml:Point> + </d:Home> + <d:Numbers m:type="#Collection(String)" /> + <d:Emails m:type="#Collection(String)" /> + <d:City>Sydney</d:City> + <d:Birthday m:type="DateTimeOffset">1983-01-15T00:00:00Z</d:Birthday> + <d:TimeBetweenLastTwoOrders m:type="Duration">PT0.0000002S</d:TimeBetweenLastTwoOrders> + </m:properties> + </content> + </entry> + <entry> + <id>http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)</id> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.Employee" scheme="http://docs.oasis-open.org/odata/ns/scheme" /> + <link rel="edit" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Parent" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(3)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Company" /> + <title /> + <updated>2014-03-20T14:31:00Z</updated> + <author> + <name /> + </author> + <content type="application/xml"> + <m:properties> + <d:PersonID m:type="Int32">3</d:PersonID> + <d:FirstName>Jacob</d:FirstName> + <d:LastName>Zip</d:LastName> + <d:MiddleName m:null="true" /> + <d:HomeAddress m:type="#Microsoft.Test.OData.Services.ODataWCFService.Address"> + <d:Street>1 Microsoft Way</d:Street> + <d:City>Sydney</d:City> + <d:PostalCode>98052</d:PostalCode> + </d:HomeAddress> + <d:Home m:type="GeographyPoint"> + <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> + <gml:pos>15 161.8</gml:pos> + </gml:Point> + </d:Home> + <d:Numbers m:type="#Collection(String)"> + <m:element>333-333-3333</m:element> + </d:Numbers> + <d:Emails m:type="#Collection(String)"> + <m:element m:null="true" /> + </d:Emails> + <d:DateHired m:type="DateTimeOffset">2010-12-13T00:00:00Z</d:DateHired> + <d:Office m:type="GeographyPoint"> + <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> + <gml:pos>15 162</gml:pos> + </gml:Point> + </d:Office> + </m:properties> + </content> + </entry> + <entry> + <id>http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)</id> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.Employee" scheme="http://docs.oasis-open.org/odata/ns/scheme" /> + <link rel="edit" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Parent" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(4)/Microsoft.Test.OData.Services.ODataWCFService.Employee/Company" /> + <title /> + <updated>2014-03-20T14:31:00Z</updated> + <author> + <name /> + </author> + <content type="application/xml"> + <m:properties> + <d:PersonID m:type="Int32">4</d:PersonID> + <d:FirstName>Elmo</d:FirstName> + <d:LastName>Rogers</d:LastName> + <d:MiddleName m:null="true" /> + <d:HomeAddress m:null="true" /> + <d:Home m:type="GeographyPoint"> + <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> + <gml:pos>-15 -61.8</gml:pos> + </gml:Point> + </d:Home> + <d:Numbers m:type="#Collection(String)"> + <m:element>444-444-4444</m:element> + <m:element>555-555-5555</m:element> + <m:element>666-666-6666</m:element> + </d:Numbers> + <d:Emails m:type="#Collection(String)"> + <m:element>def@def.org</m:element> + <m:element>lmn@lmn.com</m:element> + </d:Emails> + <d:DateHired m:type="DateTimeOffset">2008-03-27T00:00:00Z</d:DateHired> + <d:Office m:type="GeographyPoint"> + <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> + <gml:pos>-15 -62</gml:pos> + </gml:Point> + </d:Office> + </m:properties> + </content> + </entry> + <entry> + <id>http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(5)</id> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.Person" scheme="http://docs.oasis-open.org/odata/ns/scheme" /> + <link rel="edit" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(5)" /> + <link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People(5)/Parent" /> + <title /> + <updated>2014-03-20T14:31:00Z</updated> + <author> + <name /> + </author> + <content type="application/xml"> + <m:properties> + <d:PersonID m:type="Int32">5</d:PersonID> + <d:FirstName>Peter</d:FirstName> + <d:LastName>Bee</d:LastName> + <d:MiddleName m:null="true" /> + <d:HomeAddress m:null="true" /> + <d:Home m:type="GeographyPoint"> + <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> + <gml:pos>-16 -261.8</gml:pos> + </gml:Point> + </d:Home> + <d:Numbers m:type="#Collection(String)"> + <m:element>555-555-5555</m:element> + </d:Numbers> + <d:Emails m:type="#Collection(String)"> + <m:element>def@test.msn</m:element> + </d:Emails> + </m:properties> + </content> + </entry> + <link rel="next" href="http://localhost:${tomcat.servlet.port}/stub/StaticService/V40/Static.svc/People?$skiptoken=5"/> +</feed> \ No newline at end of file diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java index 9c826d9d6..f889fd248 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java @@ -22,28 +22,43 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.apache.olingo.ext.proxy.api.Search; -import org.apache.olingo.ext.proxy.api.Sort; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.apache.olingo.ext.proxy.api.Search; +import org.apache.olingo.ext.proxy.api.Sort; //CHECKSTYLE:OFF (Maven checkstyle) import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.People; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.EmployeeCollection; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonCollection; +import org.junit.Test; //CHECKSTYLE:ON (Maven checkstyle) public class FilterTestITCase extends AbstractTestITCase { + @Test + public void testFilterWithEntityType() { + final People people = container.getPeople(); + final EmployeeCollection response = people.filter(service.getClient().getFilterFactory().lt("PersonID", 4)) + .execute(EmployeeCollection.class); + + assertEquals(1, response.size()); + + for(final Employee employee : response) { + assertEquals(Integer.valueOf(3), employee.getPersonID()); + } + } + @Test public void filterOrderby() { final People people = container.getPeople(); PersonCollection result = people.filter(service.getClient().getFilterFactory().lt("PersonID", 3)).execute(); - + // 1. check that result looks as expected assertEquals(2, result.size());