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 2014/05/12 10:38:58 UTC
[23/50] [abbrv] git commit: Adding test for nested query option
Adding test for nested query option
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/367f61d6
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/367f61d6
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/367f61d6
Branch: refs/heads/olingo274
Commit: 367f61d63cd74e8f92e2ccf5b784cc664db9a717
Parents: 8bb1f0b
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu May 8 15:07:43 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu May 8 15:07:43 2014 +0200
----------------------------------------------------------------------
.../org/apache/olingo/fit/AbstractServices.java | 3 +-
.../olingo/fit/v4/QueryOptionsTestITCase.java | 39 +++++++++++++++-----
2 files changed, 31 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/367f61d6/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
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 2252c55..1a3cb88 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -990,7 +990,7 @@ public abstract class AbstractServices {
final String entitySetName,
final String entityId,
final String format,
- final String expand,
+ String expand,
final String select,
final boolean keyAsSegment) {
@@ -1047,6 +1047,7 @@ public abstract class AbstractServices {
}
if (StringUtils.isNotBlank(expand)) {
+ expand = StringUtils.substringBefore(expand, "(");
final List<String> links = Arrays.asList(expand.split(","));
final Map<Link, Link> replace = new HashMap<Link, Link>();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/367f61d6/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
index 44e860c..0ba6e90 100644
--- a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java
@@ -30,7 +30,10 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.v4.URIBuilder;
+
import static org.apache.olingo.fit.v4.AbstractTestITCase.client;
+
+import org.apache.olingo.client.api.uri.QueryOption;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
@@ -51,7 +54,22 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
+
+ final ODataEntity customer = req.execute().getBody();
+ assertTrue(customer.getNavigationLink("Orders") instanceof ODataInlineEntitySet);
+ }
+
+ @Test
+ public void expandWithFilter() {
+ // TODO: simplify as per OLINGO-223
+ final StringBuilder expandWithFilter = new StringBuilder("Orders(").
+ append('$').append(QueryOption.FILTER).append('=').
+ append(getClient().getFilterFactory().gt("OrderID", 7).build()).
+ append(')');
+ final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
+ appendEntitySetSegment("Customers").appendKeySegment(1).expand(expandWithFilter.toString());
+
+ final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntity customer = req.execute().getBody();
assertTrue(customer.getNavigationLink("Orders") instanceof ODataInlineEntitySet);
@@ -70,7 +88,6 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
// 1. check that filtered entity set looks as expected
ODataEntitySetRequest<ODataEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON);
ODataEntitySet feed = req.execute().getBody();
assertNotNull(feed);
@@ -86,7 +103,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
// 3. add orderby clause to filter above
req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.orderBy("PersonID desc").build());
- req.setFormat(ODataPubFormat.JSON);
+
feed = req.execute().getBody();
assertNotNull(feed);
assertEquals(2, feed.getEntities().size());
@@ -128,9 +145,10 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
// 1. check that filtered entity set looks as expected
- ODataEntitySetRequest<ODataEntitySet> req =
+ final ODataEntitySetRequest<ODataEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.skip(2).build());
- ODataEntitySet feed = req.execute().getBody();
+
+ final ODataEntitySet feed = req.execute().getBody();
assertEquals(3, feed.getEntities().size());
}
@@ -141,9 +159,10 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
// 1. check that filtered entity set looks as expected
- ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
+ final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.top(2).build());
- ODataEntitySet feed = req.execute().getBody();
+
+ final ODataEntitySet feed = req.execute().getBody();
assertEquals(2, feed.getEntities().size());
}
@@ -157,7 +176,6 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final ODataEntitySetRequest<ODataEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON);
final ODataEntitySet feed = req.execute().getBody();
assertNotNull(feed);
@@ -178,7 +196,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final ODataEntitySetRequest<ODataEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON);
+
final ODataEntitySet feed = req.execute().getBody();
assertNotNull(feed);
assertEquals(feed.getEntities().size(), feed.getCount());
@@ -193,7 +211,6 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Customers").appendKeySegment(1).select("PersonID,Orders").expand("Orders");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
final ODataEntity customer = req.execute().getBody();
assertEquals(1, customer.getProperties().size());
@@ -208,6 +225,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
expandWithSelect("Orders", "OrderID", "OrderDetails");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
+
final ODataRetrieveResponse<ODataEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
}
@@ -220,6 +238,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final ODataEntitySetRequest<ODataEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(builder.build());
+
final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
assertEquals(200, res.getStatusCode());
assertFalse(res.getBody().getEntities().isEmpty());