You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/05/19 15:28:11 UTC
[22/50] [abbrv] git commit: [OLINGO-260] provided singleton
integration test on proxy
[OLINGO-260] provided singleton integration test on proxy
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/d4400f60
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/d4400f60
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/d4400f60
Branch: refs/heads/master
Commit: d4400f608e90f9458fdb45761aebd73fae655780
Parents: 9902955
Author: fmartelli <fa...@gmail.com>
Authored: Tue May 13 14:40:56 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Mon May 19 14:31:37 2014 +0200
----------------------------------------------------------------------
.../commons/EntitySetInvocationHandler.java | 27 +++++++++++++++++---
.../fit/proxy/v4/SingletonTestITCase.java | 25 ++++++++----------
2 files changed, 33 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d4400f60/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java
----------------------------------------------------------------------
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 10c68f2..209c8ea 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
@@ -55,6 +55,7 @@ import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
import org.apache.olingo.ext.proxy.context.EntityContext;
import org.apache.olingo.ext.proxy.context.EntityUUID;
import org.apache.olingo.ext.proxy.utils.ClassUtils;
+import org.apache.olingo.ext.proxy.utils.CoreUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -276,11 +277,29 @@ class EntitySetInvocationHandler<C extends CommonEdmEnabledODataClient<?>, T ext
LOG.debug("Execute query '{}'", uriBuilder.toString());
- final ODataRetrieveResponse<CommonODataEntity> res =
- client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()).execute();
+ final CommonODataEntity entity;
+ final String etag;
- handler = EntityTypeInvocationHandler.getInstance(res.getBody(), this, typeRef);
- handler.setETag(res.getETag());
+ if (isSingleton) {
+ final ODataRetrieveResponse<org.apache.olingo.commons.api.domain.v4.Singleton> res =
+ ((ODataClient) client).getRetrieveRequestFactory().getSingletonRequest(uri).execute();
+
+ entity = res.getBody();
+ etag = res.getETag();
+ } else {
+ final ODataRetrieveResponse<CommonODataEntity> res =
+ client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()).execute();
+
+ etag = res.getETag();
+ entity = res.getBody();
+
+ if (entity == null || !key.equals(CoreUtils.getKey(client, typeRef, entity))) {
+ throw new IllegalArgumentException("Invalid singleton " + typeRef.getSimpleName() + "(" + key + ")");
+ }
+ }
+
+ handler = EntityTypeInvocationHandler.getInstance(entity, this, typeRef);
+ handler.setETag(etag);
} catch (Exception e) {
LOG.info("Entity '" + uuid + "' not found", e);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d4400f60/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java
index d9467bc..6886756 100644
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java
@@ -19,27 +19,22 @@
package org.apache.olingo.fit.proxy.v4;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyCategory;
import org.junit.Test;
+/**
+ * This is the unit test class to check entity create operations.
+ */
public class SingletonTestITCase extends AbstractTestITCase {
@Test
public void read() {
- final Company company = container.getCompany().get();
- assertEquals(0, company.getCompanyID(), 0);
- assertEquals(CompanyCategory.IT, company.getCompanyCategory());
- }
-
- @Test
- public void update() {
- final Company company = container.getCompany().get();
- company.setRevenue(132520L);
-
- container.flush();
-
- assertEquals(132520L, container.getCompany().get().getRevenue(), 0);
+ assertNotNull(container.getCompany().get(0));
+ entityContext.detachAll();
+ assertNotNull(container.getCompany().iterator().next());
+ entityContext.detachAll();
+ assertEquals(1, container.getCompany().count(), 0);
+ entityContext.detachAll();
}
}