[OLINGO-365] All former tests now pass with new StructuredComposableInvokerInvocationHandler: time to add specific checks for new features
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/fce2155c Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/fce2155c Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/fce2155c Branch: refs/heads/master Commit: fce2155cd55b9134959005ec81fcadc577fcd6e2 Parents: c0b92cf Author: Francesco Chicchiriccò <--global> Authored: Mon Aug 4 11:17:24 2014 +0200 Committer: Francesco Chicchiriccò <--global> Committed: Mon Aug 4 11:17:24 2014 +0200 ---------------------------------------------------------------------- .../commons/AbstractInvocationHandler.java | 1 + .../AbstractStructuredInvocationHandler.java | 9 +- .../ext/proxy/commons/InvokerHandler.java | 341 ------------------ .../proxy/commons/InvokerInvocationHandler.java | 342 +++++++++++++++++++ .../commons/OperationInvocationHandler.java | 28 +- ...turedComposableInvokerInvocationHandler.java | 84 +++++ .../olingo/ext/proxy/utils/ProxyUtils.java | 11 +- .../src/main/resources/operation.vm | 4 +- .../fit/proxy/v4/APIBasicDesignTestITCase.java | 15 +- .../olingo/fit/proxy/v4/AsyncTestITCase.java | 9 +- .../v4/BoundOperationInvokeTestITCase.java | 14 +- .../v4/OperationImportInvokeTestITCase.java | 13 +- .../services/odatawcfservice/types/Account.java | 2 +- .../services/odatawcfservice/types/Person.java | 2 +- .../services/odatawcfservice/types/Product.java | 2 +- .../odatawcfservice/types/ProductDetail.java | 2 +- .../olingo/fit/tecsvc/client/BasicITCase.java | 2 +- 17 files changed, 486 insertions(+), 395 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java index cde3fc7..3dcec81 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java @@ -84,6 +84,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler { protected Object invokeSelfMethod(final Method method, final Object[] args) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + return getClass().getMethod(method.getName(), method.getParameterTypes()).invoke(this, args); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java index b9710db..3189842 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java @@ -297,10 +297,10 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca res = Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), new Class<?>[] {EdmStreamValue.class}, new EdmStreamValueHandler( - baseURI == null - ? null - : getClient().newURIBuilder(baseURI.toASCIIString()).appendPropertySegment(name).build(), - service)); + baseURI == null + ? null + : getClient().newURIBuilder(baseURI.toASCIIString()).appendPropertySegment(name).build(), + service)); streamedPropertyCache.put(name, EdmStreamValue.class.cast(res)); } @@ -322,7 +322,6 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca getEntityHandler(), baseURI, false); - } else if (ref != null && ComplexCollection.class.isAssignableFrom(ref)) { final ComplexCollectionInvocationHandler<?> collectionHandler; final Class<?> itemRef = ClassUtils.extractTypeArg(ref, ComplexCollection.class); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerHandler.java deleted file mode 100644 index 2c27dc3..0000000 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerHandler.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.ext.proxy.commons; - -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.lang.reflect.Type; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.Future; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent; -import org.apache.olingo.client.api.http.HttpMethod; -import org.apache.olingo.client.api.uri.CommonURIBuilder; -import org.apache.olingo.client.api.uri.URIFilter; -import org.apache.olingo.client.core.uri.URIUtils; -import org.apache.olingo.commons.api.domain.CommonODataEntity; -import org.apache.olingo.commons.api.domain.CommonODataEntitySet; -import org.apache.olingo.commons.api.domain.CommonODataProperty; -import org.apache.olingo.commons.api.domain.ODataInvokeResult; -import org.apache.olingo.commons.api.domain.ODataValue; -import org.apache.olingo.commons.api.edm.EdmFunction; -import org.apache.olingo.commons.api.edm.EdmOperation; -import org.apache.olingo.commons.api.edm.EdmReturnType; -import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; -import org.apache.olingo.ext.proxy.AbstractService; -import org.apache.olingo.ext.proxy.api.ComplexCollection; -import org.apache.olingo.ext.proxy.api.EntityCollection; -import org.apache.olingo.ext.proxy.api.OperationType; -import org.apache.olingo.ext.proxy.api.PrimitiveCollection; -import org.apache.olingo.ext.proxy.api.Sort; -import org.apache.olingo.ext.proxy.api.annotations.Operation; -import org.apache.olingo.ext.proxy.utils.ClassUtils; -import org.apache.olingo.ext.proxy.utils.CoreUtils; -import org.apache.olingo.ext.proxy.utils.ProxyUtils; - -public class InvokerHandler<T, O> extends AbstractInvocationHandler { - - private final URI baseURI; - - private CommonURIBuilder<?> uri; - - private final Map<String, ODataValue> parameters; - - private final Operation operation; - - private final EdmOperation edmOperation; - - private final Class<T> targetRef; - - private final Class<?> operationRef; - - public InvokerHandler( - final URI uri, - final Map<String, ODataValue> parameters, - final Operation operation, - final EdmOperation edmOperation, - final Type[] references, - final AbstractService<?> service) { - - super(service); - - this.baseURI = uri; - this.uri = this.baseURI == null ? null : service.getClient().newURIBuilder(this.baseURI.toASCIIString()); - this.parameters = parameters; - this.edmOperation = edmOperation; - this.operation = operation; - if (references.length > 0) { - this.targetRef = ClassUtils.<T>getTypeClass(references[0]); - this.operationRef = references.length > 1 ? ClassUtils.<T>getTypeClass(references[1]) : null; - } else { - this.targetRef = null; - this.operationRef = null; - } - } - - public Future<T> executeAsync() { - return service.getClient().getConfiguration().getExecutor().submit(new Callable<T>() { - - @Override - public T call() throws Exception { - return execute(); - } - }); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - public T execute() { - if (operation == null || uri == null) { - throw new IllegalStateException("Invalid operation"); - } - - try { - // 1. IMPORTANT: flush any pending change *before* invoke if this operation is side effecting - if (operation.type() == OperationType.ACTION) { - service.getPersistenceManager().flush(); - } - - // 2. invoke - final ODataInvokeResult result = service.getClient().getInvokeRequestFactory().getInvokeRequest( - edmOperation instanceof EdmFunction ? HttpMethod.GET : HttpMethod.POST, - uri.build(), - getResultReference(edmOperation.getReturnType()), - parameters). - execute().getBody(); - - // 3. process invoke result - if (StringUtils.isBlank(operation.returnType())) { - return (T) ClassUtils.returnVoid(); - } - - final EdmTypeInfo edmType = new EdmTypeInfo.Builder(). - setEdm(service.getClient().getCachedEdm()).setTypeExpression(operation.returnType()).build(); - - if (edmType.isEntityType()) { - if (edmType.isCollection()) { - final Class<?> collItemType = ClassUtils.extractTypeArg(targetRef, EntityCollection.class); - return (T) ProxyUtils.getEntityCollectionProxy( - service, - collItemType, - targetRef, - null, - (CommonODataEntitySet) result, - this.baseURI, - false); - } else { - return (T) ProxyUtils.getEntityProxy( - service, - (CommonODataEntity) result, - null, - targetRef, - null, - false); - } - } else { - Object res; - - final Class<?> ref = ClassUtils.getTypeClass(targetRef); - final CommonODataProperty property = (CommonODataProperty) result; - - if (property == null || property.hasNullValue()) { - res = null; - } else if (edmType.isCollection()) { - if (edmType.isComplexType()) { - final Class<?> itemRef = ClassUtils.extractTypeArg(ref, ComplexCollection.class); - final List items = new ArrayList(); - - for (ODataValue item : property.getValue().asCollection()) { - items.add(ProxyUtils.getComplex( - service, - property.getName(), - item, - itemRef, - null, - null, - true)); - } - - res = Proxy.newProxyInstance( - Thread.currentThread().getContextClassLoader(), - new Class<?>[] {ref}, new ComplexCollectionInvocationHandler( - service, - items, - itemRef, - null)); - } else { - final List items = new ArrayList(); - - for (ODataValue item : property.getValue().asCollection()) { - items.add(item.asPrimitive().toValue()); - } - - res = Proxy.newProxyInstance( - Thread.currentThread().getContextClassLoader(), - new Class<?>[] {PrimitiveCollection.class}, new PrimitiveCollectionInvocationHandler( - service, - items, - null, - null)); - } - } else { - if (edmType.isComplexType()) { - res = ProxyUtils.getComplex( - service, property.getName(), property.getValue().asComplex(), ref, null, null, false); - } else { - res = CoreUtils.getObjectFromODataValue(property.getValue(), targetRef, service); - } - } - - return (T) res; - } - } catch (Exception e) { - throw new IllegalStateException(e); - } - } - - @SuppressWarnings("unchecked") - private <RES extends ODataInvokeResult> Class<RES> getResultReference(final EdmReturnType returnType) { - Class<RES> result; - - if (returnType == null) { - result = (Class<RES>) ODataNoContent.class; - } else { - if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { - result = (Class<RES>) CommonODataEntitySet.class; - } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { - result = (Class<RES>) CommonODataEntity.class; - } else { - result = (Class<RES>) CommonODataProperty.class; - } - } - - return result; - } - - @Override - @SuppressWarnings({"unchecked", "rawtype"}) - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if ("filter".equals(method.getName()) - || "orderBy".equals(method.getName()) - || "top".equals(method.getName()) - || "skip".equals(method.getName()) - || "expand".equals(method.getName()) - || "select".equals(method.getName())) { - invokeSelfMethod(method, args); - return proxy; - } else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) { - final EdmTypeInfo returnType = new EdmTypeInfo.Builder(). - setEdm(service.getClient().getCachedEdm()).setTypeExpression(operation.returnType()).build(); - - final URI prefixURI = URIUtils.buildFunctionInvokeURI(this.baseURI, parameters, getClient().getServiceVersion()); - - OperationInvocationHandler handler; - - if (returnType.isComplexType()) { - if (returnType.isCollection()) { - handler = OperationInvocationHandler.getInstance(new ComplexCollectionInvocationHandler( - targetRef, service, getClient().newURIBuilder(prefixURI.toASCIIString()))); - } else { - handler = OperationInvocationHandler.getInstance(ComplexInvocationHandler.getInstance( - targetRef, service, getClient().newURIBuilder(prefixURI.toASCIIString()))); - } - } else { - if (returnType.isCollection()) { - handler = OperationInvocationHandler.getInstance(new EntityCollectionInvocationHandler( - service, null, targetRef, null, getClient().newURIBuilder(prefixURI.toASCIIString()))); - } else { - handler = OperationInvocationHandler.getInstance(EntityInvocationHandler.getInstance( - prefixURI, targetRef, service)); - } - } - - return Proxy.newProxyInstance( - Thread.currentThread().getContextClassLoader(), - new Class<?>[] {operationRef}, handler); - } else if (isSelfMethod(method, args)) { - return invokeSelfMethod(method, args); - } else { - throw new NoSuchMethodException(method.getName()); - } - } - - public void filter(final String filter) { - if (this.uri != null) { - this.uri.filter(filter); - } - } - - public void filter(final URIFilter filter) { - if (this.uri != null) { - this.uri.filter(filter); - } - } - - public void orderBy(final Sort... sort) { - if (this.uri != null) { - final StringBuilder builder = new StringBuilder(); - for (Sort sortClause : sort) { - builder.append(sortClause.getKey()).append(' ').append(sortClause.getValue()).append(','); - } - builder.deleteCharAt(builder.length() - 1); - - this.uri.orderBy(builder.toString()); - } - } - - public void orderBy(final String orderBy) { - if (this.uri != null) { - this.uri.orderBy(orderBy); - } - } - - public void top(final int top) throws IllegalArgumentException { - if (this.uri != null) { - this.uri.top(top); - } - } - - public void skip(final int skip) throws IllegalArgumentException { - if (this.uri != null) { - this.uri.skip(skip); - } - } - - public void expand(final String... expand) { - if (this.uri != null) { - this.uri.expand(expand); - } - } - - public void select(final String... select) { - if (this.uri != null) { - this.uri.select(select); - } - } - - public void clearQueryOptions() { - this.uri = this.baseURI == null ? null : getClient().newURIBuilder(baseURI.toASCIIString()); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerInvocationHandler.java new file mode 100644 index 0000000..a28f4e7 --- /dev/null +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/InvokerInvocationHandler.java @@ -0,0 +1,342 @@ +/* + * 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. + */ +package org.apache.olingo.ext.proxy.commons; + +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.lang.reflect.Type; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent; +import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.client.api.uri.CommonURIBuilder; +import org.apache.olingo.client.api.uri.URIFilter; +import org.apache.olingo.client.core.uri.URIUtils; +import org.apache.olingo.commons.api.domain.CommonODataEntity; +import org.apache.olingo.commons.api.domain.CommonODataEntitySet; +import org.apache.olingo.commons.api.domain.CommonODataProperty; +import org.apache.olingo.commons.api.domain.ODataInvokeResult; +import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.edm.EdmFunction; +import org.apache.olingo.commons.api.edm.EdmOperation; +import org.apache.olingo.commons.api.edm.EdmReturnType; +import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import org.apache.olingo.ext.proxy.AbstractService; +import org.apache.olingo.ext.proxy.api.ComplexCollection; +import org.apache.olingo.ext.proxy.api.EntityCollection; +import org.apache.olingo.ext.proxy.api.OperationType; +import org.apache.olingo.ext.proxy.api.Operations; +import org.apache.olingo.ext.proxy.api.PrimitiveCollection; +import org.apache.olingo.ext.proxy.api.Sort; +import org.apache.olingo.ext.proxy.api.annotations.Operation; +import org.apache.olingo.ext.proxy.utils.ClassUtils; +import org.apache.olingo.ext.proxy.utils.CoreUtils; +import org.apache.olingo.ext.proxy.utils.ProxyUtils; + +public class InvokerInvocationHandler<T, O extends Operations> extends AbstractInvocationHandler { + + private final URI baseURI; + + private CommonURIBuilder<?> uri; + + private final Map<String, ODataValue> parameters; + + private final Operation operation; + + private final EdmOperation edmOperation; + + protected final Class<T> targetRef; + + private final Class<?> operationRef; + + public InvokerInvocationHandler( + final URI uri, + final Map<String, ODataValue> parameters, + final Operation operation, + final EdmOperation edmOperation, + final Type[] references, + final AbstractService<?> service) { + + super(service); + + this.baseURI = uri; + this.uri = this.baseURI == null ? null : service.getClient().newURIBuilder(this.baseURI.toASCIIString()); + this.parameters = parameters; + this.operation = operation; + this.edmOperation = edmOperation; + if (references.length > 0) { + this.targetRef = ClassUtils.<T>getTypeClass(references[0]); + this.operationRef = references.length > 1 ? ClassUtils.<T>getTypeClass(references[1]) : null; + } else { + this.targetRef = null; + this.operationRef = null; + } + } + + public Future<T> executeAsync() { + return service.getClient().getConfiguration().getExecutor().submit(new Callable<T>() { + + @Override + public T call() throws Exception { + return execute(); + } + }); + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + public T execute() { + if (operation == null || uri == null) { + throw new IllegalStateException("Invalid operation"); + } + + try { + // 1. IMPORTANT: flush any pending change *before* invoke if this operation is side effecting + if (operation.type() == OperationType.ACTION) { + service.getPersistenceManager().flush(); + } + + // 2. invoke + final ODataInvokeResult result = service.getClient().getInvokeRequestFactory().getInvokeRequest( + edmOperation instanceof EdmFunction ? HttpMethod.GET : HttpMethod.POST, + uri.build(), + getResultReference(edmOperation.getReturnType()), + parameters). + execute().getBody(); + + // 3. process invoke result + if (StringUtils.isBlank(operation.returnType())) { + return (T) ClassUtils.returnVoid(); + } + + final EdmTypeInfo returnType = new EdmTypeInfo.Builder(). + setEdm(service.getClient().getCachedEdm()).setTypeExpression(operation.returnType()).build(); + + if (returnType.isEntityType()) { + if (returnType.isCollection()) { + final Class<?> collItemType = ClassUtils.extractTypeArg(targetRef, EntityCollection.class); + return (T) ProxyUtils.getEntityCollectionProxy( + service, + collItemType, + targetRef, + null, + (CommonODataEntitySet) result, + this.baseURI, + false); + } else { + return (T) ProxyUtils.getEntityProxy( + service, + (CommonODataEntity) result, + null, + targetRef, + null, + false); + } + } else { + Object res; + + final Class<?> ref = ClassUtils.getTypeClass(targetRef); + final CommonODataProperty property = (CommonODataProperty) result; + + if (property == null || property.hasNullValue()) { + res = null; + } else if (returnType.isCollection()) { + if (returnType.isComplexType()) { + final Class<?> itemRef = ClassUtils.extractTypeArg(ref, ComplexCollection.class); + final List items = new ArrayList(); + + for (ODataValue item : property.getValue().asCollection()) { + items.add(ProxyUtils.getComplexProxy( + service, + property.getName(), + item, + itemRef, + null, + null, + true)); + } + + res = Proxy.newProxyInstance( + Thread.currentThread().getContextClassLoader(), + new Class<?>[] {ref}, new ComplexCollectionInvocationHandler( + service, + items, + itemRef, + null)); + } else { + final List items = new ArrayList(); + + for (ODataValue item : property.getValue().asCollection()) { + items.add(item.asPrimitive().toValue()); + } + + res = Proxy.newProxyInstance( + Thread.currentThread().getContextClassLoader(), + new Class<?>[] {PrimitiveCollection.class}, new PrimitiveCollectionInvocationHandler( + service, + items, + null, + null)); + } + } else { + if (returnType.isComplexType()) { + res = ProxyUtils.getComplexProxy( + service, property.getName(), property.getValue().asComplex(), ref, null, null, false); + } else { + res = CoreUtils.getObjectFromODataValue(property.getValue(), targetRef, service); + } + } + + return (T) res; + } + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + + @SuppressWarnings("unchecked") + private <RES extends ODataInvokeResult> Class<RES> getResultReference(final EdmReturnType returnType) { + Class<RES> result; + + if (returnType == null) { + result = (Class<RES>) ODataNoContent.class; + } else { + if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { + result = (Class<RES>) CommonODataEntitySet.class; + } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { + result = (Class<RES>) CommonODataEntity.class; + } else { + result = (Class<RES>) CommonODataProperty.class; + } + } + + return result; + } + + @Override + @SuppressWarnings({"unchecked", "rawtype"}) + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if ("filter".equals(method.getName()) + || "orderBy".equals(method.getName()) + || "top".equals(method.getName()) + || "skip".equals(method.getName()) + || "expand".equals(method.getName()) + || "select".equals(method.getName())) { + invokeSelfMethod(method, args); + return proxy; + } else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) { + final EdmTypeInfo returnType = new EdmTypeInfo.Builder(). + setEdm(service.getClient().getCachedEdm()).setTypeExpression(operation.returnType()).build(); + + final URI prefixURI = URIUtils.buildFunctionInvokeURI(this.baseURI, parameters, getClient().getServiceVersion()); + + OperationInvocationHandler handler; + + if (returnType.isComplexType()) { + if (returnType.isCollection()) { + handler = OperationInvocationHandler.getInstance(new ComplexCollectionInvocationHandler( + targetRef, service, getClient().newURIBuilder(prefixURI.toASCIIString()))); + } else { + handler = OperationInvocationHandler.getInstance(ComplexInvocationHandler.getInstance( + targetRef, service, getClient().newURIBuilder(prefixURI.toASCIIString()))); + } + } else { + if (returnType.isCollection()) { + handler = OperationInvocationHandler.getInstance(new EntityCollectionInvocationHandler( + service, null, targetRef, null, getClient().newURIBuilder(prefixURI.toASCIIString()))); + } else { + handler = OperationInvocationHandler.getInstance(EntityInvocationHandler.getInstance( + prefixURI, targetRef, service)); + } + } + + return Proxy.newProxyInstance( + Thread.currentThread().getContextClassLoader(), + new Class<?>[] {operationRef}, handler); + } else if (isSelfMethod(method, args)) { + return invokeSelfMethod(method, args); + } else { + throw new NoSuchMethodException(method.getName()); + } + } + + public void filter(final String filter) { + if (this.uri != null) { + this.uri.filter(filter); + } + } + + public void filter(final URIFilter filter) { + if (this.uri != null) { + this.uri.filter(filter); + } + } + + public void orderBy(final Sort... sort) { + if (this.uri != null) { + final StringBuilder builder = new StringBuilder(); + for (Sort sortClause : sort) { + builder.append(sortClause.getKey()).append(' ').append(sortClause.getValue()).append(','); + } + builder.deleteCharAt(builder.length() - 1); + + this.uri.orderBy(builder.toString()); + } + } + + public void orderBy(final String orderBy) { + if (this.uri != null) { + this.uri.orderBy(orderBy); + } + } + + public void top(final int top) throws IllegalArgumentException { + if (this.uri != null) { + this.uri.top(top); + } + } + + public void skip(final int skip) throws IllegalArgumentException { + if (this.uri != null) { + this.uri.skip(skip); + } + } + + public void expand(final String... expand) { + if (this.uri != null) { + this.uri.expand(expand); + } + } + + public void select(final String... select) { + if (this.uri != null) { + this.uri.select(select); + } + } + + public void clearQueryOptions() { + this.uri = this.baseURI == null ? null : getClient().newURIBuilder(baseURI.toASCIIString()); + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java index 00630aa..7751d52 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java @@ -185,20 +185,36 @@ final class OperationInvocationHandler extends AbstractInvocationHandler { final ODataValue paramValue = parameter.getValue() == null ? null : CoreUtils.getODataValue(service.getClient(), parameterType, parameter.getValue()); - + parameterValues.put(parameter.getKey().name(), paramValue); } - return Proxy.newProxyInstance( - Thread.currentThread().getContextClassLoader(), - new Class<?>[] {ClassUtils.getTypeClass(method.getGenericReturnType())}, - new InvokerHandler( + final EdmTypeInfo returnType = edmOperation.getValue().getReturnType() == null + ? null + : new EdmTypeInfo.Builder().setEdm(service.getClient().getCachedEdm()).setTypeExpression( + edmOperation.getValue().getReturnType().getType().getFullQualifiedName().toString()).build(); + + final InvokerInvocationHandler handler = returnType != null + && (returnType.isEntityType() || returnType.isComplexType()) && operation.isComposable() + ? new StructuredComposableInvokerInvocationHandler( + edmOperation.getKey(), + parameterValues, + operation, + edmOperation.getValue(), + ClassUtils.getTypeArguments(method.getReturnType().getGenericInterfaces()[0]), + returnType, + service) + : new InvokerInvocationHandler( edmOperation.getKey(), parameterValues, operation, edmOperation.getValue(), ClassUtils.getTypeArguments(method.getGenericReturnType()), - service)); + service); + return Proxy.newProxyInstance( + Thread.currentThread().getContextClassLoader(), + new Class<?>[] {ClassUtils.getTypeClass(method.getGenericReturnType())}, + handler); } else { throw new NoSuchMethodException(method.getName()); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/StructuredComposableInvokerInvocationHandler.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/StructuredComposableInvokerInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/StructuredComposableInvokerInvocationHandler.java new file mode 100644 index 0000000..64e00c9 --- /dev/null +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/StructuredComposableInvokerInvocationHandler.java @@ -0,0 +1,84 @@ +/* + * 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. + */ +package org.apache.olingo.ext.proxy.commons; + +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.net.URI; +import java.util.Map; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.edm.EdmOperation; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import org.apache.olingo.ext.proxy.AbstractService; +import org.apache.olingo.ext.proxy.api.Operations; +import org.apache.olingo.ext.proxy.api.annotations.Operation; + +public class StructuredComposableInvokerInvocationHandler<T, O extends Operations> + extends InvokerInvocationHandler<T, O> { + + private AbstractStructuredInvocationHandler structuredHandler; + + public StructuredComposableInvokerInvocationHandler( + final URI uri, + final Map<String, ODataValue> parameters, + final Operation operation, + final EdmOperation edmOperation, + final Type[] references, + final EdmTypeInfo returnType, + final AbstractService<?> service) { + + super(uri, parameters, operation, edmOperation, references, service); + + if (!edmOperation.getReturnType().isCollection()) { + if (returnType.isEntityType()) { + this.structuredHandler = EntityInvocationHandler.getInstance( + uri, targetRef, service); + } + if (returnType.isComplexType()) { + this.structuredHandler = ComplexInvocationHandler.getInstance( + targetRef, service, service.getClient().newURIBuilder(uri.toASCIIString())); + } + } + } + + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { + if (method.getName().startsWith("get")) { + return structuredHandler.invoke(proxy, method, args); + } else if (method.getName().startsWith("set")) { + return structuredHandler.invoke(proxy, method, args); + } else if ("filter".equals(method.getName()) + || "orderBy".equals(method.getName()) + || "top".equals(method.getName()) + || "skip".equals(method.getName()) + || "expand".equals(method.getName()) + || "select".equals(method.getName())) { + + return super.invoke(proxy, method, args); + } else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) { + return super.invoke(proxy, method, args); + } else if (isSelfMethod(method, args)) { + return invokeSelfMethod(method, args); + } else { + throw new NoSuchMethodException(method.getName()); + } + } + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ProxyUtils.java ---------------------------------------------------------------------- diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ProxyUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ProxyUtils.java index 65b6ff0..7e7ccb4 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ProxyUtils.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/ProxyUtils.java @@ -25,7 +25,6 @@ import org.apache.olingo.commons.api.domain.CommonODataEntity; import org.apache.olingo.commons.api.domain.CommonODataEntitySet; import org.apache.olingo.commons.api.domain.ODataValue; import org.apache.olingo.ext.proxy.AbstractService; -import org.apache.olingo.ext.proxy.api.ComplexType; import org.apache.olingo.ext.proxy.commons.ComplexInvocationHandler; import org.apache.olingo.ext.proxy.commons.EntityCollectionInvocationHandler; import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler; @@ -55,7 +54,7 @@ public class ProxyUtils { Thread.currentThread().getContextClassLoader(), new Class<?>[] {typeCollectionRef}, new EntityCollectionInvocationHandler(service, items, typeCollectionRef, targetEntitySetURI, - uri == null ? null : service.getClient().newURIBuilder(uri.toASCIIString()))); + uri == null ? null : service.getClient().newURIBuilder(uri.toASCIIString()))); } public static Object getEntitySetProxy( @@ -95,7 +94,7 @@ public class ProxyUtils { handler); } - public static ComplexType getComplex( + public static Object getComplexProxy( final AbstractService<?> service, final String name, final ODataValue value, @@ -130,10 +129,8 @@ public class ProxyUtils { complexHandler.setEntityHandler(handler); - final ComplexType res = ComplexType.class.cast(Proxy.newProxyInstance( + return Proxy.newProxyInstance( Thread.currentThread().getContextClassLoader(), - new Class<?>[] {actualRef}, complexHandler)); - - return res; + new Class<?>[] {actualRef}, complexHandler); } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/ext/pojogen-maven-plugin/src/main/resources/operation.vm ---------------------------------------------------------------------- diff --git a/ext/pojogen-maven-plugin/src/main/resources/operation.vm b/ext/pojogen-maven-plugin/src/main/resources/operation.vm index c2376b7..e23b8b8 100644 --- a/ext/pojogen-maven-plugin/src/main/resources/operation.vm +++ b/ext/pojogen-maven-plugin/src/main/resources/operation.vm @@ -30,13 +30,13 @@ *##else#* *##if(${operation.ReturnType.Type.Kind} == "ENTITY" || ${operation.ReturnType.Type.Kind} == "COMPLEX")#* *##if($operation.getReturnType().isCollection())#* - *##if($operationComposable)#* + *##if($operation.Composable)#* *##set($returnType = "${defaultType}ComposableInvoker")#* *##{else}#* *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredCollectionInvoker<$defaultType>")#* *##end#* *##{else}#* - *##if($operationComposable)#* + *##if($operation.Composable)#* *##set($returnType = "${defaultType}ComposableInvoker")#* *##{else}#* *##set($returnType = "org.apache.olingo.ext.proxy.api.StructuredInvoker<$defaultType>")#* http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java index 510f0cb..ce537de 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java @@ -37,9 +37,6 @@ import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.ext.proxy.AbstractService; import org.apache.olingo.ext.proxy.api.EdmStreamValue; import org.apache.olingo.ext.proxy.api.PrimitiveCollection; -import org.apache.olingo.ext.proxy.api.StructuredCollectionComposableInvoker; -import org.apache.olingo.ext.proxy.api.StructuredCollectionInvoker; -import org.apache.olingo.ext.proxy.api.StructuredComposableInvoker; import org.junit.Test; //CHECKSTYLE:OFF (Maven checkstyle) @@ -60,10 +57,13 @@ import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.service import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderCollection; 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.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonComposableInvoker; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Product; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductCollection; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductCollectionComposableInvoker; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetail; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollection; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollectionComposableInvoker; //CHECKSTYLE:ON (Maven checkstyle) public class APIBasicDesignTestITCase extends AbstractTestITCase { @@ -390,7 +390,7 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase { product.setDetails(detailCollection); getContainer().getProducts().add(product); - + // The first HTTP Request to create product and the linked product detail getContainer().flush(); @@ -398,7 +398,7 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase { assertNotNull(product.operations().addAccessRight(AccessLevel.None).execute()); // The third HTTP Request to access a bound operation via entity URL - final StructuredCollectionInvoker<ProductDetailCollection> result = + final ProductDetailCollectionComposableInvoker result = container.getProducts().getByKey(1012).operations().getProductDetails(1); assertEquals(1, result.execute().size()); } @@ -541,8 +541,7 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase { @Test public void workingWithComposableOperations() { - final StructuredCollectionComposableInvoker<ProductCollection, ProductCollection.Operations> invoker1 = - container.operations().getAllProducts(); + final ProductCollectionComposableInvoker invoker1 = container.operations().getAllProducts(); // Complex/Entity collection (available filter, select, expand, orderBy, skip and top) invoker1.operations().discount(10). // discount is an operation of ProductCollecton @@ -551,7 +550,7 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase { expand("ProductDetail"). orderBy("Name").skip(3).top(5).execute(); - final StructuredComposableInvoker<Person, Person.Operations> invoker2 = container.operations().getPerson2("London"); + final PersonComposableInvoker invoker2 = container.operations().getPerson2("London"); // Complex/Entity (available only select and expand: after query option composition is not available anymore) invoker2.select("Name"). // after the first query option no composition is possible http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java index 837fda4..855fe36 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java @@ -28,14 +28,14 @@ import org.junit.Test; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import org.apache.olingo.commons.api.ODataRuntimeException; -import org.apache.olingo.ext.proxy.api.StructuredCollectionComposableInvoker; -import org.apache.olingo.ext.proxy.api.StructuredComposableInvoker; //CHECKSTYLE:OFF (Maven checkstyle) import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CustomerCollection; 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.PersonComposableInvoker; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductCollection; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductCollectionComposableInvoker; //CHECKSTYLE:ON (Maven checkstyle) public class AsyncTestITCase extends AbstractTestITCase { @@ -77,8 +77,7 @@ public class AsyncTestITCase extends AbstractTestITCase { @Test public void invoke() throws Exception { - final StructuredCollectionComposableInvoker<ProductCollection, ProductCollection.Operations> invoker1 = - container.operations().getAllProducts(); + final ProductCollectionComposableInvoker invoker1 = container.operations().getAllProducts(); final Future<ProductCollection> future1 = invoker1.operations(). discount(10). @@ -91,7 +90,7 @@ public class AsyncTestITCase extends AbstractTestITCase { } assertFalse(future1.get().isEmpty()); - final StructuredComposableInvoker<Person, Person.Operations> invoker2 = container.operations().getPerson2("London"); + final PersonComposableInvoker invoker2 = container.operations().getPerson2("London"); final Future<Person> future2 = invoker2.select("Name"). expand("Order").executeAsync(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java index fadbeb7..2777618 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java @@ -23,21 +23,19 @@ import static org.junit.Assert.assertNotNull; import java.sql.Timestamp; import java.util.Calendar; -import org.apache.olingo.ext.proxy.api.StructuredCollectionInvoker; -import org.apache.olingo.ext.proxy.api.StructuredInvoker; import org.junit.Test; //CHECKSTYLE:OFF (Maven checkstyle) import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel; -import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfo; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfoComposableInvoker; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument; 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.Product; -import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollection; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailKey; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AddressCollection; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductComposableInvoker; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollectionComposableInvoker; //CHECKSTYLE:ON (Maven checkstyle) public class BoundOperationInvokeTestITCase extends AbstractTestITCase { @@ -49,7 +47,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { @Test public void getProductDetails() { - final StructuredCollectionInvoker<ProductDetailCollection> result = + final ProductDetailCollectionComposableInvoker result = container.getProducts().getByKey(5).operations().getProductDetails(1); assertEquals(1, result.execute().size()); } @@ -60,7 +58,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { key.setProductID(6); key.setProductDetailID(1); - final StructuredInvoker<Product> product = + final ProductComposableInvoker product = container.getProductDetails().getByKey(key).operations().getRelatedProduct(); assertEquals(6, product.execute().getProductID(), 0); } @@ -73,7 +71,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { @Test public void getAccountInfo() { - final StructuredInvoker<AccountInfo> accountInfo = + final AccountInfoComposableInvoker accountInfo = container.getAccounts().getByKey(101).operations().getAccountInfo(); assertNotNull(accountInfo.execute()); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OperationImportInvokeTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OperationImportInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OperationImportInvokeTestITCase.java index b6400e4..52d1e18 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OperationImportInvokeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OperationImportInvokeTestITCase.java @@ -23,16 +23,14 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.apache.olingo.ext.proxy.api.PrimitiveCollection; -import org.apache.olingo.ext.proxy.api.StructuredCollectionComposableInvoker; -import org.apache.olingo.ext.proxy.api.StructuredComposableInvoker; //CHECKSTYLE:OFF (Maven checkstyle) import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Color; -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.ProductCollection; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonComposableInvoker; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductCollectionComposableInvoker; //CHECKSTYLE:ON (Maven checkstyle) public class OperationImportInvokeTestITCase extends AbstractTestITCase { @@ -45,7 +43,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { @Test public void getPerson2() { - final StructuredComposableInvoker<Person, Person.Operations> person = container.operations().getPerson2("London"); + final PersonComposableInvoker person = container.operations().getPerson2("London"); assertEquals(1, person.execute().getPersonID(), 0); } @@ -56,14 +54,13 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { address.setPostalCode("98052"); address.setCity("London"); - final StructuredComposableInvoker<Person, Person.Operations> person = container.operations().getPerson(address); + final PersonComposableInvoker person = container.operations().getPerson(address); assertEquals(1, person.execute().getPersonID(), 0); } @Test public void getAllProducts() { - final StructuredCollectionComposableInvoker<ProductCollection, ProductCollection.Operations> products = - container.operations().getAllProducts(); + final ProductCollectionComposableInvoker products = container.operations().getAllProducts(); assertEquals(5, products.execute().size()); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Account.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Account.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Account.java index b3b88a4..6b7656f 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Account.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Account.java @@ -150,7 +150,7 @@ public interface Account type = OperationType.FUNCTION, isComposable = true, referenceType = org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfo.class, returnType = "Microsoft.Test.OData.Services.ODataWCFService.AccountInfo") - org.apache.olingo.ext.proxy.api.StructuredInvoker<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfo> getAccountInfo( + org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfoComposableInvoker getAccountInfo( ); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Person.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Person.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Person.java index 33de5f6..9a323aa 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Person.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Person.java @@ -244,7 +244,7 @@ public interface Person type = OperationType.FUNCTION, isComposable = true, referenceType = org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress.class, returnType = "Microsoft.Test.OData.Services.ODataWCFService.HomeAddress") - org.apache.olingo.ext.proxy.api.StructuredInvoker<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress> getHomeAddress( + org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddressComposableInvoker getHomeAddress( ); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Product.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Product.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Product.java index 4a49ba2..83dc5ff 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Product.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Product.java @@ -267,7 +267,7 @@ public interface Product type = OperationType.FUNCTION, isComposable = true, referenceType = org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollection.class, returnType = "Collection(Microsoft.Test.OData.Services.ODataWCFService.ProductDetail)") - org.apache.olingo.ext.proxy.api.StructuredCollectionInvoker<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollection> getProductDetails( + org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollectionComposableInvoker getProductDetails( @Parameter(name = "count", type = "Edm.Int32", nullable = true) java.lang.Integer count ); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductDetail.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductDetail.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductDetail.java index 011b05c..99ad05a 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductDetail.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductDetail.java @@ -162,7 +162,7 @@ public interface ProductDetail type = OperationType.FUNCTION, isComposable = true, referenceType = org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Product.class, returnType = "Microsoft.Test.OData.Services.ODataWCFService.Product") - org.apache.olingo.ext.proxy.api.StructuredInvoker<org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Product> getRelatedProduct( + org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductComposableInvoker getRelatedProduct( ); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fce2155c/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java index 6df42eb..1cb234c 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java @@ -1,4 +1,4 @@ -/* +/* * 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
