[OLINGO-564] Renamed 'OData*' to 'Client*' classes

This commit is contained in:
Michael Bolz 2015-04-28 23:11:55 +02:00
parent 53b10f6b7f
commit c37d4da571
209 changed files with 3790 additions and 3746 deletions

View File

@ -35,7 +35,7 @@ import org.apache.commons.lang3.tuple.Triple;
import org.apache.olingo.client.api.uri.QueryOption;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.api.uri.URIFilter;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.AbstractTerm;
import org.apache.olingo.ext.proxy.api.EntityType;
@ -59,7 +59,7 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
protected final Class<T> itemRef;
protected final List<ODataAnnotation> annotations = new ArrayList<ODataAnnotation>();
protected final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>();
private final Map<Class<? extends AbstractTerm>, Object> annotationsByTerm =
new HashMap<Class<? extends AbstractTerm>, Object>();
@ -92,7 +92,7 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
public Collection<T> execute() {
if (this.uri != null) {
final Triple<List<T>, URI, List<ODataAnnotation>> res = fetchPartial(this.uri.build(), itemRef);
final Triple<List<T>, URI, List<ClientAnnotation>> res = fetchPartial(this.uri.build(), itemRef);
this.nextPageURI = res.getMiddle();
if (items == null) {
@ -109,9 +109,9 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
return this;
}
public abstract Triple<List<T>, URI, List<ODataAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef);
public abstract Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef);
public void setAnnotations(final List<ODataAnnotation> annotations) {
public void setAnnotations(final List<ClientAnnotation> annotations) {
this.annotations.clear();
this.annotationsByTerm.clear();
this.annotations.addAll(annotations);
@ -145,8 +145,8 @@ public abstract class AbstractCollectionInvocationHandler<T extends Serializable
try {
final Term termAnn = term.getAnnotation(Term.class);
final Namespace namespaceAnn = term.getAnnotation(Namespace.class);
ODataAnnotation annotation = null;
for (ODataAnnotation _annotation : annotations) {
ClientAnnotation annotation = null;
for (ClientAnnotation _annotation : annotations) {
if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) {
annotation = _annotation;
}

View File

@ -30,10 +30,10 @@ import org.apache.olingo.client.api.ODataClient;
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.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataSingleton;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientSingleton;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
import org.apache.olingo.ext.proxy.api.AbstractSingleton;
@ -93,27 +93,27 @@ public abstract class AbstractEntityCollectionInvocationHandler<T extends Entity
@SuppressWarnings("unchecked")
@Override
public Triple<List<T>, URI, List<ODataAnnotation>> fetchPartial(
public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(
final URI uri, final Class<T> typeRef) {
final List<ODataEntity> entities = new ArrayList<ODataEntity>();
final List<ClientEntity> entities = new ArrayList<ClientEntity>();
final URI next;
final List<ODataAnnotation> anns = new ArrayList<ODataAnnotation>();
final List<ClientAnnotation> anns = new ArrayList<ClientAnnotation>();
if (isSingleton) {
final ODataRetrieveResponse<ODataSingleton> res =
final ODataRetrieveResponse<ClientSingleton> res =
((ODataClient) getClient()).getRetrieveRequestFactory().getSingletonRequest(uri).execute();
entities.add(res.getBody());
next = null;
} else {
final ODataEntitySetRequest<ODataEntitySet> req =
final ODataEntitySetRequest<ClientEntitySet> req =
getClient().getRetrieveRequestFactory().getEntitySetRequest(uri);
req.setPrefer(getClient().newPreferences().includeAnnotations("*"));
final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
final ODataRetrieveResponse<ClientEntitySet> res = req.execute();
final ODataEntitySet entitySet = res.getBody();
final ClientEntitySet entitySet = res.getBody();
entities.addAll(entitySet.getEntities());
next = entitySet.getNext();
anns.addAll(entitySet.getAnnotations());
@ -121,7 +121,7 @@ public abstract class AbstractEntityCollectionInvocationHandler<T extends Entity
final List<T> res = new ArrayList<T>(entities.size());
for (ODataEntity entity : entities) {
for (ClientEntity entity : entities) {
Class<?> actualRef = null;
if (entity.getTypeName() != null) {
actualRef = service.getEntityTypeClass(entity.getTypeName().toString());
@ -150,6 +150,6 @@ public abstract class AbstractEntityCollectionInvocationHandler<T extends Entity
handlerInTheContext == null ? handler : handlerInTheContext));
}
return new ImmutableTriple<List<T>, URI, List<ODataAnnotation>>(res, next, anns);
return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(res, next, anns);
}
}

View File

@ -32,8 +32,8 @@ import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.olingo.client.api.EdmEnabledODataClient;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.ComplexType;
@ -94,7 +94,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
protected ComplexType<?> getComplex(
final String name,
final ODataValue value,
final ClientValue value,
final Class<?> ref,
final EntityInvocationHandler handler,
final URI baseURI,
@ -153,7 +153,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
final String namespace = handler.getUUID().getType().getAnnotation(Namespace.class).value();
final ODataEntity template;
final ClientEntity template;
final URI entityURI;
if (handler.getEntityURI() == null || handler.getUUID().getKey() == null) {

View File

@ -40,9 +40,9 @@ import org.apache.olingo.client.api.communication.request.cud.ODataReferenceAddi
import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataLinkType;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.domain.ClientLinkType;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.EdmStreamValue;
import org.apache.olingo.ext.proxy.api.PersistenceManager;
@ -118,8 +118,8 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
service.getContext().detachAll();
}
private ODataLink buildNavigationLink(final String name, final URI uri, final ODataLinkType type) {
ODataLink result;
private ClientLink buildNavigationLink(final String name, final URI uri, final ClientLinkType type) {
ClientLink result;
switch (type) {
case ENTITY_NAVIGATION:
@ -146,7 +146,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
int posNumber = pos;
items.put(handler, null);
final ODataEntity entity = handler.getEntity();
final ClientEntity entity = handler.getEntity();
entity.getNavigationLinks().clear();
final AttachedEntityStatus currentStatus = service.getContext().entityContext().getStatus(handler);
@ -166,13 +166,13 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
}
for (Map.Entry<NavigationProperty, Object> property : handler.getLinkChanges().entrySet()) {
final ODataLinkType type = Collection.class.isAssignableFrom(property.getValue().getClass())
? ODataLinkType.ENTITY_SET_NAVIGATION
: ODataLinkType.ENTITY_NAVIGATION;
final ClientLinkType type = Collection.class.isAssignableFrom(property.getValue().getClass())
? ClientLinkType.ENTITY_SET_NAVIGATION
: ClientLinkType.ENTITY_NAVIGATION;
final Set<EntityInvocationHandler> toBeLinked = new HashSet<EntityInvocationHandler>();
for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
for (Object proxy : type == ClientLinkType.ENTITY_SET_NAVIGATION
? (Collection<?>) property.getValue() : Collections.singleton(property.getValue())) {
final EntityInvocationHandler target = (EntityInvocationHandler) Proxy.getInvocationHandler(proxy);
@ -312,7 +312,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
posNumber++;
items.put(delayedUpdate.getSource(), posNumber);
final ODataEntity changes =
final ClientEntity changes =
service.getClient().getObjectFactory().newEntity(delayedUpdate.getSource().getEntity().getTypeName());
AttachedEntityStatus status = service.getContext().entityContext().getStatus(delayedUpdate.getSource());
@ -339,7 +339,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
targetURI = URI.create("$" + targetPos);
}
changes.addLink(delayedUpdate.getType() == ODataLinkType.ENTITY_NAVIGATION
changes.addLink(delayedUpdate.getType() == ClientLinkType.ENTITY_NAVIGATION
? service.getClient().getObjectFactory().
newEntityNavigationLink(delayedUpdate.getSourceName(), targetURI)
: service.getClient().getObjectFactory().
@ -366,7 +366,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
private AttachedEntityStatus queue(
final EntityInvocationHandler handler,
final ODataEntity entity,
final ClientEntity entity,
final PersistenceChanges changeset) {
switch (service.getContext().entityContext().getStatus(handler)) {
@ -390,7 +390,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
private void queueCreate(
final EntityInvocationHandler handler,
final ODataEntity entity,
final ClientEntity entity,
final PersistenceChanges changeset) {
LOG.debug("Create '{}'", handler);
@ -445,12 +445,12 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
private void queueUpdate(
final EntityInvocationHandler handler,
final ODataEntity changes,
final ClientEntity changes,
final PersistenceChanges changeset) {
LOG.debug("Update '{}'", handler.getEntityURI());
final ODataEntityUpdateRequest<ODataEntity> req =
final ODataEntityUpdateRequest<ClientEntity> req =
((EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
getEntityUpdateRequest(handler.getEntityURI(),
org.apache.olingo.client.api.communication.request.cud.UpdateType.PATCH, changes);
@ -490,12 +490,12 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
private void queueUpdate(
final EntityInvocationHandler handler,
final URI uri,
final ODataEntity changes,
final ClientEntity changes,
final PersistenceChanges changeset) {
LOG.debug("Update '{}'", uri);
final ODataEntityUpdateRequest<ODataEntity> req =
final ODataEntityUpdateRequest<ClientEntity> req =
((EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
getEntityUpdateRequest(uri,
org.apache.olingo.client.api.communication.request.cud.UpdateType.PATCH, changes);
@ -511,7 +511,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
private void queueDelete(
final EntityInvocationHandler handler,
final ODataEntity entity,
final ClientEntity entity,
final PersistenceChanges changeset) {
final URI deleteURI = entity.getEditLink() == null ? handler.getEntityURI() : entity.getEditLink();
changeset.addChange(buildDeleteRequest(deleteURI, handler.getETag()), handler);

View File

@ -41,13 +41,13 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.uri.QueryOption;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataLinked;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientInlineEntity;
import org.apache.olingo.commons.api.domain.ClientInlineEntitySet;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.domain.ClientLinked;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.ext.proxy.AbstractService;
@ -309,7 +309,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
} else if (propertyCache.containsKey(name)) {
res = propertyCache.get(name);
} else {
final ODataProperty property = getInternalProperty(name);
final ClientProperty property = getInternalProperty(name);
if (ref != null && ClassUtils.getTypeClass(type).isAnnotationPresent(ComplexType.class)) {
res = getComplex(
@ -332,7 +332,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
} else {
List items = new ArrayList();
for (ODataValue item : property.getValue().asCollection()) {
for (ClientValue item : property.getValue().asCollection()) {
items.add(getComplex(
name,
item,
@ -364,7 +364,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
? null : getClient().newURIBuilder(baseURI.toASCIIString()).appendPropertySegment(name));
} else {
List items = new ArrayList();
for (ODataValue item : property.getValue().asCollection()) {
for (ClientValue item : property.getValue().asCollection()) {
items.add(item.asPrimitive().toValue());
}
collectionHandler = new PrimitiveCollectionInvocationHandler(
@ -450,25 +450,25 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
final Object navPropValue;
URI targetEntitySetURI = CoreUtils.getTargetEntitySetURI(getClient(), property);
final ODataLink link = ((ODataLinked) internal).getNavigationLink(property.name());
final ClientLink link = ((ClientLinked) internal).getNavigationLink(property.name());
if (link instanceof ODataInlineEntity) {
if (link instanceof ClientInlineEntity) {
// return entity
navPropValue = ProxyUtils.getEntityProxy(
service,
((ODataInlineEntity) link).getEntity(),
((ClientInlineEntity) link).getEntity(),
targetEntitySetURI,
type,
null,
false);
} else if (link instanceof ODataInlineEntitySet) {
} else if (link instanceof ClientInlineEntitySet) {
// return entity set
navPropValue = ProxyUtils.getEntityCollectionProxy(
service,
collItemType,
type,
targetEntitySetURI,
((ODataInlineEntitySet) link).getEntitySet(),
((ClientInlineEntitySet) link).getEntitySet(),
targetEntitySetURI,
false);
} else {
@ -494,7 +494,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
EntityInvocationHandler handler = getContext().entityContext().getEntity(uuid);
if (handler == null) {
final ODataEntity entity = getClient().getObjectFactory().newEntity(new FullQualifiedName(
final ClientEntity entity = getClient().getObjectFactory().newEntity(new FullQualifiedName(
collItemType.getAnnotation(Namespace.class).value(), ClassUtils.getEntityTypeName(collItemType)));
handler = EntityInvocationHandler.getInstance(
@ -543,7 +543,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
}
}
for (ODataProperty property : getInternalProperties()) {
for (ClientProperty property : getInternalProperties()) {
if (!propertyNames.contains(property.getName())) {
res.add(property.getName());
}
@ -644,7 +644,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
public abstract boolean isChanged();
protected abstract <T extends ODataProperty> List<T> getInternalProperties();
protected abstract <T extends ClientProperty> List<T> getInternalProperties();
protected abstract ODataProperty getInternalProperty(final String name);
protected abstract ClientProperty getInternalProperty(final String name);
}

View File

@ -27,9 +27,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.commons.api.domain.ClientComplexValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.AbstractTerm;
import org.apache.olingo.ext.proxy.api.Annotatable;
@ -77,17 +77,17 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
return annotations;
}
private List<ODataAnnotation> internalAnnotations() {
List<ODataAnnotation> result = Collections.<ODataAnnotation> emptyList();
private List<ClientAnnotation> internalAnnotations() {
List<ClientAnnotation> result = Collections.<ClientAnnotation> emptyList();
if (targetHandler.getInternal() instanceof ODataEntity) {
if (targetHandler.getInternal() instanceof ClientEntity) {
result = propName == null
? ((ODataEntity) targetHandler.getInternal()).getNavigationLink(navPropName).getAnnotations()
: ((ODataEntity) targetHandler.getInternal()).getProperty(propName).getAnnotations();
} else if (targetHandler.getInternal() instanceof ODataComplexValue) {
? ((ClientEntity) targetHandler.getInternal()).getNavigationLink(navPropName).getAnnotations()
: ((ClientEntity) targetHandler.getInternal()).getProperty(propName).getAnnotations();
} else if (targetHandler.getInternal() instanceof ClientComplexValue) {
result = propName == null
? ((ODataComplexValue) targetHandler.getInternal()).getNavigationLink(navPropName).getAnnotations()
: ((ODataComplexValue) targetHandler.getInternal()).get(propName).getAnnotations();
? ((ClientComplexValue) targetHandler.getInternal()).getNavigationLink(navPropName).getAnnotations()
: ((ClientComplexValue) targetHandler.getInternal()).get(propName).getAnnotations();
}
return result;
@ -146,8 +146,8 @@ public class AnnotatableInvocationHandler extends AbstractInvocationHandler impl
try {
final Term termAnn = term.getAnnotation(Term.class);
final Namespace namespaceAnn = term.getAnnotation(Namespace.class);
ODataAnnotation annotation = null;
for (ODataAnnotation _annotation : internalAnnotations()) {
ClientAnnotation annotation = null;
for (ClientAnnotation _annotation : internalAnnotations()) {
if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) {
annotation = _annotation;
}

View File

@ -33,10 +33,10 @@ import org.apache.commons.lang3.tuple.Triple;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.commons.api.domain.ClientCollectionValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.ComplexCollection;
import org.apache.olingo.ext.proxy.api.ComplexType;
@ -96,18 +96,18 @@ public class ComplexCollectionInvocationHandler<T extends ComplexType<?>>
@SuppressWarnings("unchecked")
@Override
public Triple<List<T>, URI, List<ODataAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef) {
final ODataPropertyRequest<ODataProperty> req =
public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef) {
final ODataPropertyRequest<ClientProperty> req =
getClient().getRetrieveRequestFactory().getPropertyRequest(uri);
req.setPrefer(getClient().newPreferences().includeAnnotations("*"));
final ODataRetrieveResponse<ODataProperty> res = req.execute();
final ODataRetrieveResponse<ClientProperty> res = req.execute();
final List<T> resItems = new ArrayList<T>();
final ODataProperty property = res.getBody();
final ClientProperty property = res.getBody();
if (property != null && property.hasCollectionValue()) {
for (ODataValue item : (ODataCollectionValue<ODataValue>) property.getValue()) {
for (ClientValue item : (ClientCollectionValue<ClientValue>) property.getValue()) {
Class<?> actualRef = null;
if (StringUtils.isNotBlank(item.getTypeName())) {
actualRef = service.getComplexTypeClass(item.getTypeName());
@ -120,7 +120,7 @@ public class ComplexCollectionInvocationHandler<T extends ComplexType<?>>
}
}
return new ImmutableTriple<List<T>, URI, List<ODataAnnotation>>(
resItems, null, Collections.<ODataAnnotation> emptyList());
return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(
resItems, null, Collections.<ClientAnnotation> emptyList());
}
}

View File

@ -28,9 +28,9 @@ import org.apache.commons.lang3.tuple.Pair;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataLinked;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientComplexValue;
import org.apache.olingo.commons.api.domain.ClientLinked;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.annotations.ComplexType;
@ -39,7 +39,7 @@ import org.apache.olingo.ext.proxy.utils.ClassUtils;
public class ComplexInvocationHandler extends AbstractStructuredInvocationHandler {
private static Pair<ODataComplexValue, Class<?>> init(
private static Pair<ClientComplexValue, Class<?>> init(
final Class<?> typeRef,
final AbstractService<?> service) {
@ -57,10 +57,10 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
final FullQualifiedName typeName =
new FullQualifiedName(ClassUtils.getNamespace(complexTypeRef), annotation.name());
final ODataComplexValue complex =
final ClientComplexValue complex =
service.getClient().getObjectFactory().newComplexValue(typeName.toString());
return new ImmutablePair<ODataComplexValue, Class<?>>(complex, complexTypeRef);
return new ImmutablePair<ClientComplexValue, Class<?>>(complex, complexTypeRef);
}
public static ComplexInvocationHandler getInstance(
@ -68,12 +68,12 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
final EntityInvocationHandler handler,
final Class<?> typeRef) {
final Pair<ODataComplexValue, Class<?>> init = init(typeRef, handler.service);
final Pair<ClientComplexValue, Class<?>> init = init(typeRef, handler.service);
return new ComplexInvocationHandler(init.getLeft(), init.getRight(), handler);
}
public static ComplexInvocationHandler getInstance(
final ODataComplexValue complex,
final ClientComplexValue complex,
final Class<?> typeRef,
final AbstractService<?> service) {
@ -84,7 +84,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
final Class<?> typeRef,
final AbstractService<?> service) {
final Pair<ODataComplexValue, Class<?>> init = init(typeRef, service);
final Pair<ClientComplexValue, Class<?>> init = init(typeRef, service);
return new ComplexInvocationHandler(init.getLeft(), init.getRight(), service);
}
@ -93,12 +93,12 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
final AbstractService<?> service,
final URIBuilder uri) {
final Pair<ODataComplexValue, Class<?>> init = init(typeRef, service);
final Pair<ClientComplexValue, Class<?>> init = init(typeRef, service);
return new ComplexInvocationHandler(init.getLeft(), init.getRight(), service, uri);
}
public static ComplexInvocationHandler getInstance(
final ODataComplexValue complex,
final ClientComplexValue complex,
final Class<?> typeRef,
final AbstractService<?> service,
final URIBuilder uri) {
@ -107,7 +107,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
}
private ComplexInvocationHandler(
final ODataComplexValue complex,
final ClientComplexValue complex,
final Class<?> typeRef,
final AbstractService<?> service,
final URIBuilder uri) {
@ -118,7 +118,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
}
private ComplexInvocationHandler(
final ODataComplexValue complex,
final ClientComplexValue complex,
final Class<?> typeRef,
final EntityInvocationHandler handler) {
@ -127,7 +127,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
}
private ComplexInvocationHandler(
final ODataComplexValue complex,
final ClientComplexValue complex,
final Class<?> typeRef,
final AbstractService<?> service) {
@ -135,13 +135,13 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
this.uri = null;
}
public ODataComplexValue getComplex() {
return (ODataComplexValue) this.internal;
public ClientComplexValue getComplex() {
return (ClientComplexValue) this.internal;
}
@Override
protected Object getNavigationPropertyValue(final NavigationProperty property, final Method getter) {
if (!(internal instanceof ODataLinked)) {
if (!(internal instanceof ClientLinked)) {
throw new UnsupportedOperationException("Internal object is not navigable");
}
@ -157,10 +157,10 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
protected void load() {
try {
if (this.uri != null) {
final ODataPropertyRequest<ODataProperty> req =
final ODataPropertyRequest<ClientProperty> req =
getClient().getRetrieveRequestFactory().getPropertyRequest(uri.build());
final ODataRetrieveResponse<ODataProperty> res = req.execute();
final ODataRetrieveResponse<ClientProperty> res = req.execute();
this.internal = res.getBody().getValue();
}
} catch (IllegalArgumentException e) {
@ -173,10 +173,10 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
}
@Override
protected List<ODataProperty> getInternalProperties() {
final List<ODataProperty> res = new ArrayList<ODataProperty>();
protected List<ClientProperty> getInternalProperties() {
final List<ClientProperty> res = new ArrayList<ClientProperty>();
if (getComplex() != null) {
for (ODataProperty property : getComplex()) {
for (ClientProperty property : getComplex()) {
res.add(property);
}
}
@ -184,7 +184,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
}
@Override
protected ODataProperty getInternalProperty(final String name) {
protected ClientProperty getInternalProperty(final String name) {
return getComplex() == null ? null : getComplex().get(name);
}
}

View File

@ -25,7 +25,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URI;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.ComplexCollection;
@ -120,7 +120,7 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
EntityInvocationHandler handler = getContext().entityContext().getEntity(uuid);
if (handler == null) {
final ODataEntity entity = getClient().getObjectFactory().newEntity(new FullQualifiedName(
final ClientEntity entity = getClient().getObjectFactory().newEntity(new FullQualifiedName(
typeRef.getAnnotation(Namespace.class).value(), ClassUtils.getEntityTypeName(typeRef)));
handler = EntityInvocationHandler.getInstance(entity, uri, uri, typeRef, service);

View File

@ -34,9 +34,9 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.ext.proxy.AbstractService;
@ -63,7 +63,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
private EntityUUID uuid;
static EntityInvocationHandler getInstance(
final ODataEntity entity,
final ClientEntity entity,
final EntitySetInvocationHandler<?, ?, ?> entitySet,
final Class<?> typeRef) {
@ -77,7 +77,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
static EntityInvocationHandler getInstance(
final Object key,
final ODataEntity entity,
final ClientEntity entity,
final URI entitySetURI,
final Class<?> typeRef,
final AbstractService<?> service) {
@ -86,7 +86,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
}
public static EntityInvocationHandler getInstance(
final ODataEntity entity,
final ClientEntity entity,
final URI entitySetURI,
final Class<?> typeRef,
final AbstractService<?> service) {
@ -95,7 +95,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
}
public static EntityInvocationHandler getInstance(
final ODataEntity entity,
final ClientEntity entity,
final URI entitySetURI,
final URI entityURI,
final Class<?> typeRef,
@ -129,7 +129,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
final String namespace = typeRef.getAnnotation(Namespace.class).value();
this.internal = service.getClient().getObjectFactory().newEntity(new FullQualifiedName(namespace, name));
ODataEntity.class.cast(this.internal).setMediaEntity(typeRef.getAnnotation(EntityType.class).hasStream());
ClientEntity.class.cast(this.internal).setMediaEntity(typeRef.getAnnotation(EntityType.class).hasStream());
this.uuid = new EntityUUID(null, typeRef, null);
}
@ -145,7 +145,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
final String namespace = typeRef.getAnnotation(Namespace.class).value();
this.internal = service.getClient().getObjectFactory().newEntity(new FullQualifiedName(namespace, name));
ODataEntity.class.cast(this.internal).setMediaEntity(typeRef.getAnnotation(EntityType.class).hasStream());
ClientEntity.class.cast(this.internal).setMediaEntity(typeRef.getAnnotation(EntityType.class).hasStream());
this.baseURI = entityURI;
this.uri = entityURI == null ? null : getClient().newURIBuilder(baseURI.toASCIIString());
@ -154,7 +154,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
}
private EntityInvocationHandler(
final ODataEntity entity,
final ClientEntity entity,
final URI entitySetURI,
final URI entityURI,
final Class<?> typeRef,
@ -177,7 +177,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
private EntityInvocationHandler(
final Object entityKey,
final ODataEntity entity,
final ClientEntity entity,
final URI entitySetURI,
final Class<?> typeRef,
final AbstractService<?> service) {
@ -207,7 +207,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
this.uuid = new EntityUUID(entitySetURI, typeRef, key);
}
public void setEntity(final ODataEntity entity) {
public void setEntity(final ClientEntity entity) {
this.internal = entity;
getEntity().setMediaEntity(typeRef.getAnnotation(EntityType.class).hasStream());
@ -240,7 +240,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
return uuid;
}
public EntityUUID updateEntityUUID(final URI entitySetURI, final Class<?> type, final ODataEntity entity) {
public EntityUUID updateEntityUUID(final URI entitySetURI, final Class<?> type, final ClientEntity entity) {
CoreUtils.addProperties(service.getClient(), this.getPropertyChanges(), entity);
final Object key = CoreUtils.getKey(getClient(), this, this.getUUID().getType(), entity);
return updateUUID(entitySetURI, type, key);
@ -266,8 +266,8 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
return uuid.getEntitySetURI();
}
public final ODataEntity getEntity() {
return (ODataEntity) internal;
public final ClientEntity getEntity() {
return (ClientEntity) internal;
}
public URI getEntityURI() {
@ -414,8 +414,8 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
try {
final Term termAnn = term.getAnnotation(Term.class);
final Namespace namespaceAnn = term.getAnnotation(Namespace.class);
ODataAnnotation annotation = null;
for (ODataAnnotation _annotation : getEntity().getAnnotations()) {
ClientAnnotation annotation = null;
for (ClientAnnotation _annotation : getEntity().getAnnotations()) {
if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) {
annotation = _annotation;
}
@ -445,14 +445,14 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
final Object key = uuid.getKey();
try {
final ODataEntityRequest<ODataEntity> req =
final ODataEntityRequest<ClientEntity> req =
getClient().getRetrieveRequestFactory().getEntityRequest(uri.build());
req.setPrefer(getClient().newPreferences().includeAnnotations("*"));
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final ClientEntity entity = res.getBody();
if (entity == null) {
throw new IllegalArgumentException("Invalid " + typeRef.getSimpleName() + "(" + key + ")");
}
@ -479,12 +479,12 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
@Override
@SuppressWarnings("unchecked")
protected <T extends ODataProperty> List<T> getInternalProperties() {
protected <T extends ClientProperty> List<T> getInternalProperties() {
return getEntity() == null ? Collections.<T> emptyList() : (List<T>) getEntity().getProperties();
}
@Override
protected ODataProperty getInternalProperty(final String name) {
protected ClientProperty getInternalProperty(final String name) {
return getEntity() == null ? null : getEntity().getProperty(name);
}

View File

@ -30,8 +30,8 @@ import java.util.concurrent.Future;
import org.apache.commons.lang3.tuple.Triple;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.ext.proxy.AbstractService;
@ -128,7 +128,7 @@ public class EntitySetInvocationHandler<
EntityInvocationHandler handler = getContext().entityContext().getEntity(uuid);
if (handler == null) {
final ODataEntity entity = getClient().getObjectFactory().newEntity(new FullQualifiedName(
final ClientEntity entity = getClient().getObjectFactory().newEntity(new FullQualifiedName(
typeRef.getAnnotation(Namespace.class).value(), ClassUtils.getEntityTypeName(typeRef)));
handler = EntityInvocationHandler.getInstance(key, entity, this.baseURI, typeRef, service);
@ -175,9 +175,9 @@ public class EntitySetInvocationHandler<
ClassUtils.getNamespace(ref), ClassUtils.getEntityTypeName(ref)).toString());
}
final List<ODataAnnotation> anns = new ArrayList<ODataAnnotation>();
final List<ClientAnnotation> anns = new ArrayList<ClientAnnotation>();
final Triple<List<T>, URI, List<ODataAnnotation>> entitySet = fetchPartial(uri.build(), (Class<T>) ref);
final Triple<List<T>, URI, List<ClientAnnotation>> entitySet = fetchPartial(uri.build(), (Class<T>) ref);
anns.addAll(entitySet.getRight());
final EntityCollectionInvocationHandler<S> entityCollectionHandler = new EntityCollectionInvocationHandler<S>(
@ -212,11 +212,11 @@ public class EntitySetInvocationHandler<
final URIBuilder uriBuilder, final Class<S> typeRef, final Class<SEC> collTypeRef) {
final List<S> res = new ArrayList<S>();
final List<ODataAnnotation> anns = new ArrayList<ODataAnnotation>();
final List<ClientAnnotation> anns = new ArrayList<ClientAnnotation>();
URI nextURI = uriBuilder.build();
while (nextURI != null) {
final Triple<List<T>, URI, List<ODataAnnotation>> entitySet = fetchPartial(nextURI, (Class<T>) typeRef);
final Triple<List<T>, URI, List<ClientAnnotation>> entitySet = fetchPartial(nextURI, (Class<T>) typeRef);
res.addAll((List<S>) entitySet.getLeft());
nextURI = entitySet.getMiddle();
anns.addAll(entitySet.getRight());

View File

@ -26,7 +26,7 @@ import java.util.List;
import java.util.NoSuchElementException;
import org.apache.commons.lang3.tuple.Triple;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.ext.proxy.api.EntityCollection;
import org.apache.olingo.ext.proxy.api.EntityType;
@ -81,7 +81,7 @@ class EntitySetIterator<T extends EntityType<?>, KEY extends Serializable, EC ex
}
private void goOn() {
final Triple<List<T>, URI, List<ODataAnnotation>> entitySet = esi.fetchPartial(this.next, this.esi.getTypeRef());
final Triple<List<T>, URI, List<ClientAnnotation>> entitySet = esi.fetchPartial(this.next, this.esi.getTypeRef());
this.current = entitySet.getLeft().iterator();
this.next = entitySet.getMiddle();
}

View File

@ -30,15 +30,15 @@ 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.communication.request.invoke.ClientNoContent;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.api.uri.URIFilter;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientInvokeResult;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmFunction;
import org.apache.olingo.commons.api.edm.EdmOperation;
import org.apache.olingo.commons.api.edm.EdmReturnType;
@ -63,7 +63,7 @@ public class InvokerInvocationHandler<T, O extends Operations> extends AbstractI
private URIBuilder uri;
private final Map<String, ODataValue> parameters;
private final Map<String, ClientValue> parameters;
private final Operation operation;
@ -75,7 +75,7 @@ public class InvokerInvocationHandler<T, O extends Operations> extends AbstractI
public InvokerInvocationHandler(
final URI uri,
final Map<String, ODataValue> parameters,
final Map<String, ClientValue> parameters,
final Operation operation,
final EdmOperation edmOperation,
final Type[] references,
@ -120,7 +120,7 @@ public class InvokerInvocationHandler<T, O extends Operations> extends AbstractI
}
// 2. invoke
final ODataInvokeResult result = service.getClient().getInvokeRequestFactory().getInvokeRequest(
final ClientInvokeResult result = service.getClient().getInvokeRequestFactory().getInvokeRequest(
edmOperation instanceof EdmFunction ? HttpMethod.GET : HttpMethod.POST,
uri.build(),
getResultReference(edmOperation.getReturnType()),
@ -143,13 +143,13 @@ public class InvokerInvocationHandler<T, O extends Operations> extends AbstractI
collItemType,
targetRef,
null,
(ODataEntitySet) result,
(ClientEntitySet) result,
this.baseURI,
false);
} else {
return (T) ProxyUtils.getEntityProxy(
service,
(ODataEntity) result,
(ClientEntity) result,
null,
targetRef,
null,
@ -159,7 +159,7 @@ public class InvokerInvocationHandler<T, O extends Operations> extends AbstractI
Object res;
final Class<?> ref = ClassUtils.getTypeClass(targetRef);
final ODataProperty property = (ODataProperty) result;
final ClientProperty property = (ClientProperty) result;
if (property == null || property.hasNullValue()) {
res = null;
@ -168,7 +168,7 @@ public class InvokerInvocationHandler<T, O extends Operations> extends AbstractI
final Class<?> itemRef = ClassUtils.extractTypeArg(ref, ComplexCollection.class);
final List items = new ArrayList();
for (ODataValue item : property.getValue().asCollection()) {
for (ClientValue item : property.getValue().asCollection()) {
items.add(ProxyUtils.getComplexProxy(
service,
property.getName(),
@ -189,7 +189,7 @@ public class InvokerInvocationHandler<T, O extends Operations> extends AbstractI
} else {
final List items = new ArrayList();
for (ODataValue item : property.getValue().asCollection()) {
for (ClientValue item : property.getValue().asCollection()) {
items.add(item.asPrimitive().toValue());
}
@ -218,18 +218,18 @@ public class InvokerInvocationHandler<T, O extends Operations> extends AbstractI
}
@SuppressWarnings("unchecked")
private <RES extends ODataInvokeResult> Class<RES> getResultReference(final EdmReturnType returnType) {
private <RES extends ClientInvokeResult> Class<RES> getResultReference(final EdmReturnType returnType) {
Class<RES> result;
if (returnType == null) {
result = (Class<RES>) ODataNoContent.class;
result = (Class<RES>) ClientNoContent.class;
} else {
if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
result = (Class<RES>) ODataEntitySet.class;
result = (Class<RES>) ClientEntitySet.class;
} else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
result = (Class<RES>) ODataEntity.class;
result = (Class<RES>) ClientEntity.class;
} else {
result = (Class<RES>) ODataProperty.class;
result = (Class<RES>) ClientProperty.class;
}
}

View File

@ -30,9 +30,9 @@ import java.util.List;
import java.util.Map;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataOperation;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientOperation;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
import org.apache.olingo.commons.api.edm.EdmEntityType;
@ -171,7 +171,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler {
throw new IllegalStateException("Invalid target invocation");
}
final Map<String, ODataValue> parameterValues = new LinkedHashMap<String, ODataValue>();
final Map<String, ClientValue> parameterValues = new LinkedHashMap<String, ClientValue>();
for (Map.Entry<Parameter, Object> parameter : parameters.entrySet()) {
if (!parameter.getKey().nullable() && parameter.getValue() == null) {
throw new IllegalArgumentException(
@ -181,7 +181,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler {
final EdmTypeInfo parameterType = new EdmTypeInfo.Builder().
setEdm(service.getClient().getCachedEdm()).setTypeExpression(parameter.getKey().type()).build();
final ODataValue paramValue = parameter.getValue() == null
final ClientValue paramValue = parameter.getValue() == null
? null
: CoreUtils.getODataValue(service.getClient(), parameterType, parameter.getValue());
@ -239,10 +239,10 @@ final class OperationInvocationHandler extends AbstractInvocationHandler {
}
private Map.Entry<URI, EdmOperation> getBoundOperation(final Operation operation, final List<String> parameterNames) {
final ODataEntity entity = EntityInvocationHandler.class.cast(target).getEntity();
final ClientEntity entity = EntityInvocationHandler.class.cast(target).getEntity();
final URI entityURI = EntityInvocationHandler.class.cast(target).getEntityURI();
ODataOperation boundOp = entity.getOperation(operation.name());
ClientOperation boundOp = entity.getOperation(operation.name());
if (boundOp == null) {
boundOp = entity.getOperation(new FullQualifiedName(targetFQN.getNamespace(), operation.name()).toString());
}
@ -261,7 +261,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler {
if (action == null) {
baseType = baseType.getBaseType();
} else {
boundOp = new ODataOperation();
boundOp = new ClientOperation();
boundOp.setMetadataAnchor(action.getFullQualifiedName().toString());
boundOp.setTitle(boundOp.getMetadataAnchor());
boundOp.setTarget(URI.create(entityURI.toASCIIString() + "/"
@ -279,7 +279,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler {
if (func == null) {
baseType = baseType.getBaseType();
} else {
boundOp = new ODataOperation();
boundOp = new ClientOperation();
boundOp.setMetadataAnchor(func.getFullQualifiedName().toString());
boundOp.setTitle(boundOp.getMetadataAnchor());
boundOp.setTarget(URI.create(entityURI.toASCIIString() + "/"

View File

@ -34,8 +34,9 @@ import org.apache.commons.lang3.tuple.Triple;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
@ -90,24 +91,24 @@ public class PrimitiveCollectionInvocationHandler<T extends Serializable>
@Override
@SuppressWarnings("unchecked")
public Triple<List<T>, URI, List<ODataAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef) {
final ODataPropertyRequest<org.apache.olingo.commons.api.domain.ODataProperty> req =
public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef) {
final ODataPropertyRequest<ClientProperty> req =
getClient().getRetrieveRequestFactory().getPropertyRequest(uri);
req.setPrefer(getClient().newPreferences().includeAnnotations("*"));
final ODataRetrieveResponse<org.apache.olingo.commons.api.domain.ODataProperty> res = req.execute();
final ODataRetrieveResponse<ClientProperty> res = req.execute();
final List<T> resItems = new ArrayList<T>();
final org.apache.olingo.commons.api.domain.ODataProperty property = res.getBody();
final ClientProperty property = res.getBody();
if (property != null && !property.hasNullValue()) {
for (ODataValue item : property.getCollectionValue()) {
for (ClientValue item : property.getCollectionValue()) {
resItems.add((T) item.asPrimitive().toValue());
}
}
return new ImmutableTriple<List<T>, URI, List<ODataAnnotation>>(
resItems, null, Collections.<ODataAnnotation>emptyList());
return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(
resItems, null, Collections.<ClientAnnotation>emptyList());
}
public void delete() {

View File

@ -24,7 +24,7 @@ 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.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmOperation;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
import org.apache.olingo.ext.proxy.AbstractService;
@ -38,7 +38,7 @@ public class StructuredComposableInvokerInvocationHandler<T, O extends Operation
public StructuredComposableInvokerInvocationHandler(
final URI uri,
final Map<String, ODataValue> parameters,
final Map<String, ClientValue> parameters,
final Operation operation,
final EdmOperation edmOperation,
final Type[] references,

View File

@ -22,7 +22,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.olingo.commons.api.domain.ODataLinkType;
import org.apache.olingo.commons.api.domain.ClientLinkType;
import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
import java.io.Serializable;
@ -39,7 +39,7 @@ public class EntityLinkDesc implements Serializable {
private final Collection<EntityInvocationHandler> targets;
private final ODataLinkType type;
private final ClientLinkType type;
private final String reference;
@ -47,7 +47,7 @@ public class EntityLinkDesc implements Serializable {
final String sourceName,
final EntityInvocationHandler source,
final Collection<EntityInvocationHandler> target,
final ODataLinkType type) {
final ClientLinkType type) {
this.sourceName = sourceName;
this.source = source;
this.targets = target;
@ -59,7 +59,7 @@ public class EntityLinkDesc implements Serializable {
final String sourceName,
final EntityInvocationHandler source,
final EntityInvocationHandler target,
final ODataLinkType type) {
final ClientLinkType type) {
this.sourceName = sourceName;
this.source = source;
this.targets = Collections.<EntityInvocationHandler>singleton(target);
@ -90,7 +90,7 @@ public class EntityLinkDesc implements Serializable {
return targets;
}
public ODataLinkType getType() {
public ClientLinkType getType() {
return type;
}

View File

@ -40,22 +40,22 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.EdmEnabledODataClient;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.ODataAnnotatable;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEnumValue;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientAnnotatable;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.commons.api.domain.ClientComplexValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEnumValue;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmElement;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmTerm;
import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.core.domain.ODataAnnotationImpl;
import org.apache.olingo.commons.core.domain.ClientAnnotationImpl;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
import org.apache.olingo.ext.proxy.AbstractService;
@ -88,10 +88,10 @@ public final class CoreUtils {
// Empty private constructor for static utility classes
}
public static ODataValue getODataValue(
public static ClientValue getODataValue(
final EdmEnabledODataClient client, final EdmTypeInfo type, final Object obj) {
final ODataValue value;
final ClientValue value;
if (type.isCollection()) {
value = client.getObjectFactory().newCollectionValue(type.getFullQualifiedName().toString());
@ -144,7 +144,7 @@ public final class CoreUtils {
return value;
}
private static ODataProperty getODataEntityProperty(
private static ClientProperty getODataEntityProperty(
final EdmEnabledODataClient client,
final FullQualifiedName entity,
final String property,
@ -154,7 +154,7 @@ public final class CoreUtils {
return getODataProperty(client, edmProperty, property, obj);
}
private static ODataProperty getODataComplexProperty(
private static ClientProperty getODataComplexProperty(
final EdmEnabledODataClient client,
final FullQualifiedName complex,
final String property,
@ -164,7 +164,7 @@ public final class CoreUtils {
return getODataProperty(client, edmProperty, property, obj);
}
private static ODataProperty getODataProperty(
private static ClientProperty getODataProperty(
final EdmEnabledODataClient client,
final EdmElement edmProperty,
final String property,
@ -186,29 +186,29 @@ public final class CoreUtils {
return getODataProperty(client, property, type, obj);
}
public static ODataAnnotation getODataAnnotation(
public static ClientAnnotation getODataAnnotation(
final EdmEnabledODataClient client, final String term, final EdmType type, final Object obj) {
ODataAnnotation annotation;
ClientAnnotation annotation;
if (obj == null) {
annotation = new ODataAnnotationImpl(term, null);
annotation = new ClientAnnotationImpl(term, null);
} else {
final EdmTypeInfo valueType = type == null
? guessTypeFromObject(client, obj)
: new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).
setTypeExpression(type.getFullQualifiedName().toString()).build();
annotation = new ODataAnnotationImpl(term, getODataValue(client, valueType, obj));
annotation = new ClientAnnotationImpl(term, getODataValue(client, valueType, obj));
}
return annotation;
}
public static ODataProperty getODataProperty(
public static ClientProperty getODataProperty(
final EdmEnabledODataClient client, final String name, final EdmTypeInfo type, final Object obj) {
ODataProperty property;
ClientProperty property;
try {
if (obj == null) {
@ -217,7 +217,7 @@ public final class CoreUtils {
final EdmTypeInfo valueType = type == null
? guessTypeFromObject(client, obj)
: type;
final ODataValue value = getODataValue(client, valueType, obj);
final ClientValue value = getODataValue(client, valueType, obj);
if (valueType.isCollection()) {
property = client.getObjectFactory().newCollectionProperty(name, value.asCollection());
@ -287,7 +287,7 @@ public final class CoreUtils {
public static void addProperties(
final EdmEnabledODataClient client,
final Map<String, Object> changes,
final ODataEntity entity) {
final ClientEntity entity) {
for (Map.Entry<String, Object> entry : changes.entrySet()) {
entity.getProperties()
@ -298,7 +298,7 @@ public final class CoreUtils {
public static void addProperties(
final EdmEnabledODataClient client,
final Map<String, Object> changes,
final ODataComplexValue entity) {
final ClientComplexValue entity) {
for (Map.Entry<String, Object> entry : changes.entrySet()) {
entity.add(getODataComplexProperty(
@ -312,7 +312,7 @@ public final class CoreUtils {
public static void addAnnotations(
final EdmEnabledODataClient client,
final Map<Class<? extends AbstractTerm>, Object> annotations,
final ODataAnnotatable annotatable) {
final ClientAnnotatable annotatable) {
for (Map.Entry<Class<? extends AbstractTerm>, Object> entry : annotations.entrySet()) {
final Namespace nsAnn = entry.getKey().getAnnotation(Namespace.class);
@ -329,7 +329,7 @@ public final class CoreUtils {
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Enum<?> enumValueToObject(final ODataEnumValue value, final Class<?> reference) {
private static Enum<?> enumValueToObject(final ClientEnumValue value, final Class<?> reference) {
final Namespace namespace = reference.getAnnotation(Namespace.class);
final EnumType enumType = reference.getAnnotation(EnumType.class);
if (value.getTypeName().equals(namespace.value() + "." + enumType.name())) {
@ -339,7 +339,7 @@ public final class CoreUtils {
return null;
}
private static Object primitiveValueToObject(final ODataPrimitiveValue value, final Class<?> reference) {
private static Object primitiveValueToObject(final ClientPrimitiveValue value, final Class<?> reference) {
Object obj;
try {
@ -378,7 +378,7 @@ public final class CoreUtils {
public static URIBuilder buildEditLink(
final EdmEnabledODataClient client,
final String entitySetURI,
final ODataEntity entity,
final ClientEntity entity,
final Object key) {
if (key == null) {
@ -428,14 +428,14 @@ public final class CoreUtils {
final EdmEnabledODataClient client,
final EntityInvocationHandler typeHandler,
final Class<?> entityTypeRef,
final ODataEntity entity) {
final ClientEntity entity) {
Object res = null;
if (!entity.getProperties().isEmpty()) {
final Class<?> keyRef = ClassUtils.getCompoundKeyRef(entityTypeRef);
if (keyRef == null) {
final ODataProperty property = entity.getProperty(firstValidEntityKey(entityTypeRef));
final ClientProperty property = entity.getProperty(firstValidEntityKey(entityTypeRef));
if (property != null && property.hasPrimitiveValue()) {
res = primitiveValueToObject(
property.getPrimitiveValue(), getPropertyClass(entityTypeRef, property.getName()));
@ -459,7 +459,7 @@ public final class CoreUtils {
final EntityInvocationHandler typeHandler,
final Object bean,
final Class<? extends Annotation> getterAnn,
final Iterator<? extends ODataProperty> propItor) {
final Iterator<? extends ClientProperty> propItor) {
if (bean != null) {
final Class<?> typeRef;
@ -484,11 +484,11 @@ public final class CoreUtils {
final Object bean,
final Class<?> typeRef,
final Class<? extends Annotation> getterAnn,
final Iterator<? extends ODataProperty> propItor) {
final Iterator<? extends ClientProperty> propItor) {
if (bean != null) {
while (propItor.hasNext()) {
final ODataProperty property = propItor.next();
final ClientProperty property = propItor.next();
final Method getter = ClassUtils.findGetterByAnnotatedName(typeRef, getterAnn, property.getName());
@ -520,9 +520,9 @@ public final class CoreUtils {
setPropertyValue(bean, getter, collection);
}
final Iterator<ODataValue> collPropItor = property.getValue().asCollection().iterator();
final Iterator<ClientValue> collPropItor = property.getValue().asCollection().iterator();
while (collPropItor.hasNext()) {
final ODataValue value = collPropItor.next();
final ClientValue value = collPropItor.next();
if (value.isPrimitive()) {
collection.add(primitiveValueToObject(
value.asPrimitive(), getPropertyClass(typeRef, property.getName())));
@ -546,7 +546,7 @@ public final class CoreUtils {
}
public static Object getObjectFromODataValue(
final ODataValue value,
final ClientValue value,
final Type typeRef,
final AbstractService<?> service)
throws InstantiationException, IllegalAccessException {
@ -566,7 +566,7 @@ public final class CoreUtils {
}
public static Object getObjectFromODataValue(
final ODataValue value,
final ClientValue value,
final Class<?> ref,
final AbstractService<?> service)
throws InstantiationException, IllegalAccessException {
@ -585,9 +585,9 @@ public final class CoreUtils {
} else if (value.isCollection()) {
final ArrayList<Object> collection = new ArrayList<Object>();
final Iterator<ODataValue> collPropItor = value.asCollection().iterator();
final Iterator<ClientValue> collPropItor = value.asCollection().iterator();
while (collPropItor.hasNext()) {
final ODataValue itemValue = collPropItor.next();
final ClientValue itemValue = collPropItor.next();
if (itemValue.isPrimitive()) {
collection.add(CoreUtils.primitiveValueToObject(itemValue.asPrimitive(), ref));
} else if (itemValue.isComplex()) {
@ -602,8 +602,8 @@ public final class CoreUtils {
}
res = collection;
} else if (value instanceof ODataEnumValue) {
res = enumValueToObject((ODataEnumValue) value, ref == null ? getEnumTypeRef(service, value) : ref);
} else if (value instanceof ClientEnumValue) {
res = enumValueToObject((ClientEnumValue) value, ref == null ? getEnumTypeRef(service, value) : ref);
} else {
res = primitiveValueToObject(value.asPrimitive(), ref);
}
@ -612,11 +612,11 @@ public final class CoreUtils {
}
public static Collection<Class<? extends AbstractTerm>> getAnnotationTerms(
final AbstractService<?> service, final List<ODataAnnotation> annotations) {
final AbstractService<?> service, final List<ClientAnnotation> annotations) {
final List<Class<? extends AbstractTerm>> res = new ArrayList<Class<? extends AbstractTerm>>();
for (ODataAnnotation annotation : annotations) {
for (ClientAnnotation annotation : annotations) {
final Class<? extends AbstractTerm> clazz = service.getTermClass(annotation.getTerm());
if (clazz != null) {
res.add(clazz);
@ -626,11 +626,11 @@ public final class CoreUtils {
return res;
}
private static Class<?> getEnumTypeRef(final AbstractService<?> service, final ODataValue value) {
private static Class<?> getEnumTypeRef(final AbstractService<?> service, final ClientValue value) {
return service.getEnumTypeClass(value.getTypeName().replaceAll("^Collection\\(", "").replaceAll("\\)$", ""));
}
public static Class<?> getComplexTypeRef(final AbstractService<?> service, final ODataValue value) {
public static Class<?> getComplexTypeRef(final AbstractService<?> service, final ClientValue value) {
return service.getComplexTypeClass(value.getTypeName().replaceAll("^Collection\\(", "").replaceAll("\\)$", ""));
}
@ -646,8 +646,8 @@ public final class CoreUtils {
return null;
}
public static URI getMediaEditLink(final String name, final ODataEntity entity) {
final ODataLink mediaEditLink = entity.getMediaEditLink(name);
public static URI getMediaEditLink(final String name, final ClientEntity entity) {
final ClientLink mediaEditLink = entity.getMediaEditLink(name);
return mediaEditLink == null ? URIUtils.getURI(entity.getEditLink(), name) : mediaEditLink.getLink();
}

View File

@ -22,9 +22,9 @@ import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.commons.ComplexInvocationHandler;
import org.apache.olingo.ext.proxy.commons.EntityCollectionInvocationHandler;
@ -39,14 +39,14 @@ public class ProxyUtils {
final Class<?> typeRef,
final Class<?> typeCollectionRef,
final URI targetEntitySetURI,
final ODataEntitySet entitySet,
final ClientEntitySet entitySet,
final URI uri,
final boolean checkInTheContext) {
final List<Object> items = new ArrayList<Object>();
if (entitySet != null) {
for (ODataEntity entityFromSet : entitySet.getEntities()) {
for (ClientEntity entityFromSet : entitySet.getEntities()) {
items.add(getEntityProxy(service, entityFromSet, uri, typeRef, null, checkInTheContext));
}
}
@ -71,7 +71,7 @@ public class ProxyUtils {
public static Object getEntityProxy(
final AbstractService<?> service,
final ODataEntity entity,
final ClientEntity entity,
final URI entitySetURI,
final Class<?> type,
final String eTag,
@ -98,7 +98,7 @@ public class ProxyUtils {
public static Object getComplexProxy(
final AbstractService<?> service,
final String name,
final ODataValue value,
final ClientValue value,
final Class<?> ref,
final EntityInvocationHandler handler,
final URI baseURI,

View File

@ -32,9 +32,9 @@ import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntityCollection;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
import org.apache.olingo.fit.server.TomcatTestServer;
@ -94,15 +94,15 @@ public abstract class AbstractBaseTestITCase {
}
}
protected void debugODataProperty(final ODataProperty property, final String message) {
protected void debugODataProperty(final ClientProperty property, final String message) {
LOG.debug(message + "\n{}", property.toString());
}
protected void debugODataValue(final ODataValue value, final String message) {
protected void debugODataValue(final ClientValue value, final String message) {
LOG.debug(message + "\n{}", value.toString());
}
protected void debugODataEntity(final ODataEntity entity, final String message) {
protected void debugODataEntity(final ClientEntity entity, final String message) {
if (LOG.isDebugEnabled()) {
StringWriter writer = new StringWriter();
try {

View File

@ -34,12 +34,12 @@ import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientCollectionValue;
import org.apache.olingo.commons.api.domain.ClientComplexValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.fit.AbstractBaseTestITCase;
@ -52,20 +52,20 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void primitveAction() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTString").build();
ODataInvokeResponse<ODataProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataProperty.class).execute();
ODataInvokeResponse<ClientProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class).execute();
assertEquals(200, response.getStatusCode());
assertEquals("UARTString string value", response.getBody().getPrimitiveValue().toValue());
}
@Test
public void primitveActionInvalidParameters() throws Exception {
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters.put("Invalid", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(1));
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTString").build();
try {
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataProperty.class, parameters)
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
.execute();
fail("Expected an ODataClientErrorException");
} catch (ODataClientErrorException e) {
@ -77,17 +77,17 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void primitveCollectionAction() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollStringTwoParam").build();
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
parameters.put("ParameterDuration", getClient().getObjectFactory().newPrimitiveValueBuilder().setType(
EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal(1)).build());
ODataInvokeResponse<ODataProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataProperty.class, parameters)
ODataInvokeResponse<ClientProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataCollectionValue<ODataValue> valueArray = response.getBody().getCollectionValue();
ClientCollectionValue<ClientValue> valueArray = response.getBody().getCollectionValue();
assertEquals(3, valueArray.size());
Iterator<ODataValue> iterator = valueArray.iterator();
Iterator<ClientValue> iterator = valueArray.iterator();
assertEquals("PT1S", iterator.next().asPrimitive().toValue());
assertEquals("PT2S", iterator.next().asPrimitive().toValue());
assertEquals("PT3S", iterator.next().asPrimitive().toValue());
@ -97,17 +97,17 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void complexAction() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCTTwoPrimParam").build();
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
ODataInvokeResponse<ODataProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataProperty.class, parameters)
ODataInvokeResponse<ClientProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataComplexValue complexValue = response.getBody().getComplexValue();
ODataProperty propInt16 = complexValue.get("PropertyInt16");
ClientComplexValue complexValue = response.getBody().getComplexValue();
ClientProperty propInt16 = complexValue.get("PropertyInt16");
assertNotNull(propInt16);
assertEquals(3, propInt16.getPrimitiveValue().toValue());
ODataProperty propString = complexValue.get("PropertyString");
ClientProperty propString = complexValue.get("PropertyString");
assertNotNull(propString);
assertEquals("UARTCTTwoPrimParam string value", propString.getPrimitiveValue().toValue());
}
@ -116,13 +116,13 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void complexCollectionActionNoContent() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollCTTwoPrimParam").build();
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 0));
ODataInvokeResponse<ODataProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataProperty.class, parameters)
ODataInvokeResponse<ClientProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataCollectionValue<ODataValue> complexValueCollection = response.getBody().getCollectionValue();
ClientCollectionValue<ClientValue> complexValueCollection = response.getBody().getCollectionValue();
assertEquals(0, complexValueCollection.size());
}
@ -130,17 +130,17 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void complexCollectionActionSubContent() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollCTTwoPrimParam").build();
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 1));
ODataInvokeResponse<ODataProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataProperty.class, parameters)
ODataInvokeResponse<ClientProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataCollectionValue<ODataValue> complexValueCollection = response.getBody().getCollectionValue();
ClientCollectionValue<ClientValue> complexValueCollection = response.getBody().getCollectionValue();
assertEquals(1, complexValueCollection.size());
Iterator<ODataValue> iterator = complexValueCollection.iterator();
Iterator<ClientValue> iterator = complexValueCollection.iterator();
ODataComplexValue next = iterator.next().asComplex();
ClientComplexValue next = iterator.next().asComplex();
assertEquals(16, next.get("PropertyInt16").getPrimitiveValue().toValue());
assertEquals("Test123", next.get("PropertyString").getPrimitiveValue().toValue());
}
@ -149,17 +149,17 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void complexCollectionActionAllContent() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollCTTwoPrimParam").build();
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
ODataInvokeResponse<ODataProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataProperty.class, parameters)
ODataInvokeResponse<ClientProperty> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientProperty.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataCollectionValue<ODataValue> complexValueCollection = response.getBody().getCollectionValue();
ClientCollectionValue<ClientValue> complexValueCollection = response.getBody().getCollectionValue();
assertEquals(3, complexValueCollection.size());
Iterator<ODataValue> iterator = complexValueCollection.iterator();
Iterator<ClientValue> iterator = complexValueCollection.iterator();
ODataComplexValue next = iterator.next().asComplex();
ClientComplexValue next = iterator.next().asComplex();
assertEquals(16, next.get("PropertyInt16").getPrimitiveValue().toValue());
assertEquals("Test123", next.get("PropertyString").getPrimitiveValue().toValue());
@ -176,18 +176,18 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void entityActionETTwoKeyTwoPrim() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTETTwoKeyTwoPrimParam").build();
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters
.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) -365));
ODataInvokeResponse<ODataEntity> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataEntity.class, parameters)
ODataInvokeResponse<ClientEntity> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntity.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataEntity entity = response.getBody();
ODataProperty propInt16 = entity.getProperty("PropertyInt16");
ClientEntity entity = response.getBody();
ClientProperty propInt16 = entity.getProperty("PropertyInt16");
assertNotNull(propInt16);
assertEquals(-365, propInt16.getPrimitiveValue().toValue());
ODataProperty propString = entity.getProperty("PropertyString");
ClientProperty propString = entity.getProperty("PropertyString");
assertNotNull(propString);
assertEquals("Test String2", propString.getPrimitiveValue().toValue());
}
@ -196,17 +196,17 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void entityCollectionActionETKeyNav() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollETKeyNavParam").build();
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters
.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 3));
ODataInvokeResponse<ODataEntitySet> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataEntitySet.class, parameters)
ODataInvokeResponse<ClientEntitySet> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntitySet.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataEntitySet entitySet = response.getBody();
ClientEntitySet entitySet = response.getBody();
assertEquals(3, entitySet.getEntities().size());
Integer key = 1;
for (ODataEntity entity : entitySet.getEntities()) {
for (ClientEntity entity : entitySet.getEntities()) {
assertEquals(key, entity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
key++;
}
@ -216,14 +216,14 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void entityCollectionActionETKeyNavEmptyCollection() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollETKeyNavParam").build();
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters
.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) 0));
ODataInvokeResponse<ODataEntitySet> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataEntitySet.class, parameters)
ODataInvokeResponse<ClientEntitySet> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntitySet.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataEntitySet entitySet = response.getBody();
ClientEntitySet entitySet = response.getBody();
assertEquals(0, entitySet.getEntities().size());
}
@ -231,14 +231,14 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
public void entityCollectionActionETKeyNavNegativeParam() throws Exception {
URI actionURI =
getClient().newURIBuilder(TecSvcConst.BASE_URI).appendActionCallSegment("AIRTCollETKeyNavParam").build();
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters
.put("ParameterInt16", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt16((short) -10));
ODataInvokeResponse<ODataEntitySet> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataEntitySet.class, parameters)
ODataInvokeResponse<ClientEntitySet> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntitySet.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataEntitySet entitySet = response.getBody();
ClientEntitySet entitySet = response.getBody();
assertEquals(0, entitySet.getEntities().size());
}
@ -251,18 +251,18 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
time.set(Calendar.HOUR_OF_DAY, 3);
time.set(Calendar.MINUTE, 0);
time.set(Calendar.SECOND, 0);
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters
.put("ParameterTimeOfDay", getClient().getObjectFactory().newPrimitiveValueBuilder().setType(
EdmPrimitiveTypeKind.TimeOfDay).setValue(time).build());
ODataInvokeResponse<ODataEntitySet> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataEntitySet.class, parameters)
ODataInvokeResponse<ClientEntitySet> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntitySet.class, parameters)
.execute();
assertEquals(200, response.getStatusCode());
ODataEntitySet entitySet = response.getBody();
ClientEntitySet entitySet = response.getBody();
assertEquals(3, entitySet.getEntities().size());
Integer key = 1;
for (ODataEntity entity : entitySet.getEntities()) {
for (ClientEntity entity : entitySet.getEntities()) {
assertEquals(key, entity.getProperty("PropertyInt16").getPrimitiveValue().toValue());
key++;
}
@ -275,12 +275,12 @@ public class ActionImportITCase extends AbstractBaseTestITCase {
Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
dateTime.clear();
dateTime.set(1012, 2, 0, 0, 0, 0);
Map<String, ODataValue> parameters = new HashMap<String, ODataValue>();
Map<String, ClientValue> parameters = new HashMap<String, ClientValue>();
parameters
.put("ParameterDate", getClient().getObjectFactory().newPrimitiveValueBuilder().setType(
EdmPrimitiveTypeKind.Date).setValue(dateTime).build());
ODataInvokeResponse<ODataEntity> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ODataEntity.class, parameters)
ODataInvokeResponse<ClientEntity> response =
getClient().getInvokeRequestFactory().getActionInvokeRequest(actionURI, ClientEntity.class, parameters)
.execute();
// Check 201
assertEquals(201, response.getStatusCode());

View File

@ -34,7 +34,7 @@ public class BasicHttpExceptionHandlingITCase extends AbstractBaseTestITCase {
private static final String SERVICE_URI = TecSvcConst.BASE_URI + "/";
@Test
public void ambigiousXHTTPMethod() throws Exception{
public void ambigiousXHTTPMethod() throws Exception {
URL url = new URL(SERVICE_URI + "?$format=json");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();

View File

@ -45,9 +45,9 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
import org.apache.olingo.client.api.http.HttpClientException;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientObjectFactory;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
@ -91,10 +91,10 @@ public class BatchClientITCase extends AbstractTestITCase {
*/
final ODataClient client = getClient();
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
// Try to create entity, with invalid type
final ODataEntity entity = of.newEntity(ES_NOT_AVAILABLE);
final ClientEntity entity = of.newEntity(ES_NOT_AVAILABLE);
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder()
.buildString("1")));
final ODataBatchRequest batchRequest = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
@ -104,7 +104,7 @@ public class BatchClientITCase extends AbstractTestITCase {
final URI targetURI = client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_NOT_AVAILABLE_NAME)
.build();
final ODataEntityCreateRequest<ODataEntity> createRequest = client.getCUDRequestFactory()
final ODataEntityCreateRequest<ClientEntity> createRequest = client.getCUDRequestFactory()
.getEntityCreateRequest(targetURI, entity);
changeset.addRequest(createRequest);
@ -257,7 +257,7 @@ public class BatchClientITCase extends AbstractTestITCase {
final BatchManager payload = request.payloadManager();
final URI uri = new URI(SERVICE_URI + "/../ESAllPrim(32767)");
final ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
queryReq.setFormat(ODataFormat.JSON);
payload.addRequest(queryReq);
@ -282,7 +282,7 @@ public class BatchClientITCase extends AbstractTestITCase {
final BatchManager payload = request.payloadManager();
final URI uri = new URI("http://otherhost/odata/ESAllPrim(32767)");
final ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
queryReq.setFormat(ODataFormat.JSON);
payload.addRequest(queryReq);
@ -297,7 +297,7 @@ public class BatchClientITCase extends AbstractTestITCase {
final BatchManager payload = request.payloadManager();
final URI uri = new URI("/ESAllPrim(32767)");
final ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
final ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
queryReq.setFormat(ODataFormat.JSON);
payload.addRequest(queryReq);
@ -366,29 +366,28 @@ public class BatchClientITCase extends AbstractTestITCase {
public void changesetWithReferences() throws EdmPrimitiveTypeException, URISyntaxException {
// create your request
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
request.setAccept(ACCEPT);
final BatchManager streamManager = request.payloadManager();
final ODataChangeset changeset = streamManager.addChangeset();
final ODataEntity entityESAllPrim = getClient().getObjectFactory().
final ClientEntity entityESAllPrim = getClient().getObjectFactory().
newEntity(new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
entityESAllPrim.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
"PropertyDouble",
client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(3.1415)));
entityESAllPrim.addLink(
of.newEntityNavigationLink("NavPropertyETTwoPrimOne", client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESTwoPrim")
.appendKeySegment(-365)
.build()));
.appendEntitySetSegment("ESTwoPrim")
.appendKeySegment(-365)
.build()));
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim");
// add create request
final ODataEntityCreateRequest<ODataEntity> createReq =
final ODataEntityCreateRequest<ClientEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), entityESAllPrim);
createReq.setFormat(ODataFormat.JSON);
changeset.addRequest(createReq);
@ -397,21 +396,21 @@ public class BatchClientITCase extends AbstractTestITCase {
int createRequestRef = changeset.getLastContentId();
// add update request
final ODataEntity entityUpdate = client.getObjectFactory().newEntity(entityESAllPrim.getTypeName());
final ClientEntity entityUpdate = client.getObjectFactory().newEntity(entityESAllPrim.getTypeName());
entityUpdate.addLink(client.getObjectFactory().newEntitySetNavigationLink(
"NavPropertyETTwoPrimMany",
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESTwoPrim").appendKeySegment(32767).build()));
final ODataEntityUpdateRequest<ODataEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
final ODataEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
URI.create("$" + createRequestRef), UpdateType.PATCH, entityUpdate);
updateReq.setFormat(ODataFormat.JSON);
changeset.addRequest(updateReq);
final ODataBatchResponse response = streamManager.getResponse();
assertEquals(HttpStatusCode.ACCEPTED.getStatusCode(), response.getStatusCode());
final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
// verify response payload ...
final Iterator<ODataBatchResponseItem> bodyIterator = response.getBody();
final ODataBatchResponseItem item = bodyIterator.next();
@ -422,31 +421,31 @@ public class BatchClientITCase extends AbstractTestITCase {
ODataResponse res = chgitem.next();
assertEquals(HttpStatusCode.CREATED.getStatusCode(), res.getStatusCode());
assertTrue(res instanceof ODataEntityCreateResponse);
final ODataEntityCreateResponse<ODataEntity> createResponse = ((ODataEntityCreateResponse<ODataEntity>) res);
final ODataEntityCreateResponse<ClientEntity> createResponse = ((ODataEntityCreateResponse<ClientEntity>) res);
res = chgitem.next();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), res.getStatusCode());
assertTrue(res instanceof ODataEntityUpdateResponse);
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
new URI(createResponse.getHeader(HttpHeader.LOCATION).iterator().next() + "/NavPropertyETTwoPrimMany"));
req.setFormat(ODataFormat.JSON);
req.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntitySet> getResponse = req.execute();
final ODataRetrieveResponse<ClientEntitySet> getResponse = req.execute();
assertEquals(32767, getResponse.getBody()
.getEntities()
.get(0)
.getProperty("PropertyInt16")
.getPrimitiveValue()
.toValue());
}
.getEntities()
.get(0)
.getProperty("PropertyInt16")
.getPrimitiveValue()
.toValue());
}
@Test
@SuppressWarnings("unchecked")
public void changesetBatchRequest() throws URISyntaxException {
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(SERVICE_URI);
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
request.setAccept(ACCEPT);
final BatchManager payload = request.payloadManager();
@ -466,18 +465,18 @@ public class BatchClientITCase extends AbstractTestITCase {
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim");
URI editLink = targetURI.build();
ODataEntity postEntity = client.getObjectFactory().newEntity(
ClientEntity postEntity = client.getObjectFactory().newEntity(
new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
postEntity.addLink(of.newEntityNavigationLink("NavPropertyETTwoPrimOne", client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESTwoPrim")
.appendKeySegment(32766)
.build()));
.appendEntitySetSegment("ESTwoPrim")
.appendKeySegment(32766)
.build()));
postEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
"PropertyDouble",
client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(3.1415)));
final ODataEntityCreateRequest<ODataEntity> createRequest =
final ODataEntityCreateRequest<ClientEntity> createRequest =
client.getCUDRequestFactory().getEntityCreateRequest(editLink, postEntity);
createRequest.setFormat(ODataFormat.JSON);
@ -488,15 +487,15 @@ public class BatchClientITCase extends AbstractTestITCase {
targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESAllPrim").appendKeySegment(0);
editLink = targetURI.build();
ODataEntity patchEntity = client.getObjectFactory()
.newEntity(new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
ClientEntity patchEntity = client.getObjectFactory()
.newEntity(new FullQualifiedName("olingo.odata.test1.ESAllPrim"));
patchEntity.setEditLink(editLink);
patchEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
"PropertyDouble",
client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(3.1415)));
ODataEntityUpdateRequest<ODataEntity> changeReq =
ODataEntityUpdateRequest<ClientEntity> changeReq =
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
changeReq.setFormat(ODataFormat.JSON);
changeset.addRequest(changeReq);
@ -512,12 +511,12 @@ public class BatchClientITCase extends AbstractTestITCase {
patchEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
"PropertyDouble",
client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(3.1415)));
patchEntity.addLink(of.newEntityNavigationLink("NavPropertyETTwoPrimOne", client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESTwoPrim")
.appendKeySegment(32766)
.build()));
changeReq = client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patchEntity);
changeReq.setFormat(ODataFormat.JSON);
changeset.addRequest(changeReq);
@ -541,24 +540,24 @@ public class BatchClientITCase extends AbstractTestITCase {
assertTrue(item.hasNext());
final ODataResponse response0 = item.next();
assertTrue(response0 instanceof ODataRetrieveResponse);
assertEquals(34, ((ODataRetrieveResponse<ODataEntity>)response0).getBody()
.getProperty("PropertyDecimal")
.getPrimitiveValue()
.toValue());
assertEquals(34, ((ODataRetrieveResponse<ClientEntity>) response0).getBody()
.getProperty("PropertyDecimal")
.getPrimitiveValue()
.toValue());
// Check change set
assertTrue(bodyIterator.hasNext());
item = bodyIterator.next();
assertTrue(item.isChangeset());
// Insert
assertTrue(item.hasNext());
final ODataResponse response1 = item.next();
assertEquals(HttpStatusCode.CREATED.getStatusCode(), response1.getStatusCode());
assertTrue(response1 instanceof ODataEntityCreateResponse);
assertEquals(3.1415, ((ODataEntityCreateResponse<ODataEntity>) response1).getBody().getProperty("PropertyDouble")
.getPrimitiveValue()
.toValue());
assertEquals(3.1415, ((ODataEntityCreateResponse<ClientEntity>) response1).getBody().getProperty("PropertyDouble")
.getPrimitiveValue()
.toValue());
// Update
assertTrue(item.hasNext());
final ODataResponse response2 = item.next();
@ -568,12 +567,12 @@ public class BatchClientITCase extends AbstractTestITCase {
// Upsert
assertTrue(item.hasNext());
final ODataResponse response3 = item.next();
assertEquals(HttpStatusCode.CREATED.getStatusCode(),response3.getStatusCode());
assertEquals(HttpStatusCode.CREATED.getStatusCode(), response3.getStatusCode());
assertTrue(response3 instanceof ODataEntityUpdateResponse);
assertEquals(3.1415, ((ODataEntityUpdateResponse<ODataEntity>) response3).getBody().getProperty("PropertyDouble")
.getPrimitiveValue()
.toValue());
assertEquals(3.1415, ((ODataEntityUpdateResponse<ClientEntity>) response3).getBody().getProperty("PropertyDouble")
.getPrimitiveValue()
.toValue());
// Check second get request
assertTrue(bodyIterator.hasNext());
item = bodyIterator.next();
@ -581,18 +580,19 @@ public class BatchClientITCase extends AbstractTestITCase {
assertTrue(item.hasNext());
final ODataResponse response4 = item.next();
assertTrue(response4 instanceof ODataRetrieveResponse);
assertEquals(3.1415, ((ODataRetrieveResponse<ODataEntity>)response4).getBody()
.getProperty("PropertyDouble")
.getPrimitiveValue()
.toValue());
assertEquals(3.1415, ((ODataRetrieveResponse<ClientEntity>) response4).getBody()
.getProperty("PropertyDouble")
.getPrimitiveValue()
.toValue());
}
private void appendGetRequest(final BatchManager manager, final String segment, final Object key, boolean isRelative)
throws URISyntaxException {
final URIBuilder targetURI = client.newURIBuilder(SERVICE_URI);
targetURI.appendEntitySetSegment(segment).appendKeySegment(key);
final URI uri = (isRelative) ? new URI(SERVICE_URI).relativize(targetURI.build()) : targetURI.build();
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(uri);
queryReq.setFormat(ODataFormat.JSON);
manager.addRequest(queryReq);
}

View File

@ -35,12 +35,12 @@ import org.apache.olingo.client.api.communication.response.ODataEntityCreateResp
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientInlineEntity;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.domain.ClientObjectFactory;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
@ -77,10 +77,10 @@ public class BindingITCase extends AbstractBaseTestITCase {
public void testCreateBindingSimple() throws EdmPrimitiveTypeException {
final ODataClient client = getClient();
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
// Create entity (EntitySet: ESKeyNav, Type: ETKeyNav)
final ODataEntity entity = of.newEntity(ET_KEY_NAV);
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
entity.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)));
entity.getProperties()
@ -102,26 +102,26 @@ public class BindingITCase extends AbstractBaseTestITCase {
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))))));
// Bind existing entities via binding synatx
entity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
entity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(new LinkedHashMap<String, Object>() {
private static final long serialVersionUID = 3109256773218160485L;
{
put(PROPERTY_INT16, 3);
put(PROPERTY_STRING, "1");
}
}).build()));
final ODataLink navLinkOne =
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(new LinkedHashMap<String, Object>() {
private static final long serialVersionUID = 3109256773218160485L;
{
put(PROPERTY_INT16, 3);
put(PROPERTY_STRING, "1");
}
}).build()));
final ClientLink navLinkOne =
of.newEntityNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE, client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(
ES_KEY_NAV).appendKeySegment(1).build());
final ODataLink navLinkMany1 =
final ClientLink navLinkMany1 =
of.newEntitySetNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY, client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(
ES_KEY_NAV).appendKeySegment(2).build());
final ODataLink navLinkMany2 =
final ClientLink navLinkMany2 =
of.newEntitySetNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY, client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(
ES_KEY_NAV).appendKeySegment(3).build());
@ -129,7 +129,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
final HashMap<String, Object> combinedKey = new HashMap<String, Object>();
combinedKey.put(PROPERTY_INT16, 1);
combinedKey.put(PROPERTY_STRING, "1");
final ODataLink navLink2Many =
final ClientLink navLink2Many =
of.newEntitySetNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(combinedKey).build());
@ -138,7 +138,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
entity.addLink(navLinkMany2);
entity.addLink(navLink2Many);
final ODataEntityCreateResponse<ODataEntity> createResponse =
final ODataEntityCreateResponse<ClientEntity> createResponse =
client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
final String cookie = createResponse.getHeader(HttpHeader.SET_COOKIE).iterator().next();
final Short entityInt16Key =
@ -149,17 +149,17 @@ public class BindingITCase extends AbstractBaseTestITCase {
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(entityInt16Key).expand(
NAV_PROPERTY_ET_KEY_NAV_ONE, NAV_PROPERTY_ET_KEY_NAV_MANY, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
final ODataEntityRequest<ODataEntity> entityGetRequest =
final ODataEntityRequest<ClientEntity> entityGetRequest =
client.getRetrieveRequestFactory().getEntityRequest(entityGetURI);
entityGetRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> entityGetResponse = entityGetRequest.execute();
final ODataRetrieveResponse<ClientEntity> entityGetResponse = entityGetRequest.execute();
// NAV_PROPERTY_ET_KEY_NAV_ONE
assertEquals(1, entityGetResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
// NAV_PROPERTY_ET_KEY_NAV_MANY(0)
Iterator<ODataValue> iterator =
Iterator<ClientValue> iterator =
entityGetResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_MANY).getCollectionValue().iterator();
assertEquals(2, iterator.next().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
@ -176,10 +176,10 @@ public class BindingITCase extends AbstractBaseTestITCase {
final URI etTwoKeyNavEntityURI =
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(combinedKey).expand(
NAV_PROPERTY_ET_KEY_NAV_ONE).build();
final ODataEntityRequest<ODataEntity> etTwoKeyNavEntityRequest =
final ODataEntityRequest<ClientEntity> etTwoKeyNavEntityRequest =
client.getRetrieveRequestFactory().getEntityRequest(etTwoKeyNavEntityURI);
etTwoKeyNavEntityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> etTwoKeyNavEntityResponse = etTwoKeyNavEntityRequest.execute();
final ODataRetrieveResponse<ClientEntity> etTwoKeyNavEntityResponse = etTwoKeyNavEntityRequest.execute();
assertEquals(entityInt16Key, etTwoKeyNavEntityResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE)
.getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toCastValue(Short.class));
@ -194,23 +194,23 @@ public class BindingITCase extends AbstractBaseTestITCase {
final ODataClient client = getClient();
final URI entityURI =
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).build();
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
// ESKeyNav(1).NavPropertyETKeyNavOne = ESKeyNav(2)
// ESKeyNav(1).NavPropertyETKeyNavMany = { ESKeyNav(1), ESKeyNav(2) }
// => Replace NavPropertyETKeyNavOne with ESKeyNav(3)
// => Add to NavPropertyETKeyNavOne ESKeyNav(3)
final ODataEntity entity = of.newEntity(ET_KEY_NAV);
final ODataLink navLinkOne =
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
final ClientLink navLinkOne =
of.newEntityNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE, client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(3).build());
final ODataLink navLinkMany =
final ClientLink navLinkMany =
of.newEntitySetNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY, client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(3).build());
entity.addLink(navLinkOne);
entity.addLink(navLinkMany);
final ODataEntityUpdateResponse<ODataEntity> updateResponse =
final ODataEntityUpdateResponse<ClientEntity> updateResponse =
client.getCUDRequestFactory().getEntityUpdateRequest(entityURI, UpdateType.PATCH, entity).execute();
final String cookie = updateResponse.getHeader(HttpHeader.SET_COOKIE).iterator().next();
@ -218,16 +218,16 @@ public class BindingITCase extends AbstractBaseTestITCase {
final URI entityGetURI =
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).expand(
NAV_PROPERTY_ET_KEY_NAV_ONE, NAV_PROPERTY_ET_KEY_NAV_MANY).build();
final ODataEntityRequest<ODataEntity> entityRequest =
final ODataEntityRequest<ClientEntity> entityRequest =
client.getRetrieveRequestFactory().getEntityRequest(entityGetURI);
entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> entityResponse = entityRequest.execute();
final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
assertEquals(3, entityResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals(3, entityResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_MANY).getCollectionValue().size());
Iterator<ODataValue> iterator =
Iterator<ClientValue> iterator =
entityResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_MANY).getCollectionValue().iterator();
assertEquals(1, iterator.next().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals(2, iterator.next().asComplex().get(PROPERTY_INT16).getPrimitiveValue().toValue());
@ -244,16 +244,16 @@ public class BindingITCase extends AbstractBaseTestITCase {
final ODataClient client = getClient();
final URI entityURI =
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).build();
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
// Request to single (non collection) navigation property
ODataEntity entity = of.newEntity(ET_KEY_NAV);
final ODataLink navLinkOne =
ClientEntity entity = of.newEntity(ET_KEY_NAV);
final ClientLink navLinkOne =
of.newEntityNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE, client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(42).build());
entity.addLink(navLinkOne);
ODataEntityUpdateResponse<ODataEntity> updateResponse = null;
ODataEntityUpdateResponse<ClientEntity> updateResponse = null;
try {
updateResponse =
client.getCUDRequestFactory().getEntityUpdateRequest(entityURI, UpdateType.PATCH, entity).execute();
@ -264,7 +264,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
// Request to collection navigation propetry
entity = of.newEntity(ET_KEY_NAV);
final ODataLink navLinkMany =
final ClientLink navLinkMany =
of.newEntitySetNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY, client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(3).build());
entity.addLink(navLinkMany);
@ -282,114 +282,114 @@ public class BindingITCase extends AbstractBaseTestITCase {
final ODataClient client = getClient();
final URI entityURI =
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).build();
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
// Request to single (non collection) navigation property
ODataEntity entity = of.newEntity(ET_KEY_NAV);
final ODataProperty navPropery = of.newComplexProperty(NAV_PROPERTY_ET_KEY_NAV_ONE, null);
ClientEntity entity = of.newEntity(ET_KEY_NAV);
final ClientProperty navPropery = of.newComplexProperty(NAV_PROPERTY_ET_KEY_NAV_ONE, null);
entity.getProperties().add(navPropery);
ODataEntityUpdateResponse<ODataEntity> updateResponse =
ODataEntityUpdateResponse<ClientEntity> updateResponse =
client.getCUDRequestFactory().getEntityUpdateRequest(entityURI, UpdateType.PATCH, entity).execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), updateResponse.getStatusCode());
final ODataEntityRequest<ODataEntity> getRequest =
final ODataEntityRequest<ClientEntity> getRequest =
client.getRetrieveRequestFactory().getEntityRequest(
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).expand(
NAV_PROPERTY_ET_KEY_NAV_ONE).build());
getRequest.addCustomHeader(HttpHeader.COOKIE, updateResponse.getHeader(HttpHeader.SET_COOKIE).iterator().next());
final ODataRetrieveResponse<ODataEntity> getResponse = getRequest.execute();
final ODataRetrieveResponse<ClientEntity> getResponse = getRequest.execute();
ODataProperty property = getResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE);
ClientProperty property = getResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE);
assertEquals(null, property.getPrimitiveValue());
}
@Test
public void testUpdateCollectionNavigationPropertyWithNull() {
final ODataClient client = getClient();
final URI entityURI =
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(1).build();
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
// Request to single (non collection) navigation property
ODataEntity entity = of.newEntity(ET_KEY_NAV);
final ODataProperty navPropery = of.newComplexProperty(NAV_PROPERTY_ET_KEY_NAV_MANY, null);
ClientEntity entity = of.newEntity(ET_KEY_NAV);
final ClientProperty navPropery = of.newComplexProperty(NAV_PROPERTY_ET_KEY_NAV_MANY, null);
entity.getProperties().add(navPropery);
try {
client.getCUDRequestFactory().getEntityUpdateRequest(entityURI, UpdateType.PATCH, entity).execute();
fail();
} catch(ODataClientErrorException e) {
} catch (ODataClientErrorException e) {
assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
}
}
@Test
public void testDeepInsertWithBindingSameNavigationProperty() {
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
final ODataObjectFactory of = client.getObjectFactory();
final ODataEntity entity = of.newEntity(ET_KEY_NAV);
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder()
.buildString("1")));
entity.getProperties().add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short)1)))
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("1")))));
final ODataEntity innerEntity = of.newEntity(ET_KEY_NAV);
innerEntity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder()
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
final ClientObjectFactory of = client.getObjectFactory();
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder()
.buildString("1")));
entity.getProperties().add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 1)))
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("1")))));
final ClientEntity innerEntity = of.newEntity(ET_KEY_NAV);
innerEntity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder()
.buildString("2")));
innerEntity.getProperties().add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
innerEntity.getProperties().add(of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 1)))
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("2")))));
innerEntity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(new LinkedHashMap<String, Object>() {
private static final long serialVersionUID = 3109256773218160485L;
{
put(PROPERTY_INT16, 3);
put(PROPERTY_STRING, "1");
}
}).build()));
final ODataInlineEntity inlineLink = of.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
entity.addLink(inlineLink);
entity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(new LinkedHashMap<String, Object>() {
private static final long serialVersionUID = 3109256773218160485L;
{
put(PROPERTY_INT16, 3);
put(PROPERTY_STRING, "1");
}
}).build()));
final URI bindingURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.appendKeySegment(3)
.build();
entity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE, bindingURI));
final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
final ODataEntityCreateResponse<ODataEntity> response =
client.getCUDRequestFactory().getEntityCreateRequest(targetURI, entity).execute();
assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
assertEquals(1, response.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)
.asInlineEntity()
.getEntity()
.getProperty(PROPERTY_COMP_TWO_PRIM)
.getComplexValue()
.get(PROPERTY_INT16)
.getPrimitiveValue()
.toValue());
innerEntity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(new LinkedHashMap<String, Object>() {
private static final long serialVersionUID = 3109256773218160485L;
{
put(PROPERTY_INT16, 3);
put(PROPERTY_STRING, "1");
}
}).build()));
final ClientInlineEntity inlineLink = of.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
entity.addLink(inlineLink);
entity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(new LinkedHashMap<String, Object>() {
private static final long serialVersionUID = 3109256773218160485L;
{
put(PROPERTY_INT16, 3);
put(PROPERTY_STRING, "1");
}
}).build()));
final URI bindingURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.appendKeySegment(3)
.build();
entity.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE, bindingURI));
final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
final ODataEntityCreateResponse<ClientEntity> response =
client.getCUDRequestFactory().getEntityCreateRequest(targetURI, entity).execute();
assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
assertEquals(1, response.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_ONE)
.asInlineEntity()
.getEntity()
.getProperty(PROPERTY_COMP_TWO_PRIM)
.getComplexValue()
.get(PROPERTY_INT16)
.getPrimitiveValue()
.toValue());
}
@Override
protected ODataClient getClient() {
ODataClient odata = ODataClientFactory.getClient();

View File

@ -40,15 +40,15 @@ import org.apache.olingo.client.api.communication.response.ODataEntityCreateResp
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientComplexValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientInlineEntity;
import org.apache.olingo.commons.api.domain.ClientInlineEntitySet;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.domain.ClientObjectFactory;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
@ -93,8 +93,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
final ODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
final ODataObjectFactory of = client.getObjectFactory();
final ODataEntity entity = of.newEntity(ET_KEY_NAV);
final ClientObjectFactory of = client.getObjectFactory();
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
// Root entity
entity.getProperties().add(
@ -106,7 +106,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
"String Property level 0, complex level 1")))));
// First level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
final ODataEntity firstLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
final ClientEntity firstLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
firstLevelTwoKeyNav.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 42)))
@ -116,12 +116,12 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
firstLevelTwoKeyNav.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
final ODataInlineEntity firstLevelTwoKeyOneInline =
final ClientInlineEntity firstLevelTwoKeyOneInline =
of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, firstLevelTwoKeyNav);
entity.addLink(firstLevelTwoKeyOneInline);
// Second level NavPropertyETTwoKeyNavOne => Type ETTwoKeyNav
final ODataEntity secondLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
final ClientEntity secondLevelTwoKeyNav = of.newEntity(ET_TWO_KEY_NAV);
secondLevelTwoKeyNav.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 421)))
@ -131,7 +131,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
secondLevelTwoKeyNav.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
// Binding links
secondLevelTwoKeyNav.addLink(of.newEntityNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, client.newURIBuilder(
SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(new LinkedHashMap<String, Object>() {
@ -142,12 +142,12 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
}
}).build()));
final ODataInlineEntity secondLevelTwoKeyOneInline =
final ClientInlineEntity secondLevelTwoKeyOneInline =
of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, secondLevelTwoKeyNav);
firstLevelTwoKeyNav.addLink(secondLevelTwoKeyOneInline);
// Third level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
final ODataEntity thirdLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
final ClientEntity thirdLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
thirdLevelTwoKeyNavMany1.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 431)))
@ -157,8 +157,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
thirdLevelTwoKeyNavMany1.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
final ODataEntity thirdLevelTwoKeyNavMany2 = of.newEntity(ET_TWO_KEY_NAV);
final ClientEntity thirdLevelTwoKeyNavMany2 = of.newEntity(ET_TWO_KEY_NAV);
thirdLevelTwoKeyNavMany2.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 432)))
@ -168,15 +168,15 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
thirdLevelTwoKeyNavMany2.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
final ODataEntitySet entitySetThirdLevelTwoKeyNavMany = of.newEntitySet();
final ClientEntitySet entitySetThirdLevelTwoKeyNavMany = of.newEntitySet();
entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany1);
entitySetThirdLevelTwoKeyNavMany.getEntities().add(thirdLevelTwoKeyNavMany2);
secondLevelTwoKeyNav.addLink(of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
entitySetThirdLevelTwoKeyNavMany));
// First level NavPropertyETTwoKeyNavMany => Type ETTwoKeyNav
final ODataEntity firstLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
final ClientEntity firstLevelTwoKeyNavMany1 = of.newEntity(ET_TWO_KEY_NAV);
firstLevelTwoKeyNavMany1.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 422)))
@ -186,17 +186,17 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
firstLevelTwoKeyNavMany1.getProperties().add(
of.newComplexProperty(PROPERTY_COMP_NAV, of.newComplexValue(CT_BASE_PRIM_COMP_NAV)));
final ODataEntitySet entitySetfirstLevelTwoKeyNavMany = of.newEntitySet();
final ClientEntitySet entitySetfirstLevelTwoKeyNavMany = of.newEntitySet();
entitySetfirstLevelTwoKeyNavMany.getEntities().add(firstLevelTwoKeyNavMany1);
entity.addLink(of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
entitySetfirstLevelTwoKeyNavMany));
final ODataEntityCreateResponse<ODataEntity> createResponse =
final ODataEntityCreateResponse<ClientEntity> createResponse =
client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
// Check response
final ODataEntity resultEntityFirstLevel =
final ClientEntity resultEntityFirstLevel =
createResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).asInlineEntity().getEntity();
assertEquals(42, resultEntityFirstLevel.getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_INT16)
.getPrimitiveValue().toValue());
@ -204,7 +204,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.getComplexValue().get(PROPERTY_STRING)
.getPrimitiveValue().toValue());
final ODataEntity resultEntitySecondLevel =
final ClientEntity resultEntitySecondLevel =
resultEntityFirstLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE).asInlineEntity().getEntity();
assertEquals(421, resultEntitySecondLevel.getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_INT16)
.getPrimitiveValue().toValue());
@ -213,7 +213,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.getComplexValue().get(PROPERTY_STRING)
.getPrimitiveValue().toValue());
final ODataEntitySet thirdLevelEntitySetNavMany =
final ClientEntitySet thirdLevelEntitySetNavMany =
resultEntitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
assertEquals(2, thirdLevelEntitySetNavMany.getEntities().size());
@ -227,7 +227,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
assertEquals("String Property level 3, complex level 1", thirdLevelEntitySetNavMany.getEntities().get(1)
.getProperty(PROPERTY_COMP_TWO_PRIM).getComplexValue().get(PROPERTY_STRING).getPrimitiveValue().toValue());
final ODataEntitySet firstLevelEntitySetNavMany =
final ClientEntitySet firstLevelEntitySetNavMany =
createResponse.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
assertEquals(1, firstLevelEntitySetNavMany.getEntities().size());
assertEquals(422, firstLevelEntitySetNavMany.getEntities().get(0).getProperty(PROPERTY_COMP_TWO_PRIM)
@ -240,8 +240,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
public void testSimpleDeepInsert() throws EdmPrimitiveTypeException {
final ODataClient client = getClient();
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
final ODataObjectFactory of = client.getObjectFactory();
final ODataEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
final ClientObjectFactory of = client.getObjectFactory();
final ClientEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
// Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
entity.getProperties()
@ -266,7 +266,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
// Non collection navigation property
// Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne)
final ODataEntity inlineEntitySingle = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
final ClientEntity inlineEntitySingle = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
inlineEntitySingle.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
inlineEntitySingle.getProperties()
@ -284,7 +284,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
// Collection navigation property
// The navigation property has a partner navigation property named "NavPropertyETKeyNavOne"
// Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany
final ODataEntity inlineEntityCol1 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
final ClientEntity inlineEntityCol1 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
inlineEntityCol1.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 44)));
inlineEntityCol1.getProperties()
@ -299,7 +299,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("442")))));
final ODataEntity inlineEntityCol2 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
final ClientEntity inlineEntityCol2 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
inlineEntityCol2.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 45)));
inlineEntityCol2.getProperties()
@ -314,19 +314,19 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("452")))));
final ODataInlineEntity newDeepInsertEntityLink =
final ClientInlineEntity newDeepInsertEntityLink =
of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle);
final ODataEntitySet newDeepInsertEntitySet = of.newEntitySet();
final ClientEntitySet newDeepInsertEntitySet = of.newEntitySet();
newDeepInsertEntitySet.getEntities().add(inlineEntityCol1);
newDeepInsertEntitySet.getEntities().add(inlineEntityCol2);
final ODataInlineEntitySet newDeepInsertEntitySetLink =
final ClientInlineEntitySet newDeepInsertEntitySetLink =
of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, newDeepInsertEntitySet);
entity.addLink(newDeepInsertEntityLink);
entity.addLink(newDeepInsertEntitySetLink);
// Perform create request
final ODataEntityCreateResponse<ODataEntity> responseCreate = client.getCUDRequestFactory()
final ODataEntityCreateResponse<ClientEntity> responseCreate = client.getCUDRequestFactory()
.getEntityCreateRequest(createURI, entity)
.execute();
assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode());
@ -334,16 +334,16 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).toString();
// Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property
ODataProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
ClientProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
final URI esKeyNavURI =
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
final ODataEntityRequest<ODataEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
final ODataEntityRequest<ClientEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
.getEntityRequest(esKeyNavURI);
esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> esKeyNavResponse = esKeyNavRequest.execute();
final ODataRetrieveResponse<ClientEntity> esKeyNavResponse = esKeyNavRequest.execute();
// Check nav. property NavPropertyETTwoKeyNavOne
assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
@ -354,12 +354,12 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
assertEquals(2, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue()
.size());
Iterator<ODataValue> twoKeyNavManyIterator =
Iterator<ClientValue> twoKeyNavManyIterator =
esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue().iterator();
final ODataValue firstTwoKeyNavEnity = twoKeyNavManyIterator.next(); // First entity
final ClientValue firstTwoKeyNavEnity = twoKeyNavManyIterator.next(); // First entity
assertEquals(441, firstTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
final ODataValue secondTwoKeyNavEnity = twoKeyNavManyIterator.next(); // Second entity
final ClientValue secondTwoKeyNavEnity = twoKeyNavManyIterator.next(); // Second entity
assertEquals(451, secondTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
@ -378,10 +378,10 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.appendKeySegment(composedKey)
.build();
final ODataEntityRequest<ODataEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
.getEntityRequest(esTwoKeyNavEntitySingleURI);
esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
assertEquals(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
@ -395,10 +395,10 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
final ODataEntityRequest<ODataEntity> esTwoKeyNavManyOneRequest =
final ODataEntityRequest<ClientEntity> esTwoKeyNavManyOneRequest =
client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
assertEquals(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
@ -416,10 +416,10 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
final ODataEntityRequest<ODataEntity> esTwoKeyNavManyTwoRequest =
final ODataEntityRequest<ClientEntity> esTwoKeyNavManyTwoRequest =
client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
assertEquals(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
@ -432,8 +432,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
public void testDeepInsertSameEntitySet() throws EdmPrimitiveTypeException {
final ODataClient client = getClient();
final URI createURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
final ODataObjectFactory of = client.getObjectFactory();
final ODataEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
final ClientObjectFactory of = client.getObjectFactory();
final ClientEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
// Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
entity.getProperties()
@ -469,7 +469,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.build()));
// Prepare inline entity(EntitySet: ESKeyNav, Type: ETKeyNav)
final ODataEntity innerEntity = of.newEntity(ET_KEY_NAV);
final ClientEntity innerEntity = of.newEntity(ET_KEY_NAV);
innerEntity.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
innerEntity.getProperties()
@ -503,11 +503,11 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
}
})
.build()));
ODataInlineEntity inlineEntity = of.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
ClientInlineEntity inlineEntity = of.newDeepInsertEntity(NAV_PROPERTY_ET_KEY_NAV_ONE, innerEntity);
entity.addLink(inlineEntity);
final ODataEntityCreateResponse<ODataEntity> responseCreate =
final ODataEntityCreateResponse<ClientEntity> responseCreate =
client.getCUDRequestFactory().getEntityCreateRequest(createURI, entity).execute();
final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).iterator().next();
final Short esKeyNavEntityKey =
@ -518,9 +518,10 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(esKeyNavEntityKey)
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
ODataEntityRequest<ODataEntity> entityRequest = client.getRetrieveRequestFactory().getEntityRequest(fetchEntityURI);
ODataEntityRequest<ClientEntity> entityRequest =
client.getRetrieveRequestFactory().getEntityRequest(fetchEntityURI);
entityRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> entityResponse = entityRequest.execute();
final ODataRetrieveResponse<ClientEntity> entityResponse = entityRequest.execute();
// Check values
assertEquals(431, entityResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(
@ -533,10 +534,10 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
final URI innerEntityURI =
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(innerEntityInt16Key)
.build();
final ODataEntityRequest<ODataEntity> innerRequest =
final ODataEntityRequest<ClientEntity> innerRequest =
client.getRetrieveRequestFactory().getEntityRequest(innerEntityURI);
innerRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
ODataRetrieveResponse<ODataEntity> innerResponse = innerRequest.execute();
ODataRetrieveResponse<ClientEntity> innerResponse = innerRequest.execute();
assertEquals(431, innerResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(PROPERTY_INT16)
.getPrimitiveValue().toValue());
@ -545,11 +546,11 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
@Test
public void testConsistency() throws EdmPrimitiveTypeException {
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
final String cookie = getCookie();
// Do not set PropertyString(Nullable=false)
final ODataEntity entity = of.newEntity(ET_KEY_NAV);
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
entity.getProperties().add(
of.newCollectionProperty(COL_PROPERTY_STRING,
of.newCollectionValue(EDM_STRING).add(
@ -558,7 +559,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
try {
ODataEntityCreateRequest<ODataEntity> request = client.getCUDRequestFactory()
ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
.getEntityCreateRequest(targetURI, entity);
request.addCustomHeader(HttpHeader.COOKIE, cookie);
request.execute();
@ -570,19 +571,19 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
// Entity must not be created
validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
}
@Test
public void testInvalidType() throws EdmPrimitiveTypeException {
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
final ODataObjectFactory of = client.getObjectFactory();
final ClientObjectFactory of = client.getObjectFactory();
final String cookie = getCookie();
final ODataEntity entity = of.newEntity(ET_KEY_NAV);
final ClientEntity entity = of.newEntity(ET_KEY_NAV);
entity.getProperties().add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildInt32(1)));
final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build();
try {
ODataEntityCreateRequest<ODataEntity> request = client.getCUDRequestFactory()
ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
.getEntityCreateRequest(targetURI, entity);
request.addCustomHeader(HttpHeader.COOKIE, cookie);
request.execute();
@ -598,7 +599,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
of.newPrimitiveValueBuilder().buildString("Test"))));
try {
ODataEntityCreateRequest<ODataEntity> request = client.getCUDRequestFactory()
ODataEntityCreateRequest<ClientEntity> request = client.getCUDRequestFactory()
.getEntityCreateRequest(targetURI, entity);
request.addCustomHeader(HttpHeader.COOKIE, cookie);
request.execute();
@ -608,14 +609,14 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
validateSet(targetURI, cookie, (short) 1, (short) 2, (short) 3);
}
@Test
@Ignore
public void testDeepInsertOnNavigationPropertyInComplexProperty() {
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
final ODataObjectFactory of = client.getObjectFactory();
final ODataEntity inlineEntity = of.newEntity(ET_TWO_KEY_NAV);
final ClientObjectFactory of = client.getObjectFactory();
final ClientEntity inlineEntity = of.newEntity(ET_TWO_KEY_NAV);
inlineEntity.getProperties().add(
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
inlineEntity.getProperties().add(
@ -624,8 +625,8 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 1)))
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("1")))));
final ODataEntity entity = of.newEntity(ET_TWO_KEY_NAV);
final ClientEntity entity = of.newEntity(ET_TWO_KEY_NAV);
entity.getProperties().add(
of.newComplexProperty(PROPERTY_COMP, of.newComplexValue(CT_PRIM_COMP)));
entity.getProperties().add(
@ -634,46 +635,46 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
of.newComplexProperty(PROPERTY_COMP_TWO_PRIM, of.newComplexValue(CT_TWO_PRIM)
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 2)))
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("2")))));
final ODataLink link = of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntity);
final ODataComplexValue complexValueCreate = of.newComplexValue(CT_NAV_FIVE_PROP);
final ClientLink link = of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntity);
final ClientComplexValue complexValueCreate = of.newComplexValue(CT_NAV_FIVE_PROP);
complexValueCreate.getNavigationLinks().add(link);
entity.getProperties().add(
of.newCollectionProperty(COL_PROPERTY_COMP_NAV, of.newCollectionValue(CT_NAV_FIVE_PROP)
.add(complexValueCreate)));
.add(complexValueCreate)));
final URI targetURI = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).build();
final ODataEntityCreateResponse<ODataEntity> response = client.getCUDRequestFactory()
.getEntityCreateRequest(targetURI, entity)
.execute();
final ODataEntityCreateResponse<ClientEntity> response = client.getCUDRequestFactory()
.getEntityCreateRequest(targetURI, entity)
.execute();
assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
final Iterator<ODataValue> iter = response.getBody()
.getProperty(COL_PROPERTY_COMP_NAV)
.getCollectionValue()
.iterator();
final Iterator<ClientValue> iter = response.getBody()
.getProperty(COL_PROPERTY_COMP_NAV)
.getCollectionValue()
.iterator();
assertTrue(iter.hasNext());
final ODataComplexValue complexValue = iter.next().asComplex();
final ODataLink linkedEntity = complexValue.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
final ClientComplexValue complexValue = iter.next().asComplex();
final ClientLink linkedEntity = complexValue.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE);
assertNotNull(linkedEntity);
assertEquals(1, linkedEntity.asInlineEntity()
.getEntity()
.getProperty(PROPERTY_INT16)
.getPrimitiveValue()
.toValue());
.getEntity()
.getProperty(PROPERTY_INT16)
.getPrimitiveValue()
.toValue());
}
@Test
public void testDeepUpsert() {
final ODataClient client = getClient();
final URI updateURI = client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_KEY_NAV)
.appendKeySegment(815)
.build();
final ODataObjectFactory of = client.getObjectFactory();
final ODataEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
.appendEntitySetSegment(ES_KEY_NAV)
.appendKeySegment(815)
.build();
final ClientObjectFactory of = client.getObjectFactory();
final ClientEntity entity = client.getObjectFactory().newEntity(ET_KEY_NAV);
// Prepare entity(EntitySet: ESKeyNav, Type: ETKeyNav)
entity.getProperties()
@ -698,7 +699,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
// Non collection navigation property
// Create related entity(EntitySet: ESTwoKeyNav, Type: ETTwoKeyNav, Nav. Property: NavPropertyETTwoKeyNavOne)
final ODataEntity inlineEntitySingle = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
final ClientEntity inlineEntitySingle = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
inlineEntitySingle.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 43)));
inlineEntitySingle.getProperties()
@ -716,7 +717,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
// Collection navigation property
// The navigation property has a partner navigation property named "NavPropertyETKeyNavOne"
// Create related entity(EntitySet: ESTwoKeyNav, Type: NavPropertyETTwoKeyNavMany
final ODataEntity inlineEntityCol1 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
final ClientEntity inlineEntityCol1 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
inlineEntityCol1.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 44)));
inlineEntityCol1.getProperties()
@ -731,7 +732,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 442)))
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("442")))));
final ODataEntity inlineEntityCol2 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
final ClientEntity inlineEntityCol2 = client.getObjectFactory().newEntity(ET_TWO_KEY_NAV);
inlineEntityCol2.getProperties()
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 45)));
inlineEntityCol2.getProperties()
@ -746,19 +747,19 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.add(of.newPrimitiveProperty(PROPERTY_INT16, of.newPrimitiveValueBuilder().buildInt16((short) 452)))
.add(of.newPrimitiveProperty(PROPERTY_STRING, of.newPrimitiveValueBuilder().buildString("452")))));
final ODataInlineEntity newDeepInsertEntityLink =
final ClientInlineEntity newDeepInsertEntityLink =
of.newDeepInsertEntity(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE, inlineEntitySingle);
final ODataEntitySet newDeepInsertEntitySet = of.newEntitySet();
final ClientEntitySet newDeepInsertEntitySet = of.newEntitySet();
newDeepInsertEntitySet.getEntities().add(inlineEntityCol1);
newDeepInsertEntitySet.getEntities().add(inlineEntityCol2);
final ODataInlineEntitySet newDeepInsertEntitySetLink =
final ClientInlineEntitySet newDeepInsertEntitySetLink =
of.newDeepInsertEntitySet(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, newDeepInsertEntitySet);
entity.addLink(newDeepInsertEntityLink);
entity.addLink(newDeepInsertEntitySetLink);
// Perform update request (upsert)
final ODataEntityUpdateResponse<ODataEntity> responseCreate = client.getCUDRequestFactory()
final ODataEntityUpdateResponse<ClientEntity> responseCreate = client.getCUDRequestFactory()
.getEntityUpdateRequest(updateURI, UpdateType.PATCH, entity)
.execute();
assertEquals(HttpStatusCode.CREATED.getStatusCode(), responseCreate.getStatusCode());
@ -766,16 +767,16 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
final String cookie = responseCreate.getHeader(HttpHeader.SET_COOKIE).toString();
// Fetch ESKeyNav entity with expand of NavPropertyETTwoKeyNavOne nav. property
ODataProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
ClientProperty propertyInt16 = responseCreate.getBody().getProperty(PROPERTY_INT16);
final URI esKeyNavURI =
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).appendKeySegment(
propertyInt16.getPrimitiveValue().toValue()).expand(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE,
NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).build();
final ODataEntityRequest<ODataEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
final ODataEntityRequest<ClientEntity> esKeyNavRequest = client.getRetrieveRequestFactory()
.getEntityRequest(esKeyNavURI);
esKeyNavRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> esKeyNavResponse = esKeyNavRequest.execute();
final ODataRetrieveResponse<ClientEntity> esKeyNavResponse = esKeyNavRequest.execute();
// Check nav. property NavPropertyETTwoKeyNavOne
assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_ONE));
@ -786,12 +787,12 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
assertNotNull(esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
assertEquals(2, esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue()
.size());
Iterator<ODataValue> twoKeyNavManyIterator =
Iterator<ClientValue> twoKeyNavManyIterator =
esKeyNavResponse.getBody().getProperty(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).getCollectionValue().iterator();
final ODataValue firstTwoKeyNavEnity = twoKeyNavManyIterator.next(); // First entity
final ClientValue firstTwoKeyNavEnity = twoKeyNavManyIterator.next(); // First entity
assertEquals(441, firstTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
final ODataValue secondTwoKeyNavEnity = twoKeyNavManyIterator.next(); // Second entity
final ClientValue secondTwoKeyNavEnity = twoKeyNavManyIterator.next(); // Second entity
assertEquals(451, secondTwoKeyNavEnity.asComplex().get(PROPERTY_COMP_NAV).getValue().asComplex().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
@ -810,10 +811,10 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
.appendKeySegment(composedKey)
.build();
final ODataEntityRequest<ODataEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
final ODataEntityRequest<ClientEntity> esTwoKeyNavSingleRequest = client.getRetrieveRequestFactory()
.getEntityRequest(esTwoKeyNavEntitySingleURI);
esTwoKeyNavSingleRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavSingleResponse = esTwoKeyNavSingleRequest.execute();
assertEquals(431, esTwoKeyNavSingleResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
@ -827,10 +828,10 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
final ODataEntityRequest<ODataEntity> esTwoKeyNavManyOneRequest =
final ODataEntityRequest<ClientEntity> esTwoKeyNavManyOneRequest =
client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyOneURI);
esTwoKeyNavManyOneRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyOneResponse = esTwoKeyNavManyOneRequest.execute();
assertEquals(441, esTwoKeyNavManyOneResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
@ -848,22 +849,22 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(composedKey)
.expand(NAV_PROPERTY_ET_KEY_NAV_ONE).build();
final ODataEntityRequest<ODataEntity> esTwoKeyNavManyTwoRequest =
final ODataEntityRequest<ClientEntity> esTwoKeyNavManyTwoRequest =
client.getRetrieveRequestFactory().getEntityRequest(esTwoKeyNavEntityManyTwoURI);
esTwoKeyNavManyTwoRequest.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
final ODataRetrieveResponse<ClientEntity> esTwoKeyNavManyTwoResponse = esTwoKeyNavManyTwoRequest.execute();
assertEquals(451, esTwoKeyNavManyTwoResponse.getBody().getProperty(PROPERTY_COMP_NAV).getComplexValue().get(
PROPERTY_INT16).getPrimitiveValue().toValue());
assertNotNull(esTwoKeyNavManyTwoResponse.getBody().getProperty(NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue());
assertEquals(propertyInt16.getPrimitiveValue().toValue(), esTwoKeyNavManyTwoResponse.getBody().getProperty(
NAV_PROPERTY_ET_KEY_NAV_ONE).getComplexValue().get(PROPERTY_INT16).getPrimitiveValue().toValue());
}
private String getCookie() {
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
final ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
final ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV).build())
.execute();
@ -872,15 +873,15 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
private void validateSet(final URI uri, final String cookie, final short... keys) throws EdmPrimitiveTypeException {
final EdmEnabledODataClient client = ODataClientFactory.getEdmEnabledClient(SERVICE_URI);
final ODataEntitySetRequest<ODataEntitySet> request = client.getRetrieveRequestFactory()
final ODataEntitySetRequest<ClientEntitySet> request = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri);
request.addCustomHeader(HttpHeader.COOKIE, cookie);
final ODataRetrieveResponse<ODataEntitySet> response = request.execute();
final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
assertEquals(3, response.getBody().getEntities().size());
for (final ODataEntity responseEntity : response.getBody().getEntities()) {
for (final ClientEntity responseEntity : response.getBody().getEntities()) {
short propertyInt16 = responseEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toCastValue(Short.class);
boolean found = false;

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -28,12 +28,12 @@ import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataLinkType;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientInlineEntity;
import org.apache.olingo.commons.api.domain.ClientInlineEntitySet;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.domain.ClientLinkType;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.apache.olingo.fit.tecsvc.TecSvcConst;
@ -44,24 +44,24 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
@Test
public void readSelect() {
final ODataClient client = getClient();
final ODataEntityRequest<ODataEntity> request = client.getRetrieveRequestFactory()
final ODataEntityRequest<ClientEntity> request = client.getRetrieveRequestFactory()
.getEntityRequest(client.newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESAllPrim").appendKeySegment(Short.MAX_VALUE)
.select("PropertyInt32,PropertyInt16")
.build());
assertNotNull(request);
final ODataRetrieveResponse<ODataEntity> response = request.execute();
final ODataRetrieveResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntity entity = response.getBody();
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertNotNull(entity.getProperties());
assertEquals(2, entity.getProperties().size());
assertNull(entity.getProperty("PropertyString"));
ODataProperty property = entity.getProperty("PropertyInt16");
ClientProperty property = entity.getProperty("PropertyInt16");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals(Integer.valueOf(Short.MAX_VALUE), property.getPrimitiveValue().toValue());
@ -75,7 +75,7 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
@Test
public void readExpandSelect() {
final ODataClient client = getClient();
final ODataEntityRequest<ODataEntity> request = client.getRetrieveRequestFactory()
final ODataEntityRequest<ClientEntity> request = client.getRetrieveRequestFactory()
.getEntityRequest(client.newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESTwoPrim").appendKeySegment(-365)
.expand("NavPropertyETAllPrimMany($select=PropertyTimeOfDay,PropertySByte)")
@ -83,30 +83,30 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
.build());
assertNotNull(request);
final ODataRetrieveResponse<ODataEntity> response = request.execute();
final ODataRetrieveResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntity entity = response.getBody();
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertNull(entity.getProperty("PropertyInt16"));
final ODataProperty property = entity.getProperty("PropertyString");
final ClientProperty property = entity.getProperty("PropertyString");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals("Test String2", property.getPrimitiveValue().toValue());
assertNull(entity.getNavigationLink("NavPropertyETAllPrimOne"));
final ODataLink link = entity.getNavigationLink("NavPropertyETAllPrimMany");
final ClientLink link = entity.getNavigationLink("NavPropertyETAllPrimMany");
assertNotNull(link);
assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, link.getType());
final ODataInlineEntitySet inlineEntitySet = link.asInlineEntitySet();
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, link.getType());
final ClientInlineEntitySet inlineEntitySet = link.asInlineEntitySet();
assertNotNull(inlineEntitySet);
final List<? extends ODataEntity> entities = inlineEntitySet.getEntitySet().getEntities();
final List<? extends ClientEntity> entities = inlineEntitySet.getEntitySet().getEntities();
assertNotNull(entities);
assertEquals(2, entities.size());
final ODataEntity inlineEntity = entities.get(0);
final ClientEntity inlineEntity = entities.get(0);
assertEquals(2, inlineEntity.getProperties().size());
assertEquals(-128, inlineEntity.getProperty("PropertySByte").getPrimitiveValue().toValue());
assertEquals(new java.sql.Timestamp(85754000),
@ -116,33 +116,33 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
@Test
public void readExpandTwoLevels() {
final ODataClient client = getClient();
final ODataEntityRequest<ODataEntity> request = client.getRetrieveRequestFactory()
final ODataEntityRequest<ClientEntity> request = client.getRetrieveRequestFactory()
.getEntityRequest(client.newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESTwoPrim").appendKeySegment(32767)
.expand("NavPropertyETAllPrimOne($expand=NavPropertyETTwoPrimOne)")
.build());
assertNotNull(request);
final ODataRetrieveResponse<ODataEntity> response = request.execute();
final ODataRetrieveResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntity entity = response.getBody();
final ClientEntity entity = response.getBody();
assertNotNull(entity);
assertEquals(2, entity.getProperties().size());
assertNull(entity.getNavigationLink("NavPropertyETAllPrimMany"));
final ODataLink link = entity.getNavigationLink("NavPropertyETAllPrimOne");
final ClientLink link = entity.getNavigationLink("NavPropertyETAllPrimOne");
assertNotNull(link);
assertEquals(ODataLinkType.ENTITY_NAVIGATION, link.getType());
final ODataInlineEntity inlineEntity = link.asInlineEntity();
assertEquals(ClientLinkType.ENTITY_NAVIGATION, link.getType());
final ClientInlineEntity inlineEntity = link.asInlineEntity();
assertNotNull(inlineEntity);
assertEquals(16, inlineEntity.getEntity().getProperties().size());
final ODataLink innerLink = inlineEntity.getEntity().getNavigationLink("NavPropertyETTwoPrimOne");
final ClientLink innerLink = inlineEntity.getEntity().getNavigationLink("NavPropertyETTwoPrimOne");
assertNotNull(innerLink);
assertEquals(ODataLinkType.ENTITY_NAVIGATION, innerLink.getType());
final ODataEntity innerEntity = innerLink.asInlineEntity().getEntity();
assertEquals(ClientLinkType.ENTITY_NAVIGATION, innerLink.getType());
final ClientEntity innerEntity = innerLink.asInlineEntity().getEntity();
assertNotNull(innerEntity);
assertEquals(2, innerEntity.getProperties().size());
assertEquals(32767, innerEntity.getProperty("PropertyInt16").getPrimitiveValue().toValue());

View File

@ -33,8 +33,8 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.QueryOption;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpStatusCode;
@ -58,20 +58,20 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.FILTER, "PropertyString eq '2'");
final ODataRetrieveResponse<ODataEntitySet> response =
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options);
final List<ODataEntity> entities = response.getBody().getEntities();
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(4, entities.size());
for (final ODataEntity entity : entities) {
for (final ClientEntity entity : entities) {
final Object propInt16 = entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
final Object propString = entity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue();
final ODataEntitySet inlineEntitySet =
final ClientEntitySet inlineEntitySet =
entity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
if (propInt16.equals(1) && propString.equals("1")) {
assertEquals(1, inlineEntitySet.getEntities().size());
final ODataEntity inlineEntity = inlineEntitySet.getEntities().get(0);
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
assertEquals(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("2", inlineEntity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
@ -79,7 +79,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
assertEquals(0, inlineEntitySet.getEntities().size());
} else if (propInt16.equals(2) && propString.equals("1")) {
assertEquals(1, inlineEntitySet.getEntities().size());
final ODataEntity inlineEntity = inlineEntitySet.getEntities().get(0);
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
assertEquals(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("2", inlineEntity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
@ -96,21 +96,21 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.ORDERBY, "PropertyString desc");
final ODataRetrieveResponse<ODataEntitySet> response =
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options);
final List<ODataEntity> entities = response.getBody().getEntities();
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(4, entities.size());
for (final ODataEntity entity : entities) {
for (final ClientEntity entity : entities) {
final Object propInt16 = entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
final Object propString = entity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue();
final ODataEntitySet inlineEntitySet =
final ClientEntitySet inlineEntitySet =
entity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
if (propInt16.equals(1) && propString.equals("1")) {
assertEquals(2, inlineEntitySet.getEntities().size());
final ODataEntity inlineEntity1 = inlineEntitySet.getEntities().get(0);
final ODataEntity inlineEntity2 = inlineEntitySet.getEntities().get(1);
final ClientEntity inlineEntity1 = inlineEntitySet.getEntities().get(0);
final ClientEntity inlineEntity2 = inlineEntitySet.getEntities().get(1);
assertEquals(1, inlineEntity1.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("2", inlineEntity1.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
@ -120,30 +120,30 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
}
}
}
@Test
public void testSkip() {
final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.SKIP, "1");
final ODataRetrieveResponse<ODataEntitySet> response =
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_KEY_NAV, NAV_PROPERTY_ET_KEY_NAV_MANY, options);
final List<ODataEntity> entities = response.getBody().getEntities();
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(3, entities.size());
for (final ODataEntity entity : entities) {
for (final ClientEntity entity : entities) {
final Object propInt16 = entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
final ODataEntitySet inlineEntitySet =
final ClientEntitySet inlineEntitySet =
entity.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
if (propInt16.equals(1)) {
assertEquals(1, inlineEntitySet.getEntities().size());
final ODataEntity inlineEntity = inlineEntitySet.getEntities().get(0);
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
assertEquals(2, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
} else if (propInt16.equals(2)) {
assertEquals(1, inlineEntitySet.getEntities().size());
final ODataEntity inlineEntity = inlineEntitySet.getEntities().get(0);
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
assertEquals(3, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
} else if (propInt16.equals(3)) {
@ -157,24 +157,24 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.TOP, "1");
final ODataRetrieveResponse<ODataEntitySet> response =
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_KEY_NAV, NAV_PROPERTY_ET_KEY_NAV_MANY, options);
final List<ODataEntity> entities = response.getBody().getEntities();
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(3, entities.size());
for (final ODataEntity entity : entities) {
for (final ClientEntity entity : entities) {
final Object propInt16 = entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
final ODataEntitySet inlineEntitySet =
final ClientEntitySet inlineEntitySet =
entity.getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
if (propInt16.equals(1)) {
assertEquals(1, inlineEntitySet.getEntities().size());
final ODataEntity inlineEntity = inlineEntitySet.getEntities().get(0);
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
assertEquals(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
} else if (propInt16.equals(2)) {
assertEquals(1, inlineEntitySet.getEntities().size());
final ODataEntity inlineEntity = inlineEntitySet.getEntities().get(0);
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
assertEquals(2, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
} else if (propInt16.equals(3)) {
@ -190,20 +190,20 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
options.put(QueryOption.FILTER, "PropertyInt16 eq 1");
options.put(QueryOption.SKIP, "1");
final ODataRetrieveResponse<ODataEntitySet> response =
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options);
final List<ODataEntity> entities = response.getBody().getEntities();
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(4, entities.size());
for (final ODataEntity entity : entities) {
for (final ClientEntity entity : entities) {
final Object propInt16 = entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
final Object propString = entity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue();
final ODataEntitySet inlineEntitySet =
final ClientEntitySet inlineEntitySet =
entity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
if (propInt16.equals(1) && propString.equals("1")) {
assertEquals(1, inlineEntitySet.getEntities().size());
final ODataEntity inlineEntity = inlineEntitySet.getEntities().get(0);
final ClientEntity inlineEntity = inlineEntitySet.getEntities().get(0);
assertEquals(1, inlineEntity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("2", inlineEntity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
@ -231,16 +231,16 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).expandWithOptions(
NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options).addQueryOption(QueryOption.SELECT,
"PropertyInt16,PropertyString").build();
final ODataRetrieveResponse<ODataEntitySet> response =
final ODataRetrieveResponse<ClientEntitySet> response =
client.getRetrieveRequestFactory().getEntitySetRequest(uri).execute();
final List<ODataEntity> entities = response.getBody().getEntities();
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(4, entities.size());
for (final ODataEntity entity : entities) {
for (final ClientEntity entity : entities) {
final Object propInt16 = entity.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue();
final Object propString = entity.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue();
final ODataEntitySet entitySet =
final ClientEntitySet entitySet =
entity.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
if (propInt16.equals(1) && propString.equals("1")) {
@ -269,11 +269,11 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(keys)
.expandWithOptions(NAV_PROPERTY_ET_KEY_NAV_MANY, options).build();
final ODataRetrieveResponse<ODataEntity> response =
final ODataRetrieveResponse<ClientEntity> response =
client.getRetrieveRequestFactory().getEntityRequest(uri).execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntitySet entitySet =
final ClientEntitySet entitySet =
response.getBody().getNavigationLink(NAV_PROPERTY_ET_KEY_NAV_MANY).asInlineEntitySet().getEntitySet();
assertEquals(1, entitySet.getEntities().size());
assertEquals(1, entitySet.getEntities().get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
@ -284,182 +284,182 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.FILTER, "PropertyInt16 eq 1"
+ " and PropertyComp/PropertyComp/PropertyDuration eq duration'PT1S' and length(PropertyString) gt 4");
final ODataRetrieveResponse<ODataEntitySet> response =
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options);
final List<ODataEntity> entities = response.getBody().getEntities();
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
assertEquals(4, entities.size());
}
@Test
public void testCyclicExpand() {
// Expand entity in the following order
// 1 => 2 => 1
// Entity with Key (PropertyInt16=1, PrroperyString='1') holds references to (PropertyInt16=1, PropertyString='1')
// Entity with Key (PropertyInt16=1, PrroperyString='1') holds references to (PropertyInt16=1, PropertyString='1')
// and (PropertyInt16=1, PropertyString='2')
// Entity with Key (PropertyInt16=1, PropertyString='2') holds references to (PropertyInt16=1, PropertyString='1')
// Define filters to select explicit the entities at any level => Circle
final ODataClient client = getClient();
final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "))");
options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "))");
options.put(QueryOption.FILTER, "PropertyString eq '2'");
final Map<String, Object> keys = new HashMap<String, Object>();
keys.put(PROPERTY_INT16, 1);
keys.put(PROPERTY_STRING, "1");
final URI uri = client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(keys)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options)
.build();
final ODataRetrieveResponse<ODataEntity> response = client.getRetrieveRequestFactory()
.getEntityRequest(uri)
.execute();
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(keys)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options)
.build();
final ODataRetrieveResponse<ClientEntity> response = client.getRetrieveRequestFactory()
.getEntityRequest(uri)
.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
assertNotNull(response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
assertEquals(1, response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final ODataEntity entitySecondLevel = response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.get(0);
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final ClientEntity entitySecondLevel = response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.get(0);
assertEquals(1, entitySecondLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("2", entitySecondLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
assertNotNull(entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
assertEquals(1, entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final ODataEntity entityThirdLevel = entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.get(0);
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final ClientEntity entityThirdLevel = entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.get(0);
assertEquals(1, entityThirdLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("1", entityThirdLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
assertNotNull(entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
assertEquals(2, entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final List<ODataEntity> fourthLevelEntites = entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities();
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final List<ClientEntity> fourthLevelEntites = entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities();
assertEquals(1, fourthLevelEntites.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("1", fourthLevelEntites.get(0).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
assertEquals(1, fourthLevelEntites.get(1).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("2", fourthLevelEntites.get(1).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
}
@Test
public void testSystemQueryOptionOnThirdLevel() {
final ODataClient client = getClient();
final Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ ";$filter=PropertyString eq '1'))");
options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ ";$filter=PropertyString eq '1'))");
options.put(QueryOption.FILTER, "PropertyString eq '2'");
final Map<String, Object> keys = new HashMap<String, Object>();
keys.put(PROPERTY_INT16, 1);
keys.put(PROPERTY_STRING, "1");
final URI uri = client.newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(keys)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options)
.build();
final ODataRetrieveResponse<ODataEntity> response = client.getRetrieveRequestFactory()
.getEntityRequest(uri)
.execute();
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(keys)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options)
.build();
final ODataRetrieveResponse<ClientEntity> response = client.getRetrieveRequestFactory()
.getEntityRequest(uri)
.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
assertNotNull(response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
assertEquals(1, response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final ODataEntity entitySecondLevel = response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.get(0);
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final ClientEntity entitySecondLevel = response.getBody().getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.get(0);
assertEquals(1, entitySecondLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("2", entitySecondLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
assertNotNull(entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
assertEquals(1, entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final ODataEntity entityThirdLevel = entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.get(0);
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final ClientEntity entityThirdLevel = entitySecondLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.get(0);
assertEquals(1, entityThirdLevel.getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("1", entityThirdLevel.getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
assertNotNull(entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY));
assertEquals(1, entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final List<ODataEntity> fourthLevelEntites = entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities();
.asInlineEntitySet()
.getEntitySet()
.getEntities()
.size());
final List<ClientEntity> fourthLevelEntites = entityThirdLevel.getNavigationLink(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY)
.asInlineEntitySet()
.getEntitySet()
.getEntities();
assertEquals(1, fourthLevelEntites.get(0).getProperty(PROPERTY_INT16).getPrimitiveValue().toValue());
assertEquals("1", fourthLevelEntites.get(0).getProperty(PROPERTY_STRING).getPrimitiveValue().toValue());
}
private ODataRetrieveResponse<ODataEntitySet> buildRequest(final String entitySet, final String navigationProperty,
private ODataRetrieveResponse<ClientEntitySet> buildRequest(final String entitySet, final String navigationProperty,
final Map<QueryOption, Object> expandOptions) {
return buildRequest(entitySet, navigationProperty, expandOptions, null);
}
private ODataRetrieveResponse<ODataEntitySet> buildRequest(final String entitySet, final String navigationProperty,
private ODataRetrieveResponse<ClientEntitySet> buildRequest(final String entitySet, final String navigationProperty,
final Map<QueryOption, Object> expandOptions, final String cookie) {
final ODataClient client = getClient();
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(entitySet)
.expandWithOptions(navigationProperty, expandOptions)
.build();
final ODataEntitySetRequest<ODataEntitySet> request = client.getRetrieveRequestFactory().getEntitySetRequest(uri);
final ODataEntitySetRequest<ClientEntitySet> request = client.getRetrieveRequestFactory().getEntitySetRequest(uri);
if (cookie != null) {
request.addCustomHeader(HttpHeader.COOKIE, cookie);

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -34,11 +34,11 @@ import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
import org.apache.olingo.client.api.communication.response.ODataRawResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
@ -49,41 +49,41 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
@Test
public void entity() throws Exception {
final ODataInvokeRequest<ODataEntity> request = getClient().getInvokeRequestFactory()
final ODataInvokeRequest<ClientEntity> request = getClient().getInvokeRequestFactory()
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendOperationCallSegment("FICRTESTwoKeyNav").build(), ODataEntity.class);
.appendOperationCallSegment("FICRTESTwoKeyNav").build(), ClientEntity.class);
assertNotNull(request);
final ODataInvokeResponse<ODataEntity> response = request.execute();
final ODataInvokeResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntity entity = response.getBody();
final ClientEntity entity = response.getBody();
assertNotNull(entity);
final ODataProperty property = entity.getProperty("PropertyInt16");
final ClientProperty property = entity.getProperty("PropertyInt16");
assertNotNull(property);
assertEquals(1, property.getPrimitiveValue().toValue());
}
@Test
public void entityCollection() {
final ODataInvokeRequest<ODataEntitySet> request = getClient().getInvokeRequestFactory()
final ODataInvokeRequest<ClientEntitySet> request = getClient().getInvokeRequestFactory()
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendOperationCallSegment("FICRTCollESTwoKeyNavParam").build(), ODataEntitySet.class,
Collections.<String, ODataValue> singletonMap("ParameterInt16",
.appendOperationCallSegment("FICRTCollESTwoKeyNavParam").build(), ClientEntitySet.class,
Collections.<String, ClientValue> singletonMap("ParameterInt16",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(2)));
assertNotNull(request);
final ODataInvokeResponse<ODataEntitySet> response = request.execute();
final ODataInvokeResponse<ClientEntitySet> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntitySet entitySet = response.getBody();
final ClientEntitySet entitySet = response.getBody();
assertNotNull(entitySet);
final List<ODataEntity> entities = entitySet.getEntities();
final List<ClientEntity> entities = entitySet.getEntities();
assertNotNull(entities);
assertEquals(2, entities.size());
final ODataEntity entity = entities.get(1);
final ClientEntity entity = entities.get(1);
assertNotNull(entity);
final ODataProperty property = entity.getProperty("PropertyString");
final ClientProperty property = entity.getProperty("PropertyString");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals("2", property.getPrimitiveValue().toValue());
@ -92,19 +92,19 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
@Test
public void entityCollectionWithAppendedKey() {
// .../odata.svc/FICRTCollESMedia()(1)
final ODataInvokeRequest<ODataEntity> request = getClient().getInvokeRequestFactory()
final ODataInvokeRequest<ClientEntity> request = getClient().getInvokeRequestFactory()
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendOperationCallSegment("FICRTCollESMedia")
.appendKeySegment(getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(1))
.build(), ODataEntity.class);
.build(), ClientEntity.class);
assertNotNull(request);
final ODataInvokeResponse<ODataEntity> response = request.execute();
final ODataInvokeResponse<ClientEntity> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntity entity = response.getBody();
final ClientEntity entity = response.getBody();
assertNotNull(entity);
final ODataProperty property = entity.getProperty("PropertyInt16");
final ClientProperty property = entity.getProperty("PropertyInt16");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals(1, property.getPrimitiveValue().toValue());
@ -113,18 +113,18 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
@Test
public void entityCollectionWithAppendedKeyAndProperty() {
// .../odata.svc/FICRTCollESMedia()(2)/PropertyInt16
final ODataInvokeRequest<ODataProperty> request = getClient().getInvokeRequestFactory()
final ODataInvokeRequest<ClientProperty> request = getClient().getInvokeRequestFactory()
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendOperationCallSegment("FICRTCollESMedia")
.appendKeySegment(getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(2))
.appendPropertySegment("PropertyInt16")
.build(), ODataProperty.class);
.build(), ClientProperty.class);
assertNotNull(request);
final ODataInvokeResponse<ODataProperty> response = request.execute();
final ODataInvokeResponse<ClientProperty> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataProperty property = response.getBody();
final ClientProperty property = response.getBody();
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals(2, property.getPrimitiveValue().toValue());
@ -141,35 +141,35 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
@Test
public void complexWithPath() throws Exception {
final ODataInvokeRequest<ODataProperty> request = getClient().getInvokeRequestFactory()
final ODataInvokeRequest<ClientProperty> request = getClient().getInvokeRequestFactory()
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendOperationCallSegment("FICRTCTTwoPrim").appendPropertySegment("PropertyInt16").build(),
ODataProperty.class);
ClientProperty.class);
assertNotNull(request);
final ODataInvokeResponse<ODataProperty> response = request.execute();
final ODataInvokeResponse<ClientProperty> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataProperty property = response.getBody();
final ClientProperty property = response.getBody();
assertNotNull(property);
assertEquals(16, property.getPrimitiveValue().toValue());
}
@Test
public void primitiveCollection() throws Exception {
final ODataInvokeRequest<ODataProperty> request = getClient().getInvokeRequestFactory()
final ODataInvokeRequest<ClientProperty> request = getClient().getInvokeRequestFactory()
.getFunctionInvokeRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendOperationCallSegment("FICRTCollString").build(), ODataProperty.class);
.appendOperationCallSegment("FICRTCollString").build(), ClientProperty.class);
assertNotNull(request);
final ODataInvokeResponse<ODataProperty> response = request.execute();
final ODataInvokeResponse<ClientProperty> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataProperty property = response.getBody();
final ClientProperty property = response.getBody();
assertNotNull(property);
assertNotNull(property.getCollectionValue());
assertEquals(3, property.getCollectionValue().size());
Iterator<ODataValue> iterator = property.getCollectionValue().iterator();
Iterator<ClientValue> iterator = property.getCollectionValue().iterator();
assertEquals("Employee1@company.example", iterator.next().asPrimitive().toValue());
assertEquals("Employee2@company.example", iterator.next().asPrimitive().toValue());
assertEquals("Employee3@company.example", iterator.next().asPrimitive().toValue());
@ -180,7 +180,7 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
final ODataValueRequest request = getClient().getRetrieveRequestFactory()
.getPropertyValueRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendOperationCallSegment("FICRTString").appendValueSegment().build());
final ODataRetrieveResponse<ODataPrimitiveValue> response = request.execute();
final ODataRetrieveResponse<ClientPrimitiveValue> response = request.execute();
assertEquals("UFCRTString string value", response.getBody().toValue());
}
@ -190,7 +190,7 @@ public class FunctionImportITCase extends AbstractBaseTestITCase {
.getPropertyValueRequest(getClient().newURIBuilder(TecSvcConst.BASE_URI)
.appendOperationCallSegment("FICRTCTTwoPrim")
.appendPropertySegment("PropertyString").appendValueSegment().build());
final ODataRetrieveResponse<ODataPrimitiveValue> response = request.execute();
final ODataRetrieveResponse<ClientPrimitiveValue> response = request.execute();
assertEquals("UFCRTCTTwoPrim string value", response.getBody().toValue());
}

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -39,8 +39,8 @@ import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreat
import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpHeader;
@ -96,13 +96,13 @@ public final class MediaITCase extends AbstractBaseTestITCase {
final ODataClient client = getClient();
final URI uri = client.newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESMedia").appendKeySegment(4).appendValueSegment().build();
ODataMediaEntityUpdateRequest<ODataEntity> request =
ODataMediaEntityUpdateRequest<ClientEntity> request =
client.getCUDRequestFactory().getMediaEntityUpdateRequest(uri,
IOUtils.toInputStream("just a test"));
request.setContentType(ContentType.TEXT_PLAIN.toContentTypeString());
assertNotNull(request);
final ODataMediaEntityUpdateResponse<ODataEntity> response = request.payloadManager().getResponse();
final ODataMediaEntityUpdateResponse<ClientEntity> response = request.payloadManager().getResponse();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
// Check that the media stream has changed.
@ -118,19 +118,19 @@ public final class MediaITCase extends AbstractBaseTestITCase {
@Test
public void create() throws Exception {
final ODataClient client = getClient();
ODataMediaEntityCreateRequest<ODataEntity> request =
ODataMediaEntityCreateRequest<ClientEntity> request =
client.getCUDRequestFactory().getMediaEntityCreateRequest(
client.newURIBuilder(TecSvcConst.BASE_URI).appendEntitySetSegment("ESMedia").build(),
IOUtils.toInputStream("just a test"));
request.setContentType(ContentType.TEXT_PLAIN.toContentTypeString());
assertNotNull(request);
final ODataMediaEntityCreateResponse<ODataEntity> response = request.payloadManager().getResponse();
final ODataMediaEntityCreateResponse<ClientEntity> response = request.payloadManager().getResponse();
assertEquals(HttpStatusCode.CREATED.getStatusCode(), response.getStatusCode());
assertEquals(request.getURI() + "(5)", response.getHeader(HttpHeader.LOCATION).iterator().next());
final ODataEntity entity = response.getBody();
final ClientEntity entity = response.getBody();
assertNotNull(entity);
final ODataProperty property = entity.getProperty("PropertyInt16");
final ClientProperty property = entity.getProperty("PropertyInt16");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals(5, property.getPrimitiveValue().toValue());

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -24,9 +24,9 @@ import static org.junit.Assert.assertNotNull;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
@ -39,7 +39,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
@Test
public void oneLevelToEntity() throws Exception {
final ODataRetrieveResponse<ODataEntity> response =
final ODataRetrieveResponse<ClientEntity> response =
client.getRetrieveRequestFactory().getEntityRequest(
client.newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESAllPrim").appendKeySegment(32767)
@ -47,9 +47,9 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntity entity = response.getBody();
final ClientEntity entity = response.getBody();
assertNotNull(entity);
final ODataProperty property = entity.getProperty("PropertyString");
final ClientProperty property = entity.getProperty("PropertyString");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals("Test String4", property.getPrimitiveValue().toValue());
@ -57,7 +57,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
@Test
public void oneLevelToEntityWithKey() throws Exception {
final ODataRetrieveResponse<ODataEntity> response =
final ODataRetrieveResponse<ClientEntity> response =
client.getRetrieveRequestFactory().getEntityRequest(
client.newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESAllPrim").appendKeySegment(32767)
@ -65,9 +65,9 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntity entity = response.getBody();
final ClientEntity entity = response.getBody();
assertNotNull(entity);
final ODataProperty property = entity.getProperty("PropertyString");
final ClientProperty property = entity.getProperty("PropertyString");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals("Test String2", property.getPrimitiveValue().toValue());
@ -75,7 +75,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
@Test
public void twoLevelsToEntityWithKey() throws Exception {
final ODataRetrieveResponse<ODataEntity> response =
final ODataRetrieveResponse<ClientEntity> response =
client.getRetrieveRequestFactory().getEntityRequest(
client.newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESTwoPrim").appendKeySegment(32767)
@ -84,9 +84,9 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntity entity = response.getBody();
final ClientEntity entity = response.getBody();
assertNotNull(entity);
final ODataProperty property = entity.getProperty("PropertyString");
final ClientProperty property = entity.getProperty("PropertyString");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals("Test String2", property.getPrimitiveValue().toValue());
@ -94,7 +94,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
@Test
public void twoLevelsToEntitySet() throws Exception {
final ODataRetrieveResponse<ODataEntitySet> response =
final ODataRetrieveResponse<ClientEntitySet> response =
client.getRetrieveRequestFactory().getEntitySetRequest(
client.newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESTwoPrim").appendKeySegment(32767)
@ -103,12 +103,12 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataEntitySet entitySet = response.getBody();
final ClientEntitySet entitySet = response.getBody();
assertNotNull(entitySet);
assertEquals(1, entitySet.getEntities().size());
final ODataEntity entity = entitySet.getEntities().get(0);
final ClientEntity entity = entitySet.getEntities().get(0);
assertNotNull(entity);
final ODataProperty property = entity.getProperty("PropertyString");
final ClientProperty property = entity.getProperty("PropertyString");
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals("Test String2", property.getPrimitiveValue().toValue());
@ -116,7 +116,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
@Test
public void twoLevelsToProperty() throws Exception {
final ODataRetrieveResponse<ODataProperty> response =
final ODataRetrieveResponse<ClientProperty> response =
client.getRetrieveRequestFactory().getPropertyRequest(
client.newURIBuilder(TecSvcConst.BASE_URI)
.appendEntitySetSegment("ESKeyNav").appendKeySegment(1)
@ -126,7 +126,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
final ODataProperty property = response.getBody();
final ClientProperty property = response.getBody();
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals(1, property.getPrimitiveValue().toValue());

View File

@ -27,9 +27,9 @@ import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataValuable;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientValuable;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
@ -47,97 +47,98 @@ public class OrderBySystemQueryITCase extends AbstractBaseTestITCase {
@AfterClass
public static void tearDownAfterClass() throws Exception {
//no teardown needed
// no teardown needed
}
@Test
public void testSimpleOrderBy() {
ODataRetrieveResponse<ODataEntitySet> response = null;
ODataRetrieveResponse<ClientEntitySet> response = null;
response = sendRequest(ES_ALL_PRIM, "PropertyDate");
assertEquals(3, response.getBody().getEntities().size());
ODataEntity oDataEntity = response.getBody().getEntities().get(0);
assertEquals("0", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
ClientEntity clientEntity = response.getBody().getEntities().get(0);
assertEquals("0", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(1);
assertEquals("32767", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(1);
assertEquals("32767", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(2);
assertEquals("-32768", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(2);
assertEquals("-32768", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
}
@Test
public void testSimpleOrderByDecending() {
ODataRetrieveResponse<ODataEntitySet> response = null;
ODataRetrieveResponse<ClientEntitySet> response = null;
response = sendRequest(ES_ALL_PRIM, "PropertyDate desc");
assertEquals(3, response.getBody().getEntities().size());
ODataEntity oDataEntity = response.getBody().getEntities().get(0);
assertEquals("-32768", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
ClientEntity clientEntity = response.getBody().getEntities().get(0);
assertEquals("-32768", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(1);
assertEquals("32767", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(1);
assertEquals("32767", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(2);
assertEquals("0", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(2);
assertEquals("0", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
}
@Test
public void testMultipleOrderBy() {
final ODataRetrieveResponse<ODataEntitySet> response = sendRequest(ES_ALL_PRIM, "PropertyByte, PropertyInt16");
final ODataRetrieveResponse<ClientEntitySet> response = sendRequest(ES_ALL_PRIM, "PropertyByte, PropertyInt16");
assertEquals(3, response.getBody().getEntities().size());
ODataEntity oDataEntity = response.getBody().getEntities().get(0);
assertEquals("-32768", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
ClientEntity clientEntity = response.getBody().getEntities().get(0);
assertEquals("-32768", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(1);
assertEquals("0", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(1);
assertEquals("0", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(2);
assertEquals("32767", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(2);
assertEquals("32767", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
}
@Test
public void testMultipleOrderByDecending() {
final ODataRetrieveResponse<ODataEntitySet> response = sendRequest(ES_ALL_PRIM, "PropertyByte, PropertyInt16 desc");
final ODataRetrieveResponse<ClientEntitySet> response =
sendRequest(ES_ALL_PRIM, "PropertyByte, PropertyInt16 desc");
assertEquals(3, response.getBody().getEntities().size());
ODataEntity oDataEntity = response.getBody().getEntities().get(0);
assertEquals("0", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
ClientEntity clientEntity = response.getBody().getEntities().get(0);
assertEquals("0", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(1);
assertEquals("-32768", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(1);
assertEquals("-32768", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(2);
assertEquals("32767", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(2);
assertEquals("32767", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
}
@Test
public void testOrderByWithNull() {
final ODataRetrieveResponse<ODataEntitySet> response = sendRequest(ES_TWO_PRIM, "PropertyString");
final ODataRetrieveResponse<ClientEntitySet> response = sendRequest(ES_TWO_PRIM, "PropertyString");
assertEquals(4, response.getBody().getEntities().size());
ODataEntity oDataEntity = response.getBody().getEntities().get(0);
assertEquals("-32766", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
ClientEntity clientEntity = response.getBody().getEntities().get(0);
assertEquals("-32766", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(1);
assertEquals("32766", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(1);
assertEquals("32766", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(2);
assertEquals("-365", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(2);
assertEquals("-365", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
oDataEntity = response.getBody().getEntities().get(3);
assertEquals("32767", ((ODataValuable) oDataEntity.getProperty("PropertyInt16")).getValue().toString());
clientEntity = response.getBody().getEntities().get(3);
assertEquals("32767", ((ClientValuable) clientEntity.getProperty("PropertyInt16")).getValue().toString());
}
@Test
public void testOrderByInvalidExpression() {
fail(ES_TWO_PRIM, "PropertyString add 10", HttpStatusCode.BAD_REQUEST);
fail(ES_TWO_PRIM, "PropertyString add 10", HttpStatusCode.BAD_REQUEST);
}
private ODataRetrieveResponse<ODataEntitySet> sendRequest(String entitySet, String orderByString) {
private ODataRetrieveResponse<ClientEntitySet> sendRequest(String entitySet, String orderByString) {
final ODataClient client = getClient();
final URI uri =
@ -146,7 +147,7 @@ public class OrderBySystemQueryITCase extends AbstractBaseTestITCase {
.orderBy(orderByString)
.build();
ODataEntitySetRequest<ODataEntitySet> request = client.getRetrieveRequestFactory().getEntitySetRequest(uri);
ODataEntitySetRequest<ClientEntitySet> request = client.getRetrieveRequestFactory().getEntitySetRequest(uri);
return request.execute();
}
@ -159,7 +160,7 @@ public class OrderBySystemQueryITCase extends AbstractBaseTestITCase {
assertEquals(errorCode.getStatusCode(), e.getStatusLine().getStatusCode());
}
}
@Override
protected ODataClient getClient() {
ODataClient odata = ODataClientFactory.getClient();

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -36,8 +36,8 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataValueReq
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpHeader;
@ -52,20 +52,20 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
@Test
public void readSimpleProperty() throws Exception {
ODataPropertyRequest<ODataProperty> request = getClient().getRetrieveRequestFactory()
ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
.getPropertyRequest(getClient().newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESTwoPrim")
.appendKeySegment(32766)
.appendPropertySegment("PropertyString")
.build());
assertNotNull(request);
ODataRetrieveResponse<ODataProperty> response = request.execute();
ODataRetrieveResponse<ClientProperty> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
assertThat(response.getContentType(), containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
final ODataProperty property = response.getBody();
final ClientProperty property = response.getBody();
assertNotNull(property);
assertNotNull(property.getPrimitiveValue());
assertEquals("Test String1", property.getPrimitiveValue().toValue());
@ -73,18 +73,18 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
@Test
public void readSimplePropertyContextURL() throws Exception {
ODataPropertyRequest<ODataProperty> request = getClient().getRetrieveRequestFactory()
ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
.getPropertyRequest(getClient().newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESTwoPrim")
.appendKeySegment(32766)
.appendPropertySegment("PropertyString")
.build());
ODataRetrieveResponse<ODataProperty> response = request.execute();
String expectedResult =
ODataRetrieveResponse<ClientProperty> response = request.execute();
String expectedResult =
"{\"@odata.context\":\"$metadata#ESTwoPrim(32766)/PropertyString\"," +
"\"value\":\"Test String1\"}";
assertEquals(expectedResult, IOUtils.toString(response.getRawResponse(), "UTF-8"));
}
"\"value\":\"Test String1\"}";
assertEquals(expectedResult, IOUtils.toString(response.getRawResponse(), "UTF-8"));
}
@Test
public void deletePrimitive() throws Exception {
@ -97,7 +97,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
// Check that the property is really gone.
// This check has to be in the same session in order to access the same data provider.
ODataPropertyRequest<ODataProperty> propertyRequest = getClient().getRetrieveRequestFactory()
ODataPropertyRequest<ClientProperty> propertyRequest = getClient().getRetrieveRequestFactory()
.getPropertyRequest(uri);
propertyRequest.addCustomHeader(HttpHeader.COOKIE, response.getHeader(HttpHeader.SET_COOKIE).iterator().next());
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), propertyRequest.execute().getStatusCode());
@ -122,12 +122,12 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
// Check that the property is not gone but empty now.
// This check has to be in the same session in order to access the same data provider.
ODataPropertyRequest<ODataProperty> request = getClient().getRetrieveRequestFactory()
ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
.getPropertyRequest(uri);
request.addCustomHeader(HttpHeader.COOKIE, response.getHeader(HttpHeader.SET_COOKIE).iterator().next());
final ODataRetrieveResponse<ODataProperty> propertyResponse = request.execute();
final ODataRetrieveResponse<ClientProperty> propertyResponse = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), propertyResponse.getStatusCode());
final ODataProperty property = propertyResponse.getBody();
final ClientProperty property = propertyResponse.getBody();
assertNotNull(property);
assertNotNull(property.getCollectionValue());
assertTrue(property.getCollectionValue().isEmpty());
@ -135,36 +135,36 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
@Test
public void readComplexProperty() throws Exception {
ODataPropertyRequest<ODataProperty> request = getClient().getRetrieveRequestFactory()
ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
.getPropertyRequest(getClient().newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESMixPrimCollComp")
.appendKeySegment(7)
.appendPropertySegment("PropertyComp")
.build());
ODataRetrieveResponse<ODataProperty> response = request.execute();
.build());
ODataRetrieveResponse<ClientProperty> response = request.execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
assertThat(response.getContentType(), containsString(ContentType.APPLICATION_JSON.toContentTypeString()));
final ODataProperty property = response.getBody();
final ClientProperty property = response.getBody();
assertNotNull(property);
assertNotNull(property.getComplexValue());
assertEquals("TEST B", property.getComplexValue().get("PropertyString").getPrimitiveValue().toValue());
}
assertEquals("TEST B", property.getComplexValue().get("PropertyString").getPrimitiveValue().toValue());
}
@Test
public void readComplexPropertyContextURL() throws Exception {
ODataPropertyRequest<ODataProperty> request = getClient().getRetrieveRequestFactory()
ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
.getPropertyRequest(getClient().newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESMixPrimCollComp")
.appendKeySegment(7)
.appendPropertySegment("PropertyComp")
.build());
ODataRetrieveResponse<ODataProperty> response = request.execute();
String expectedResult =
.build());
ODataRetrieveResponse<ClientProperty> response = request.execute();
String expectedResult =
"{\"@odata.context\":\"$metadata#ESMixPrimCollComp(7)/PropertyComp\"," +
"\"PropertyInt16\":222,\"PropertyString\":\"TEST B\"}";
assertEquals(expectedResult, IOUtils.toString(response.getRawResponse(), "UTF-8"));
}
"\"PropertyInt16\":222,\"PropertyString\":\"TEST B\"}";
assertEquals(expectedResult, IOUtils.toString(response.getRawResponse(), "UTF-8"));
}
@Test
public void deleteComplex() throws Exception {
@ -177,7 +177,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
// Check that the property is really gone.
// This check has to be in the same session in order to access the same data provider.
ODataPropertyRequest<ODataProperty> propertyRequest = getClient().getRetrieveRequestFactory()
ODataPropertyRequest<ClientProperty> propertyRequest = getClient().getRetrieveRequestFactory()
.getPropertyRequest(uri);
propertyRequest.addCustomHeader(HttpHeader.COOKIE, response.getHeader(HttpHeader.SET_COOKIE).iterator().next());
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), propertyRequest.execute().getStatusCode());
@ -185,15 +185,15 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
@Test
public void readUnknownProperty() throws Exception {
ODataPropertyRequest<ODataProperty> request = getClient().getRetrieveRequestFactory()
ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
.getPropertyRequest(getClient().newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESTwoPrim")
.appendKeySegment(32766)
.appendPropertySegment("Unknown")
.build());
try {
request.execute();
fail("Expected exception not thrown!");
request.execute();
fail("Expected exception not thrown!");
} catch (final ODataClientErrorException e) {
assertEquals(HttpStatusCode.NOT_FOUND.getStatusCode(), e.getStatusLine().getStatusCode());
}
@ -201,15 +201,15 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
@Test
public void readNoContentProperty() throws Exception {
ODataPropertyRequest<ODataProperty> request = getClient().getRetrieveRequestFactory()
ODataPropertyRequest<ClientProperty> request = getClient().getRetrieveRequestFactory()
.getPropertyRequest(getClient().newURIBuilder(SERVICE_URI)
.appendEntitySetSegment("ESTwoPrim")
.appendKeySegment(-32766)
.appendPropertySegment("PropertyString")
.build());
ODataRetrieveResponse<ODataProperty> response = request.execute();
.build());
ODataRetrieveResponse<ClientProperty> response = request.execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
}
}
@Test
public void readPropertyValue() throws Exception {
@ -220,9 +220,9 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
.appendPropertySegment("PropertyString")
.appendValueSegment()
.build());
ODataRetrieveResponse<ODataPrimitiveValue> response = request.execute();
ODataRetrieveResponse<ClientPrimitiveValue> response = request.execute();
assertEquals("Test String1", response.getBody().toValue());
}
}
@Override
protected ODataClient getClient() {

View File

@ -28,8 +28,8 @@ import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.QueryOption;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpStatusCode;
import org.apache.olingo.fit.AbstractBaseTestITCase;
@ -50,7 +50,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.addQueryOption(QueryOption.COUNT, "true")
.build();
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
@ -66,7 +66,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.addQueryOption(QueryOption.COUNT, "true")
.build();
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
@ -82,14 +82,14 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.addQueryOption(QueryOption.TOP, new Integer(5).toString())
.build();
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
assertEquals(5, response.getBody().getEntities().size());
for (int i = 0; i < 5; i++) {
ODataEntity entity = response.getBody().getEntities().get(i);
ClientEntity entity = response.getBody().getEntities().get(i);
assertEquals(new Integer(i + 1).toString(), entity.getProperty(PROPERTY_INT16).getValue().toString());
}
}
@ -102,14 +102,14 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.addQueryOption(QueryOption.SKIP, new Integer(5).toString())
.build();
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
assertEquals(10, response.getBody().getEntities().size());
for (int i = 0; i < 10; i++) {
ODataEntity entity = response.getBody().getEntities().get(i);
ClientEntity entity = response.getBody().getEntities().get(i);
assertEquals(new Integer(i + 6).toString(), entity.getProperty(PROPERTY_INT16).getValue().toString());
}
}
@ -123,7 +123,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.addQueryOption(QueryOption.SKIP, new Integer(503).toString())
.build();
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
@ -138,7 +138,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.addQueryOption(QueryOption.SKIP, new Integer(10000).toString())
.build();
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
@ -157,7 +157,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.addQueryOption(QueryOption.TOP, new Integer(43).toString()) // 102, 101, ...., 59
.build();
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
@ -168,7 +168,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
// Check first 10 entities
for (int i = 0; i < 10; i++) {
ODataEntity entity = response.getBody().getEntities().get(i);
ClientEntity entity = response.getBody().getEntities().get(i);
assertEquals(new Integer(id).toString(), entity.getProperty(PROPERTY_INT16).getValue().toString());
id--;
}
@ -179,7 +179,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
assertEquals(Integer.valueOf(105), response.getBody().getCount());
assertEquals(10, response.getBody().getEntities().size());
for (int i = 0; i < 10; i++) {
ODataEntity entity = response.getBody().getEntities().get(i);
ClientEntity entity = response.getBody().getEntities().get(i);
assertEquals(new Integer(id).toString(), entity.getProperty(PROPERTY_INT16).getValue().toString());
id--;
}
@ -190,7 +190,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
assertEquals(Integer.valueOf(105), response.getBody().getCount());
assertEquals(3, response.getBody().getEntities().size());
for (int i = 0; i < 3; i++) {
ODataEntity entity = response.getBody().getEntities().get(i);
ClientEntity entity = response.getBody().getEntities().get(i);
assertEquals(new Integer(id).toString(), entity.getProperty(PROPERTY_INT16).getValue().toString());
id--;
}
@ -206,7 +206,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.appendEntitySetSegment(ES_SERVER_SIDE_PAGING)
.build();
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
@ -233,7 +233,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.addQueryOption(QueryOption.COUNT, Boolean.TRUE.toString())
.build();
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
@ -241,7 +241,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
URI nextLink = response.getBody().getNext();
assertEquals("http://localhost:9080/odata-server-tecsvc/odata.svc/ESServerSidePaging?%24count=true&%24skiptoken=1",
nextLink.toASCIIString());
int token = 1;
while (nextLink != null) {
token++;
@ -252,13 +252,14 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.execute();
nextLink = response.getBody().getNext();
if(nextLink != null) {
assertEquals(
"http://localhost:9080/odata-server-tecsvc/odata.svc/ESServerSidePaging?%24count=true&%24skiptoken=" + token,
nextLink.toASCIIString());
if (nextLink != null) {
assertEquals(
"http://localhost:9080/odata-server-tecsvc/odata.svc/ESServerSidePaging?%24count=true&%24skiptoken="
+ token,
nextLink.toASCIIString());
}
}
assertEquals(50 + 1, token);
}
@ -272,7 +273,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.build();
try {
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
fail();
@ -290,7 +291,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
.addQueryOption(QueryOption.TOP, new Integer(-5).toString())
.build();
try {
ODataRetrieveResponse<ODataEntitySet> response = client.getRetrieveRequestFactory()
ODataRetrieveResponse<ClientEntitySet> response = client.getRetrieveRequestFactory()
.getEntitySetRequest(uri)
.execute();
fail();

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -26,15 +26,15 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientCollectionValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.core.domain.ODataEntityImpl;
import org.apache.olingo.commons.core.domain.ClientEntityImpl;
import org.apache.olingo.fit.AbstractBaseTestITCase;
import org.junit.BeforeClass;
@ -98,12 +98,12 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
return client;
}
protected ODataEntity read(final ODataFormat format, final URI editLink) {
final ODataEntityRequest<ODataEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(editLink);
protected ClientEntity read(final ODataFormat format, final URI editLink) {
final ODataEntityRequest<ClientEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(editLink);
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
@ -115,57 +115,57 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
}
protected void createAndDeleteOrder(final String serviceRoot, final ODataFormat format, final int id) {
final ODataEntity order = new ODataEntityImpl(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
final ClientEntity order = new ClientEntityImpl(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
final ODataProperty orderId = getClient().getObjectFactory().newPrimitiveProperty("OrderID",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id));
final ClientProperty orderId = getClient().getObjectFactory().newPrimitiveProperty("OrderID",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id));
order.getProperties().add(orderId);
Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
dateTime.set(2011, 2, 4, 16, 3, 57);
final ODataProperty orderDate = getClient().getObjectFactory().newPrimitiveProperty("OrderDate",
getClient().getObjectFactory().newPrimitiveValueBuilder()
final ClientProperty orderDate = getClient().getObjectFactory().newPrimitiveProperty("OrderDate",
getClient().getObjectFactory().newPrimitiveValueBuilder()
.setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build());
order.getProperties().add(orderDate);
final ODataProperty shelfLife = getClient().getObjectFactory().newPrimitiveProperty("ShelfLife",
getClient().getObjectFactory().newPrimitiveValueBuilder().
final ClientProperty shelfLife = getClient().getObjectFactory().newPrimitiveProperty("ShelfLife",
getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Duration).setValue(BigDecimal.TEN.scaleByPowerOfTen(7)).build());
order.getProperties().add(shelfLife);
final ODataCollectionValue<ODataValue> orderShelfLifesValue = getClient().getObjectFactory().
newCollectionValue("Collection(Duration)");
final ClientCollectionValue<ClientValue> orderShelfLifesValue = getClient().getObjectFactory().
newCollectionValue("Collection(Duration)");
orderShelfLifesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000001")).build());
setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000001")).build());
orderShelfLifesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build());
final ODataProperty orderShelfLifes = getClient().getObjectFactory().
newCollectionProperty("OrderShelfLifes", orderShelfLifesValue);
setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build());
final ClientProperty orderShelfLifes = getClient().getObjectFactory().
newCollectionProperty("OrderShelfLifes", orderShelfLifesValue);
order.getProperties().add(orderShelfLifes);
final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
getClient().newURIBuilder(serviceRoot).
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
getClient().newURIBuilder(serviceRoot).
appendEntitySetSegment("Orders").build(), order);
req.setFormat(format);
final ODataEntity created = req.execute().getBody();
final ClientEntity created = req.execute().getBody();
assertNotNull(created);
assertEquals(2, created.getProperty("OrderShelfLifes").getCollectionValue().size());
if(format == ODataFormat.JSON_NO_METADATA) {
if (format == ODataFormat.JSON_NO_METADATA) {
assertEquals(0, created.getNavigationLinks().size());
assertNull(created.getEditLink());
} else if(format == ODataFormat.JSON_FULL_METADATA) {
} else if (format == ODataFormat.JSON_FULL_METADATA) {
assertEquals(3, created.getNavigationLinks().size());
assertThat(created.getTypeName().getNamespace(), is("Microsoft.Test.OData.Services.ODataWCFService"));
assertThat(created.getEditLink().toASCIIString(), startsWith("http://localhost:9080/stub/StaticService"));
} else if(format == ODataFormat.JSON || format == ODataFormat.APPLICATION_JSON) {
} else if (format == ODataFormat.JSON || format == ODataFormat.APPLICATION_JSON) {
assertEquals(0, created.getNavigationLinks().size());
assertNull(created.getEditLink());
}
final URI deleteURI = getClient().newURIBuilder(serviceRoot).
appendEntitySetSegment("Orders").appendKeySegment(id).build();
appendEntitySetSegment("Orders").appendKeySegment(id).build();
final ODataDeleteRequest deleteReq = getClient().getCUDRequestFactory().getDeleteRequest(deleteURI);
final ODataDeleteResponse deleteRes = deleteReq.execute();
assertEquals(204, deleteRes.getStatusCode());

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -24,11 +24,11 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
import org.apache.olingo.client.api.communication.response.AsyncResponseWrapper;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientInlineEntity;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -48,7 +48,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
public void clientAsync() throws InterruptedException, ExecutionException {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers");
final Future<ODataRetrieveResponse<ODataEntitySet>> futureRes =
final Future<ODataRetrieveResponse<ClientEntitySet>> futureRes =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).asyncExecute();
assertNotNull(futureRes);
@ -56,7 +56,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
Thread.sleep(1000L);
}
final ODataRetrieveResponse<ODataEntitySet> res = futureRes.get();
final ODataRetrieveResponse<ClientEntitySet> res = futureRes.get();
assertNotNull(res);
assertEquals(200, res.getStatusCode());
assertFalse(res.getBody().getEntities().isEmpty());
@ -66,18 +66,19 @@ public class AsyncTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final AsyncRequestWrapper<ODataRetrieveResponse<ODataEntity>> async =
client.getAsyncRequestFactory().<ODataRetrieveResponse<ODataEntity>> getAsyncRequestWrapper(req);
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntity>> async =
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntity>> getAsyncRequestWrapper(req);
final AsyncResponseWrapper<ODataRetrieveResponse<ODataEntity>> responseWrapper = async.execute();
final AsyncResponseWrapper<ODataRetrieveResponse<ClientEntity>> responseWrapper = async.execute();
assertFalse(responseWrapper.isPreferenceApplied());
final ODataRetrieveResponse<ODataEntity> res = responseWrapper.getODataResponse();
final ODataEntity entity = res.getBody();
final ODataRetrieveResponse<ClientEntity> res = responseWrapper.getODataResponse();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
@ -92,12 +93,12 @@ public class AsyncTestITCase extends AbstractTestITCase {
boolean found = false;
for (ODataLink link : entity.getNavigationLinks()) {
if (link instanceof ODataInlineEntity) {
final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
for (ClientLink link : entity.getNavigationLinks()) {
if (link instanceof ClientInlineEntity) {
final ClientEntity inline = ((ClientInlineEntity) link).getEntity();
assertNotNull(inline);
final List<? extends ODataProperty> properties = inline.getProperties();
final List<? extends ClientProperty> properties = inline.getProperties();
assertEquals(5, properties.size());
assertTrue(properties.get(0).getName().equals("CompanyID")
@ -133,21 +134,21 @@ public class AsyncTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("async").appendEntitySetSegment("Orders");
final ODataEntitySetRequest<ODataEntitySet> req =
final ODataEntitySetRequest<ClientEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
req.setFormat(format);
final AsyncRequestWrapper<ODataRetrieveResponse<ODataEntitySet>> async =
client.getAsyncRequestFactory().<ODataRetrieveResponse<ODataEntitySet>> getAsyncRequestWrapper(req);
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntitySet>> async =
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntitySet>> getAsyncRequestWrapper(req);
async.callback(URI.create("http://client.service.it/callback/endpoint"));
final AsyncResponseWrapper<ODataRetrieveResponse<ODataEntitySet>> responseWrapper = async.execute();
final AsyncResponseWrapper<ODataRetrieveResponse<ClientEntitySet>> responseWrapper = async.execute();
assertTrue(responseWrapper.isPreferenceApplied());
assertTrue(responseWrapper.isDone());
final ODataRetrieveResponse<ODataEntitySet> res = responseWrapper.getODataResponse();
final ODataEntitySet entitySet = res.getBody();
final ODataRetrieveResponse<ClientEntitySet> res = responseWrapper.getODataResponse();
final ClientEntitySet entitySet = res.getBody();
assertFalse(entitySet.getEntities().isEmpty());
}

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -31,7 +31,7 @@ import org.apache.olingo.client.api.http.HttpClientException;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ContentType;
@ -83,7 +83,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
targetURI.appendEntitySetSegment("Customers").appendKeySegment(1);
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
queryReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(queryReq);
@ -98,7 +98,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
targetURI = client.newURIBuilder(baseURL).appendEntitySetSegment("Customers").appendKeySegment(1);
final URI editLink = targetURI.build();
final ODataEntity patch = client.getObjectFactory().newEntity(
final ClientEntity patch = client.getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
patch.setEditLink(editLink);
@ -106,7 +106,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
"LastName",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("new last name")));
final ODataEntityUpdateRequest<ODataEntity> changeReq =
final ODataEntityUpdateRequest<ClientEntity> changeReq =
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -46,8 +46,8 @@ import org.apache.olingo.client.core.communication.request.batch.ODataSingleResp
import org.apache.olingo.client.core.communication.request.retrieve.ODataEntityRequestImpl;
import org.apache.olingo.client.core.communication.request.retrieve.ODataEntityRequestImpl.ODataEntityResponseImpl;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
@ -122,7 +122,7 @@ public class BatchTestITCase extends AbstractTestITCase {
final ODataChangeset changeset = payload.addChangeset();
URIBuilder targetURI;
ODataEntityCreateRequest<ODataEntity> createReq;
ODataEntityCreateRequest<ClientEntity> createReq;
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
for (int i = 1; i <= 2; i++) {
@ -158,7 +158,7 @@ public class BatchTestITCase extends AbstractTestITCase {
assertEquals(404, res.getStatusCode());
assertEquals("Not Found", res.getStatusMessage());
assertEquals(Integer.valueOf(3), Integer.valueOf(
res.getHeader(ODataBatchConstants.CHANGESET_CONTENT_ID_NAME).iterator().next()));
res.getHeader(ODataBatchConstants.CHANGESET_CONTENT_ID_NAME).iterator().next()));
assertFalse(retitem.hasNext());
assertFalse(iter.hasNext());
@ -192,7 +192,7 @@ public class BatchTestITCase extends AbstractTestITCase {
targetURI.appendEntitySetSegment("UnexistingEntitySet").appendKeySegment(1);
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
queryReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(queryReq);
@ -247,13 +247,13 @@ public class BatchTestITCase extends AbstractTestITCase {
final BatchManager streamManager = request.payloadManager();
final ODataChangeset changeset = streamManager.addChangeset();
ODataEntity order = newOrder(20);
ClientEntity order = newOrder(20);
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
// add create request
final ODataEntityCreateRequest<ODataEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), order);
final ODataEntityCreateRequest<ClientEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), order);
changeset.addRequest(createReq);
@ -261,10 +261,10 @@ public class BatchTestITCase extends AbstractTestITCase {
int createRequestRef = changeset.getLastContentId();
// add update request: link CustomerInfo(17) to the new customer
final ODataEntity customerChanges = client.getObjectFactory().newEntity(order.getTypeName());
final ClientEntity customerChanges = client.getObjectFactory().newEntity(order.getTypeName());
customerChanges.addLink(client.getObjectFactory().newEntitySetNavigationLink(
"OrderDetails",
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("OrderDetails").
"OrderDetails",
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("OrderDetails").
appendKeySegment(new HashMap<String, Object>() {
private static final long serialVersionUID = 3109256773218160485L;
@ -274,8 +274,8 @@ public class BatchTestITCase extends AbstractTestITCase {
}
}).build()));
final ODataEntityUpdateRequest<ODataEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
URI.create("$" + createRequestRef), UpdateType.PATCH, customerChanges);
final ODataEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest(
URI.create("$" + createRequestRef), UpdateType.PATCH, customerChanges);
changeset.addRequest(updateReq);
@ -295,12 +295,12 @@ public class BatchTestITCase extends AbstractTestITCase {
assertEquals(201, res.getStatusCode());
assertTrue(res instanceof ODataEntityCreateResponse);
order = ((ODataEntityCreateResponse<ODataEntity>) res).getBody();
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
URIUtils.getURI(testStaticServiceRootURL, order.getEditLink().toASCIIString() + "/OrderDetails"));
order = ((ODataEntityCreateResponse<ClientEntity>) res).getBody();
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
URIUtils.getURI(testStaticServiceRootURL, order.getEditLink().toASCIIString() + "/OrderDetails"));
assertEquals(Integer.valueOf(7),
req.execute().getBody().getEntities().get(0).getProperty("OrderID").getPrimitiveValue().
req.execute().getBody().getEntities().get(0).getProperty("OrderID").getPrimitiveValue().
toCastValue(Integer.class));
res = chgitem.next();
@ -309,13 +309,13 @@ public class BatchTestITCase extends AbstractTestITCase {
// clean ...
assertEquals(204, client.getCUDRequestFactory().getDeleteRequest(
URIUtils.getURI(testStaticServiceRootURL, order.getEditLink().toASCIIString())).execute().
getStatusCode());
URIUtils.getURI(testStaticServiceRootURL, order.getEditLink().toASCIIString())).execute().
getStatusCode());
try {
client.getRetrieveRequestFactory().getEntityRequest(
URIUtils.getURI(testStaticServiceRootURL, order.getEditLink().toASCIIString())).
execute().getBody();
URIUtils.getURI(testStaticServiceRootURL, order.getEditLink().toASCIIString())).
execute().getBody();
fail();
} catch (Exception e) {
// ignore
@ -336,10 +336,10 @@ public class BatchTestITCase extends AbstractTestITCase {
// prepare URI
URIBuilder targetURI = client.newURIBuilder(testStaticServiceRootURL);
targetURI.appendEntitySetSegment("Customers").appendKeySegment(1).
expand("Orders").select("PersonID,Orders/OrderID");
expand("Orders").select("PersonID,Orders/OrderID");
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
queryReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(queryReq);
@ -350,9 +350,9 @@ public class BatchTestITCase extends AbstractTestITCase {
// -------------------------------------------
// prepare URI
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
final ODataEntity original = newOrder(2000);
final ODataEntityCreateRequest<ODataEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
final ClientEntity original = newOrder(2000);
final ODataEntityCreateRequest<ClientEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
createReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(createReq);
// -------------------------------------------
@ -382,15 +382,15 @@ public class BatchTestITCase extends AbstractTestITCase {
assertEquals(201, res.getStatusCode());
assertEquals("Created", res.getStatusMessage());
final ODataEntityCreateResponse<ODataEntity> entres = (ODataEntityCreateResponse<ODataEntity>) res;
final ODataEntity entity = entres.getBody();
final ODataEntityCreateResponse<ClientEntity> entres = (ODataEntityCreateResponse<ClientEntity>) res;
final ClientEntity entity = entres.getBody();
assertEquals(2000, entity.getProperty("OrderID").getPrimitiveValue().toCastValue(Integer.class).intValue());
assertFalse(iter.hasNext());
}
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({ "unchecked", "rawtypes" })
public void batchRequest() throws EdmPrimitiveTypeException {
// create your request
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL);
@ -406,7 +406,7 @@ public class BatchTestITCase extends AbstractTestITCase {
targetURI.appendEntitySetSegment("Customers").appendKeySegment(1);
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
queryReq.setFormat(ODataFormat.JSON);
streamManager.addRequest(queryReq);
@ -421,25 +421,25 @@ public class BatchTestITCase extends AbstractTestITCase {
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").appendKeySegment(1);
final URI editLink = targetURI.build();
final ODataEntity patch = client.getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
final ClientEntity patch = client.getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
patch.setEditLink(editLink);
patch.getProperties().add(client.getObjectFactory().newPrimitiveProperty(
"LastName",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("new last name")));
"LastName",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("new last name")));
final ODataEntityUpdateRequest<ODataEntity> changeReq =
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
final ODataEntityUpdateRequest<ClientEntity> changeReq =
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
changeset.addRequest(changeReq);
// Create Order into the changeset
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
final ODataEntity original = newOrder(1000);
final ODataEntityCreateRequest<ODataEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
final ClientEntity original = newOrder(1000);
final ODataEntityCreateRequest<ClientEntity> createReq =
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
createReq.setFormat(ODataFormat.JSON);
changeset.addRequest(createReq);
// -------------------------------------------
@ -471,10 +471,10 @@ public class BatchTestITCase extends AbstractTestITCase {
assertEquals(200, res.getStatusCode());
assertEquals("OK", res.getStatusMessage());
ODataEntityRequestImpl<ODataEntity>.ODataEntityResponseImpl entres =
(ODataEntityRequestImpl.ODataEntityResponseImpl) res;
ODataEntityRequestImpl<ClientEntity>.ODataEntityResponseImpl entres =
(ODataEntityRequestImpl.ODataEntityResponseImpl) res;
ODataEntity entity = entres.getBody();
ClientEntity entity = entres.getBody();
assertEquals(1, entity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
// retrieve the second item (ODataChangeset)
@ -492,7 +492,7 @@ public class BatchTestITCase extends AbstractTestITCase {
assertEquals(201, res.getStatusCode());
assertEquals("Created", res.getStatusMessage());
final ODataEntityCreateResponse<ODataEntity> createres = (ODataEntityCreateResponse<ODataEntity>) res;
final ODataEntityCreateResponse<ClientEntity> createres = (ODataEntityCreateResponse<ClientEntity>) res;
entity = createres.getBody();
assertEquals(new Integer(1000), entity.getProperty("OrderID").getPrimitiveValue().toCastValue(Integer.class));
@ -517,7 +517,7 @@ public class BatchTestITCase extends AbstractTestITCase {
public void async() {
// create your request
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(
URI.create(testStaticServiceRootURL + "/async/").normalize().toASCIIString());
URI.create(testStaticServiceRootURL + "/async/").normalize().toASCIIString());
request.setAccept(ACCEPT);
final AsyncBatchRequestWrapper async = client.getAsyncRequestFactory().getAsyncBatchRequestWrapper(request);
@ -530,7 +530,7 @@ public class BatchTestITCase extends AbstractTestITCase {
targetURI.appendEntitySetSegment("People").appendKeySegment(5);
// create new request
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
ODataEntityRequest<ClientEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
queryReq.setFormat(ODataFormat.JSON);
async.addRetrieve(queryReq);
@ -636,22 +636,22 @@ public class BatchTestITCase extends AbstractTestITCase {
}
}
private ODataEntity newOrder(final int id) {
final ODataEntity order = getClient().getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
private ClientEntity newOrder(final int id) {
final ClientEntity order = getClient().getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("OrderID",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id)));
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id)));
order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("OrderDate",
getClient().getObjectFactory().newPrimitiveValueBuilder().
getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).build()));
order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ShelfLife",
getClient().getObjectFactory().newPrimitiveValueBuilder().
getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build()));
order.getProperties().add(getClient().getObjectFactory().newCollectionProperty("OrderShelfLifes",
getClient().getObjectFactory().newCollectionValue(EdmPrimitiveTypeKind.Duration.name()).add(
getClient().getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Duration).
setValue(new BigDecimal("0.0000002")).build())));
getClient().getObjectFactory().newCollectionValue(EdmPrimitiveTypeKind.Duration.name()).add(
getClient().getObjectFactory().newPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Duration).
setValue(new BigDecimal("0.0000002")).build())));
return order;
}

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -21,16 +21,16 @@ package org.apache.olingo.fit.v4;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataEnumValue;
import org.apache.olingo.commons.api.domain.ODataOperation;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataSingleton;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientCollectionValue;
import org.apache.olingo.commons.api.domain.ClientComplexValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientEnumValue;
import org.apache.olingo.commons.api.domain.ClientOperation;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientSingleton;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
@ -53,40 +53,40 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
private void functions(final ODataFormat format) throws EdmPrimitiveTypeException {
// GetEmployeesCount
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
final ODataEntityRequest<ODataSingleton> singletonReq =
final ODataEntityRequest<ClientSingleton> singletonReq =
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
singletonReq.setFormat(format);
final ODataSingleton company = singletonReq.execute().getBody();
final ClientSingleton company = singletonReq.execute().getBody();
assertNotNull(company);
ODataOperation boundOp = company.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount");
ClientOperation boundOp = company.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount");
assertNotNull(boundOp);
final ODataInvokeRequest<ODataProperty> getEmployeesCountReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataProperty.class);
final ODataInvokeRequest<ClientProperty> getEmployeesCountReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class);
getEmployeesCountReq.setFormat(format);
final ODataProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody();
final ClientProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody();
assertNotNull(getEmployeesCountRes);
assertTrue(getEmployeesCountRes.hasPrimitiveValue());
// GetProductDetails
builder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Products").appendKeySegment(5);
ODataEntityRequest<ODataEntity> entityReq = client.getRetrieveRequestFactory().
ODataEntityRequest<ClientEntity> entityReq = client.getRetrieveRequestFactory().
getEntityRequest(builder.build());
entityReq.setFormat(format);
ODataEntity entity = entityReq.execute().getBody();
ClientEntity entity = entityReq.execute().getBody();
assertNotNull(entity);
boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails");
assertNotNull(boundOp);
final ODataPrimitiveValue count = client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1);
final ODataInvokeRequest<ODataEntitySet> getProductDetailsReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataEntitySet.class,
Collections.<String, ODataValue> singletonMap("count", count));
final ClientPrimitiveValue count = client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1);
final ODataInvokeRequest<ClientEntitySet> getProductDetailsReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntitySet.class,
Collections.<String, ClientValue> singletonMap("count", count));
getProductDetailsReq.setFormat(format);
final ODataEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody();
final ClientEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody();
assertNotNull(getProductDetailsRes);
assertEquals(1, getProductDetailsRes.getEntities().size());
@ -104,10 +104,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct");
assertNotNull(boundOp);
final ODataInvokeRequest<ODataEntity> getRelatedProductReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataEntity.class);
final ODataInvokeRequest<ClientEntity> getRelatedProductReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class);
getRelatedProductReq.setFormat(format);
final ODataEntity getRelatedProductRes = getRelatedProductReq.execute().getBody();
final ClientEntity getRelatedProductRes = getRelatedProductReq.execute().getBody();
assertNotNull(getRelatedProductRes);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Product",
getRelatedProductRes.getTypeName().toString());
@ -124,10 +124,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI");
assertNotNull(boundOp);
final ODataInvokeRequest<ODataEntity> getDefaultPIReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataEntity.class);
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class);
getDefaultPIReq.setFormat(format);
final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
assertNotNull(getDefaultPIRes);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
getDefaultPIRes.getTypeName().toString());
@ -138,10 +138,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo");
assertNotNull(boundOp);
final ODataInvokeRequest<ODataProperty> getAccountInfoReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataProperty.class);
final ODataInvokeRequest<ClientProperty> getAccountInfoReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class);
getAccountInfoReq.setFormat(format);
final ODataProperty getAccountInfoRes = getAccountInfoReq.execute().getBody();
final ClientProperty getAccountInfoRes = getAccountInfoReq.execute().getBody();
assertNotNull(getAccountInfoRes);
assertTrue(getAccountInfoRes.hasComplexValue());
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.AccountInfo",
@ -158,12 +158,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount");
assertNotNull(boundOp);
final ODataPrimitiveValue bonusRate = client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1);
final ODataInvokeRequest<ODataProperty> getActualAmountReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataProperty.class,
Collections.<String, ODataValue> singletonMap("bonusRate", bonusRate));
final ClientPrimitiveValue bonusRate = client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1);
final ODataInvokeRequest<ClientProperty> getActualAmountReq =
client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
Collections.<String, ClientValue> singletonMap("bonusRate", bonusRate));
getActualAmountReq.setFormat(format);
final ODataProperty getActualAmountRes = getActualAmountReq.execute().getBody();
final ClientProperty getActualAmountRes = getActualAmountReq.execute().getBody();
assertNotNull(getActualAmountRes);
assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0);
}
@ -181,26 +181,26 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
@Test
public void edmEnabledFunctions() throws EdmPrimitiveTypeException {
// GetEmployeesCount
final ODataInvokeRequest<ODataProperty> getEmployeesCountReq =
final ODataInvokeRequest<ClientProperty> getEmployeesCountReq =
edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest(
edmClient.newURIBuilder().appendSingletonSegment("Company").build(),
new FullQualifiedName(("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount")),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"),
false);
final ODataProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody();
final ClientProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody();
assertNotNull(getEmployeesCountRes);
assertTrue(getEmployeesCountRes.hasPrimitiveValue());
// GetProductDetails
final ODataPrimitiveValue count = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1);
final ODataInvokeRequest<ODataEntitySet> getProductDetailsReq =
final ClientPrimitiveValue count = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1);
final ODataInvokeRequest<ClientEntitySet> getProductDetailsReq =
edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest(
edmClient.newURIBuilder().appendEntitySetSegment("Products").appendKeySegment(5).build(),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product"),
false,
Collections.<String, ODataValue> singletonMap("count", count));
final ODataEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody();
Collections.<String, ClientValue> singletonMap("count", count));
final ClientEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody();
assertNotNull(getProductDetailsRes);
assertEquals(1, getProductDetailsRes.getEntities().size());
@ -210,26 +210,26 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
keyMap.put("ProductDetailID", 1);
URIBuilder builder = edmClient.newURIBuilder().appendEntitySetSegment("ProductDetails").appendKeySegment(keyMap);
final ODataInvokeRequest<ODataEntity> getRelatedProductReq =
final ODataInvokeRequest<ClientEntity> getRelatedProductReq =
edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest(
builder.build(),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct"),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail"),
false);
final ODataEntity getRelatedProductRes = getRelatedProductReq.execute().getBody();
final ClientEntity getRelatedProductRes = getRelatedProductReq.execute().getBody();
assertNotNull(getRelatedProductRes);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Product",
getRelatedProductRes.getTypeName().toString());
assertEquals(6, getRelatedProductRes.getProperty("ProductID").getPrimitiveValue().toCastValue(Integer.class), 0);
// GetDefaultPI
final ODataInvokeRequest<ODataEntity> getDefaultPIReq =
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest(
edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).build(),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI"),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Account"),
false);
final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
assertNotNull(getDefaultPIRes);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
getDefaultPIRes.getTypeName().toString());
@ -237,29 +237,29 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
getDefaultPIRes.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);
// GetAccountInfo
final ODataInvokeRequest<ODataProperty> getAccountInfoReq =
final ODataInvokeRequest<ClientProperty> getAccountInfoReq =
edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest(
edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).build(),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo"),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Account"),
false);
final ODataProperty getAccountInfoRes = getAccountInfoReq.execute().getBody();
final ClientProperty getAccountInfoRes = getAccountInfoReq.execute().getBody();
assertNotNull(getAccountInfoRes);
assertTrue(getAccountInfoRes.hasComplexValue());
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.AccountInfo",
getAccountInfoRes.getComplexValue().getTypeName());
// GetActualAmount
final ODataPrimitiveValue bonusRate = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1);
final ODataInvokeRequest<ODataProperty> getActualAmountReq =
final ClientPrimitiveValue bonusRate = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1);
final ODataInvokeRequest<ClientProperty> getActualAmountReq =
edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest(
edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).
appendNavigationSegment("MyGiftCard").build(),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount"),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GiftCard"),
false,
Collections.<String, ODataValue> singletonMap("bonusRate", bonusRate));
final ODataProperty getActualAmountRes = getActualAmountReq.execute().getBody();
Collections.<String, ClientValue> singletonMap("bonusRate", bonusRate));
final ClientProperty getActualAmountRes = getActualAmountReq.execute().getBody();
assertNotNull(getActualAmountRes);
assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0);
}
@ -267,22 +267,22 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
private void actions(final ODataFormat format) throws EdmPrimitiveTypeException {
// IncreaseRevenue
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
ODataEntityRequest<ODataEntity> entityReq =
ODataEntityRequest<ClientEntity> entityReq =
client.getRetrieveRequestFactory().getEntityRequest(builder.build());
entityReq.setFormat(format);
ODataEntity entity = entityReq.execute().getBody();
ClientEntity entity = entityReq.execute().getBody();
assertNotNull(entity);
ODataOperation boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue");
ClientOperation boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue");
assertNotNull(boundOp);
final ODataPrimitiveValue increaseValue =
final ClientPrimitiveValue increaseValue =
client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(12L);
final ODataInvokeRequest<ODataProperty> increaseRevenueReq =
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataProperty.class,
Collections.<String, ODataValue> singletonMap("IncreaseValue", increaseValue));
final ODataInvokeRequest<ClientProperty> increaseRevenueReq =
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
Collections.<String, ClientValue> singletonMap("IncreaseValue", increaseValue));
increaseRevenueReq.setFormat(format);
final ODataProperty increaseRevenueRes = increaseRevenueReq.execute().getBody();
final ClientProperty increaseRevenueRes = increaseRevenueReq.execute().getBody();
assertNotNull(increaseRevenueRes);
assertTrue(increaseRevenueRes.hasPrimitiveValue());
@ -297,13 +297,13 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight");
assertNotNull(boundOp);
final ODataEnumValue accessRight = client.getObjectFactory().
final ClientEnumValue accessRight = client.getObjectFactory().
newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "Execute");
final ODataInvokeRequest<ODataProperty> getProductDetailsReq =
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataProperty.class,
Collections.<String, ODataValue> singletonMap("accessRight", accessRight));
final ODataInvokeRequest<ClientProperty> getProductDetailsReq =
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class,
Collections.<String, ClientValue> singletonMap("accessRight", accessRight));
getProductDetailsReq.setFormat(format);
final ODataProperty getProductDetailsRes = getProductDetailsReq.execute().getBody();
final ClientProperty getProductDetailsRes = getProductDetailsReq.execute().getBody();
assertNotNull(getProductDetailsRes);
assertTrue(getProductDetailsRes.hasEnumValue());
@ -318,10 +318,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.ResetAddress");
assertNotNull(boundOp);
final ODataCollectionValue<org.apache.olingo.commons.api.domain.ODataValue> addresses =
final ClientCollectionValue<ClientValue> addresses =
client.getObjectFactory().
newCollectionValue("Collection(Microsoft.Test.OData.Services.ODataWCFService.Address)");
final ODataComplexValue address = client.getObjectFactory().
final ClientComplexValue address = client.getObjectFactory().
newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
address.add(client.getObjectFactory().newPrimitiveProperty("Street",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("Piazza La Bomba E Scappa")));
@ -330,14 +330,14 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010")));
addresses.add(address);
final ODataPrimitiveValue index = client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(0);
final Map<String, ODataValue> params = new LinkedHashMap<String, ODataValue>(2);
final ClientPrimitiveValue index = client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(0);
final Map<String, ClientValue> params = new LinkedHashMap<String, ClientValue>(2);
params.put("addresses", addresses);
params.put("index", index);
final ODataInvokeRequest<ODataEntity> resetAddressReq =
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataEntity.class, params);
final ODataInvokeRequest<ClientEntity> resetAddressReq =
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class, params);
resetAddressReq.setFormat(format);
final ODataEntity resetAddressRes = resetAddressReq.execute().getBody();
final ClientEntity resetAddressRes = resetAddressReq.execute().getBody();
assertNotNull(resetAddressRes);
assertEquals(2, resetAddressRes.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
@ -354,13 +354,13 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
dateTime.set(2014, 3, 9, 0, 0, 0);
final ODataPrimitiveValue newDate = client.getObjectFactory().newPrimitiveValueBuilder().
final ClientPrimitiveValue newDate = client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build();
final ODataInvokeRequest<ODataEntity> getDefaultPIReq =
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataEntity.class,
Collections.<String, ODataValue> singletonMap("newDate", newDate));
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class,
Collections.<String, ClientValue> singletonMap("newDate", newDate));
getDefaultPIReq.setFormat(format);
final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
assertNotNull(getDefaultPIRes);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
getDefaultPIRes.getTypeName().toString());
@ -381,37 +381,37 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
@Test
public void edmEnabledActions() throws EdmPrimitiveTypeException {
// IncreaseRevenue
final ODataPrimitiveValue increaseValue = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt64(12L);
final ODataInvokeRequest<ODataProperty> increaseRevenueReq =
final ClientPrimitiveValue increaseValue = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt64(12L);
final ODataInvokeRequest<ClientProperty> increaseRevenueReq =
edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest(
edmClient.newURIBuilder().appendSingletonSegment("Company").build(),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue"),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"),
false,
Collections.<String, ODataValue> singletonMap("IncreaseValue", increaseValue));
final ODataProperty increaseRevenueRes = increaseRevenueReq.execute().getBody();
Collections.<String, ClientValue> singletonMap("IncreaseValue", increaseValue));
final ClientProperty increaseRevenueRes = increaseRevenueReq.execute().getBody();
assertNotNull(increaseRevenueRes);
assertTrue(increaseRevenueRes.hasPrimitiveValue());
// AddAccessRight
final ODataEnumValue accessRight = edmClient.getObjectFactory().
final ClientEnumValue accessRight = edmClient.getObjectFactory().
newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "Execute");
final ODataInvokeRequest<ODataProperty> getProductDetailsReq =
final ODataInvokeRequest<ClientProperty> getProductDetailsReq =
edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest(
edmClient.newURIBuilder().appendEntitySetSegment("Products").appendKeySegment(5).build(),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product"),
false,
Collections.<String, ODataValue> singletonMap("accessRight", accessRight));
final ODataProperty getProductDetailsRes = getProductDetailsReq.execute().getBody();
Collections.<String, ClientValue> singletonMap("accessRight", accessRight));
final ClientProperty getProductDetailsRes = getProductDetailsReq.execute().getBody();
assertNotNull(getProductDetailsRes);
assertTrue(getProductDetailsRes.hasEnumValue());
// ResetAddress
final ODataCollectionValue<org.apache.olingo.commons.api.domain.ODataValue> addresses =
final ClientCollectionValue<ClientValue> addresses =
edmClient.getObjectFactory().
newCollectionValue("Collection(Microsoft.Test.OData.Services.ODataWCFService.Address)");
final ODataComplexValue address = edmClient.getObjectFactory().
final ClientComplexValue address = edmClient.getObjectFactory().
newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
address.add(edmClient.getObjectFactory().newPrimitiveProperty("Street",
edmClient.getObjectFactory().newPrimitiveValueBuilder().buildString("Piazza La Bomba E Scappa")));
@ -420,36 +420,36 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
address.add(edmClient.getObjectFactory().newPrimitiveProperty("PostalCode",
edmClient.getObjectFactory().newPrimitiveValueBuilder().buildString("66010")));
addresses.add(address);
final ODataPrimitiveValue index = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(0);
final Map<String, ODataValue> params = new LinkedHashMap<String, ODataValue>(2);
final ClientPrimitiveValue index = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(0);
final Map<String, ClientValue> params = new LinkedHashMap<String, ClientValue>(2);
params.put("addresses", addresses);
params.put("index", index);
final Map<String, Object> keys = new HashMap<String, Object>();
keys.put("PersonID", 2);
final ODataInvokeRequest<ODataEntity> resetAddressReq =
final ODataInvokeRequest<ClientEntity> resetAddressReq =
edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest(
edmClient.newURIBuilder().appendEntitySetSegment("Customers").appendKeySegment(keys).build(),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Person"),
false,
params);
final ODataEntity resetAddressRes = resetAddressReq.execute().getBody();
final ClientEntity resetAddressRes = resetAddressReq.execute().getBody();
assertNotNull(resetAddressRes);
assertEquals(2, resetAddressRes.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
// RefreshDefaultPI
Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
dateTime.set(2014, 3, 9, 0, 0, 0);
final ODataPrimitiveValue newDate = edmClient.getObjectFactory().newPrimitiveValueBuilder().
final ClientPrimitiveValue newDate = edmClient.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build();
final ODataInvokeRequest<ODataEntity> getDefaultPIReq =
final ODataInvokeRequest<ClientEntity> getDefaultPIReq =
edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest(
edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).build(),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI"),
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Account"),
false,
Collections.<String, ODataValue> singletonMap("newDate", newDate));
final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
Collections.<String, ClientValue> singletonMap("newDate", newDate));
final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody();
assertNotNull(getDefaultPIRes);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument",
getDefaultPIRes.getTypeName().toString());

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -46,16 +46,16 @@ import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataDelta;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientCollectionValue;
import org.apache.olingo.commons.api.domain.ClientDelta;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.core.domain.ODataEntityImpl;
import org.apache.olingo.commons.core.domain.ClientEntityImpl;
import org.junit.Test;
/**
@ -73,7 +73,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
final ODataEntityRequest<ODataEntity> req =
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
assertEquals("4.0", req.getHeader("OData-MaxVersion"));
@ -87,36 +87,36 @@ public class ConformanceTestITCase extends AbstractTestITCase {
*/
@Test
public void item2() {
final ODataEntity order =
new ODataEntityImpl(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
final ClientEntity order =
new ClientEntityImpl(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
final ODataProperty orderId = getClient().getObjectFactory().newPrimitiveProperty("OrderID",
final ClientProperty orderId = getClient().getObjectFactory().newPrimitiveProperty("OrderID",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(2000));
order.getProperties().add(orderId);
Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
dateTime.set(2011, 2, 4, 16, 3, 57);
final ODataProperty orderDate = getClient().getObjectFactory().newPrimitiveProperty("OrderDate",
final ClientProperty orderDate = getClient().getObjectFactory().newPrimitiveProperty("OrderDate",
getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build());
order.getProperties().add(orderDate);
final ODataProperty shelfLife = getClient().getObjectFactory().newPrimitiveProperty("ShelfLife",
final ClientProperty shelfLife = getClient().getObjectFactory().newPrimitiveProperty("ShelfLife",
getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000001")).build());
order.getProperties().add(shelfLife);
final ODataCollectionValue<ODataValue> orderShelfLifesValue = getClient().getObjectFactory().
final ClientCollectionValue<ClientValue> orderShelfLifesValue = getClient().getObjectFactory().
newCollectionValue("Collection(Duration)");
orderShelfLifesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000001")).build());
orderShelfLifesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build());
final ODataProperty orderShelfLifes = getClient().getObjectFactory().
final ClientProperty orderShelfLifes = getClient().getObjectFactory().
newCollectionProperty("OrderShelfLifes", orderShelfLifesValue);
order.getProperties().add(orderShelfLifes);
final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
getClient().newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Orders").build(), order);
req.setFormat(ODataFormat.JSON_FULL_METADATA);
@ -136,7 +136,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(),
req.getContentType());
final ODataEntity created = req.execute().getBody();
final ClientEntity created = req.execute().getBody();
assertNotNull(created);
final URI deleteURI = created.getEditLink() == null
@ -156,14 +156,14 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("redirect").
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
final ODataEntityRequest<ODataEntity> req =
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
assertEquals("4.0", req.getHeader("OData-MaxVersion"));
assertEquals("4.0", req.getHeader(HeaderName.odataMaxVersion.toString()));
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
@ -178,13 +178,13 @@ public class ConformanceTestITCase extends AbstractTestITCase {
public void item5() {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setFormat(ODataFormat.JSON_FULL_METADATA);
req.setPrefer(client.newPreferences().maxPageSize(5));
ODataRetrieveResponse<ODataEntitySet> res = req.execute();
ODataEntitySet feed = res.getBody();
ODataRetrieveResponse<ClientEntitySet> res = req.execute();
ClientEntitySet feed = res.getBody();
assertNotNull(feed);
@ -212,7 +212,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
public void item6() {
final Integer id = 2000;
ODataEntity rowIndex = getClient().getObjectFactory().newEntity(
ClientEntity rowIndex = getClient().getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.OpenTypesServiceV4.RowIndex"));
getClient().getBinder().add(rowIndex,
getClient().getObjectFactory().newPrimitiveProperty("Id",
@ -227,11 +227,11 @@ public class ConformanceTestITCase extends AbstractTestITCase {
rowIndex.addLink(client.getObjectFactory().newEntityNavigationLink(
"Row", URI.create(testOpenTypeServiceRootURL + "/Row(71f7d0dc-ede4-45eb-b421-555a2aa1e58f)")));
final ODataEntityCreateRequest<ODataEntity> createReq = getClient().getCUDRequestFactory().
final ODataEntityCreateRequest<ClientEntity> createReq = getClient().getCUDRequestFactory().
getEntityCreateRequest(getClient().newURIBuilder(testOpenTypeServiceRootURL).
appendEntitySetSegment("RowIndex").build(), rowIndex);
final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
assertEquals(201, createRes.getStatusCode());
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
@ -256,7 +256,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final URI uri = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).build();
final ODataEntity patch = client.getObjectFactory().newEntity(
final ClientEntity patch = client.getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
patch.setEditLink(uri);
@ -264,13 +264,13 @@ public class ConformanceTestITCase extends AbstractTestITCase {
patch.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("FirstName",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildString(newname)));
final ODataEntityUpdateRequest<ODataEntity> req =
final ODataEntityUpdateRequest<ClientEntity> req =
getClient().getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
final ODataEntityUpdateResponse<ODataEntity> res = req.execute();
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
assertEquals(204, res.getStatusCode());
final ODataEntity actual = read(ODataFormat.JSON, uri);
final ClientEntity actual = read(ODataFormat.JSON, uri);
assertEquals(newname, actual.getProperty("FirstName").getPrimitiveValue().toString());
}
@ -287,7 +287,8 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testAuthServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataFormat.JSON_FULL_METADATA);
assertNotNull(req.execute().getBody());
@ -304,13 +305,13 @@ public class ConformanceTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
appendRefSegment();
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataFormat.JSON_FULL_METADATA);
ODataRetrieveResponse<ODataEntity> res = req.execute();
ODataRetrieveResponse<ClientEntity> res = req.execute();
assertNotNull(res);
final ODataEntity entity = res.getBody();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertTrue(entity.getId().toASCIIString().endsWith("/StaticService/V40/Static.svc/Customers(PersonID=1)"));
@ -330,18 +331,18 @@ public class ConformanceTestITCase extends AbstractTestITCase {
*/
@Test
public void item10() {
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build());
req.setPrefer(client.newPreferences().trackChanges());
final ODataEntitySet customers = req.execute().getBody();
final ClientEntitySet customers = req.execute().getBody();
assertNotNull(customers);
assertNotNull(customers.getDeltaLink());
final ODataDeltaRequest deltaReq = client.getRetrieveRequestFactory().getDeltaRequest(customers.getDeltaLink());
deltaReq.setFormat(ODataFormat.JSON_FULL_METADATA);
final ODataDelta delta = deltaReq.execute().getBody();
final ClientDelta delta = deltaReq.execute().getBody();
assertNotNull(delta);
assertNotNull(delta.getDeltaLink());
@ -363,7 +364,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
assertEquals("Orders", delta.getDeletedLinks().get(0).getRelationship());
assertEquals(2, delta.getEntities().size());
ODataProperty property = delta.getEntities().get(0).getProperty("ContactName");
ClientProperty property = delta.getEntities().get(0).getProperty("ContactName");
assertNotNull(property);
assertTrue(property.hasPrimitiveValue());
property = delta.getEntities().get(1).getProperty("ShippingAddress");
@ -379,21 +380,21 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("async").appendEntitySetSegment("Orders");
final ODataEntitySetRequest<ODataEntitySet> req =
final ODataEntitySetRequest<ClientEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
req.setFormat(ODataFormat.JSON_FULL_METADATA);
final AsyncRequestWrapper<ODataRetrieveResponse<ODataEntitySet>> async =
client.getAsyncRequestFactory().<ODataRetrieveResponse<ODataEntitySet>> getAsyncRequestWrapper(req);
final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntitySet>> async =
client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntitySet>> getAsyncRequestWrapper(req);
async.callback(URI.create("http://client.service.it/callback/endpoint"));
final AsyncResponseWrapper<ODataRetrieveResponse<ODataEntitySet>> responseWrapper = async.execute();
final AsyncResponseWrapper<ODataRetrieveResponse<ClientEntitySet>> responseWrapper = async.execute();
assertTrue(responseWrapper.isPreferenceApplied());
assertTrue(responseWrapper.isDone());
final ODataRetrieveResponse<ODataEntitySet> res = responseWrapper.getODataResponse();
final ODataEntitySet entitySet = res.getBody();
final ODataRetrieveResponse<ClientEntitySet> res = responseWrapper.getODataResponse();
final ClientEntitySet entitySet = res.getBody();
assertFalse(entitySet.getEntities().isEmpty());
}
@ -406,7 +407,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
final ODataEntityRequest<ODataEntity> req =
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataFormat.JSON);
@ -414,7 +415,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
assertEquals("application/json;odata.metadata=minimal", req.getHeader(HeaderName.accept.toString()));
assertEquals("application/json;odata.metadata=minimal", req.getAccept());
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
assertTrue(res.getContentType().startsWith("application/json; odata.metadata=minimal"));
assertNotNull(res.getBody());

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -20,9 +20,9 @@ package org.apache.olingo.fit.v4;
import org.apache.olingo.client.api.communication.request.retrieve.ODataDeltaRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.commons.api.domain.ODataDelta;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientDelta;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -33,18 +33,18 @@ import static org.junit.Assert.assertTrue;
public class DeltaTestITCase extends AbstractTestITCase {
private void parse(final ODataFormat format) {
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build());
req.setPrefer(client.newPreferences().trackChanges());
final ODataEntitySet customers = req.execute().getBody();
final ClientEntitySet customers = req.execute().getBody();
assertNotNull(customers);
assertNotNull(customers.getDeltaLink());
final ODataDeltaRequest deltaReq = client.getRetrieveRequestFactory().getDeltaRequest(customers.getDeltaLink());
deltaReq.setFormat(format);
final ODataDelta delta = deltaReq.execute().getBody();
final ClientDelta delta = deltaReq.execute().getBody();
assertNotNull(delta);
assertNotNull(delta.getDeltaLink());
@ -66,7 +66,7 @@ public class DeltaTestITCase extends AbstractTestITCase {
assertEquals("Orders", delta.getDeletedLinks().get(0).getRelationship());
assertEquals(2, delta.getEntities().size());
ODataProperty property = delta.getEntities().get(0).getProperty("ContactName");
ClientProperty property = delta.getEntities().get(0).getProperty("ContactName");
assertNotNull(property);
assertTrue(property.hasPrimitiveValue());
property = delta.getEntities().get(1).getProperty("ShippingAddress");

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -30,10 +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.ODataEntityCreateResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataValuable;
import org.apache.olingo.commons.api.domain.ClientComplexValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientValuable;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
@ -46,11 +46,11 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").
appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.Customer");
ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setFormat(format);
for (ODataEntity customer : req.execute().getBody().getEntities()) {
for (ClientEntity customer : req.execute().getBody().getEntities()) {
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", customer.getTypeName().toString());
}
@ -62,7 +62,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
req.setFormat(format);
for (ODataEntity customer : req.execute().getBody().getEntities()) {
for (ClientEntity customer : req.execute().getBody().getEntities()) {
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", customer.getTypeName().toString());
}
}
@ -78,7 +78,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
}
private void createDelete(final ODataFormat format) {
final ODataEntity customer = client.getObjectFactory().
final ClientEntity customer = client.getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("PersonID",
@ -88,7 +88,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("Test")));
final ODataComplexValue homeAddress =
final ClientComplexValue homeAddress =
client.getObjectFactory().newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress");
homeAddress.add(client.getObjectFactory().newPrimitiveProperty("Street",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("V.le Gabriele D'Annunzio")));
@ -115,24 +115,24 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
client.getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build()));
final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().
final ODataEntityCreateRequest<ClientEntity> createReq = client.getCUDRequestFactory().
getEntityCreateRequest(
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People").build(),
customer);
createReq.setFormat(format);
final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
assertEquals(201, createRes.getStatusCode());
final ODataEntityRequest<ODataEntity> fetchReq = client.getRetrieveRequestFactory().
final ODataEntityRequest<ClientEntity> fetchReq = client.getRetrieveRequestFactory().
getEntityRequest(client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(976).build());
fetchReq.setFormat(format);
final ODataEntity actual = fetchReq.execute().getBody();
final ClientEntity actual = fetchReq.execute().getBody();
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", actual.getTypeName().toString());
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress",
((ODataValuable) actual.getProperty("HomeAddress")).getValue().getTypeName());
((ClientValuable) actual.getProperty("HomeAddress")).getValue().getTypeName());
final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(actual.getEditLink());
assertEquals(204, deleteReq.execute().getStatusCode());

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -22,10 +22,10 @@ import org.apache.commons.lang3.RandomUtils;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientInlineEntitySet;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
@ -52,18 +52,17 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.JSON_FULL_METADATA, 1001);
}
private void onContained(final ODataFormat format) {
final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts").
appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build();
// 1. read contained collection before any operation
ODataEntitySet instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody();
ClientEntitySet instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody();
assertNotNull(instruments);
final int sizeBefore = instruments.getCount();
// 2. instantiate an ODataEntity of the same type as the collection above
final ODataEntity instrument = getClient().getObjectFactory().
final ClientEntity instrument = getClient().getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
int id = RandomUtils.nextInt(101999, 105000);
@ -76,11 +75,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).build()));
// 3. create it as contained entity
final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
getEntityCreateRequest(uri, instrument);
req.setFormat(format);
final ODataEntityCreateResponse<ODataEntity> res = req.execute();
final ODataEntityCreateResponse<ClientEntity> res = req.execute();
assertEquals(201, res.getStatusCode());
// 4. verify that the contained collection effectively grew
@ -114,7 +113,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
private void deepInsert(final ODataFormat format, final int productId, final int productDetailId)
throws EdmPrimitiveTypeException {
final ODataEntity product = getClient().getObjectFactory().
final ClientEntity product = getClient().getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product"));
product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductID",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productId)));
@ -142,7 +141,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
product.getProperty("CoverColors").getCollectionValue().add(getClient().getObjectFactory().
newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Red"));
final ODataEntity detail = getClient().getObjectFactory().
final ClientEntity detail = getClient().getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail"));
detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductID",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productId)));
@ -153,27 +152,27 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Description",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("High-Quality Milk")));
final ODataEntitySet details = getClient().getObjectFactory().newEntitySet();
final ClientEntitySet details = getClient().getObjectFactory().newEntitySet();
details.getEntities().add(detail);
final ODataInlineEntitySet inlineDetails = getClient().getObjectFactory().
final ClientInlineEntitySet inlineDetails = getClient().getObjectFactory().
newDeepInsertEntitySet("Details", details);
product.addLink(inlineDetails);
final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Products").build(), product);
req.setFormat(format);
final ODataEntityCreateResponse<ODataEntity> res = req.execute();
final ODataEntityCreateResponse<ClientEntity> res = req.execute();
assertEquals(201, res.getStatusCode());
final ODataEntity createdProduct = res.getBody();
final ClientEntity createdProduct = res.getBody();
assertEquals(productId,
createdProduct.getProperty("ProductID").getPrimitiveValue().toCastValue(Integer.class), 0);
final ODataLink createdLink = createdProduct.getNavigationLink("Details");
final ClientLink createdLink = createdProduct.getNavigationLink("Details");
assertNotNull(createdLink);
final ODataEntitySet createdProductDetails =
final ClientEntitySet createdProductDetails =
getClient().getRetrieveRequestFactory().getEntitySetRequest(createdLink.getLink()).execute().getBody();
assertNotNull(createdProductDetails);
assertEquals(productDetailId, createdProductDetails.getEntities().iterator().next().

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -32,13 +32,13 @@ import org.apache.olingo.client.api.communication.response.ODataRawResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataInlineEntity;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataLinkType;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientInlineEntity;
import org.apache.olingo.commons.api.domain.ClientInlineEntitySet;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.domain.ClientLinkType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -55,14 +55,14 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
private void withInlineEntity(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().
getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
@ -81,24 +81,24 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
boolean found = false;
for (ODataLink link : entity.getNavigationLinks()) {
if (link instanceof ODataInlineEntity) {
final ODataEntity inline = ((ODataInlineEntity) link).getEntity();
for (ClientLink link : entity.getNavigationLinks()) {
if (link instanceof ClientInlineEntity) {
final ClientEntity inline = ((ClientInlineEntity) link).getEntity();
assertNotNull(inline);
final List<? extends ODataProperty> properties = inline.getProperties();
final List<? extends ClientProperty> properties = inline.getProperties();
assertEquals(5, properties.size());
assertTrue(properties.get(0).getName().equals("CompanyID")
|| properties.get(1).getName().equals("CompanyID")
|| properties.get(2).getName().equals("CompanyID")
|| properties.get(3).getName().equals("CompanyID")
|| properties.get(4).getName().equals("CompanyID"));
|| properties.get(1).getName().equals("CompanyID")
|| properties.get(2).getName().equals("CompanyID")
|| properties.get(3).getName().equals("CompanyID")
|| properties.get(4).getName().equals("CompanyID"));
assertTrue(properties.get(0).getValue().toString().equals("0")
|| properties.get(1).getValue().toString().equals("0")
|| properties.get(2).getValue().toString().equals("0")
|| properties.get(3).getValue().toString().equals("0")
|| properties.get(4).getValue().toString().equals("0"));
|| properties.get(1).getValue().toString().equals("0")
|| properties.get(2).getValue().toString().equals("0")
|| properties.get(3).getValue().toString().equals("0")
|| properties.get(4).getValue().toString().equals("0"));
found = true;
}
@ -125,23 +125,23 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
private void withInlineEntitySet(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().
getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().
getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
// In JSON with minimal metadata, links are not provided
if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
boolean found = false;
for (ODataLink link : entity.getNavigationLinks()) {
if (link instanceof ODataInlineEntitySet) {
final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
for (ClientLink link : entity.getNavigationLinks()) {
if (link instanceof ClientInlineEntitySet) {
final ClientEntitySet inline = ((ClientInlineEntitySet) link).getEntitySet();
assertNotNull(inline);
found = true;
@ -168,7 +168,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
private void rawRequest(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5);
appendEntitySetSegment("People").appendKeySegment(5);
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
req.setFormat(format.getContentType().toContentTypeString());
@ -176,10 +176,10 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
final ODataRawResponse res = req.execute();
assertNotNull(res);
final ResWrap<ODataEntitySet> entitySet = res.getBodyAs(ODataEntitySet.class);
final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class);
assertNull(entitySet);
final ResWrap<ODataEntity> entity = res.getBodyAs(ODataEntity.class);
final ResWrap<ClientEntity> entity = res.getBodyAs(ClientEntity.class);
assertTrue(entity.getPayload().getId().toASCIIString().endsWith("/StaticService/V40/Static.svc/People(5)"));
}
@ -200,16 +200,17 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
multiKey.put("ProductDetailID", 1);
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("ProductDetails").appendKeySegment(multiKey);
appendEntitySetSegment("ProductDetails").appendKeySegment(multiKey);
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertEquals(Integer.valueOf(1),
entity.getProperty("ProductDetailID").getPrimitiveValue().toCastValue(Integer.class));
entity.getProperty("ProductDetailID").getPrimitiveValue().toCastValue(Integer.class));
}
@Test
@ -224,18 +225,19 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
private void checkForETag(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder =
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
final String etag = res.getETag();
assertTrue(StringUtils.isNotBlank(etag));
final ODataEntity order = res.getBody();
final ClientEntity order = res.getBody();
assertEquals(etag, order.getETag());
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Order", order.getTypeName().toString());
assertEquals("Edm.Int32", order.getProperty("OrderID").getPrimitiveValue().getTypeName());
@ -263,7 +265,8 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
public void issue99() {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataFormat.JSON);
// this statement should cause an IllegalArgumentException bearing JsonParseException
@ -273,21 +276,21 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
private void reference(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
appendRefSegment();
appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
appendRefSegment();
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
ODataRetrieveResponse<ODataEntity> res = req.execute();
ODataRetrieveResponse<ClientEntity> res = req.execute();
assertNotNull(res);
final ODataEntity entity = res.getBody();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertTrue(entity.getId().toASCIIString().endsWith("/StaticService/V40/Static.svc/Customers(PersonID=1)"));
final URI referenceURI = client.newURIBuilder(testStaticServiceRootURL).
appendEntityIdSegment(entity.getId().toASCIIString()).build();
appendEntityIdSegment(entity.getId().toASCIIString()).build();
req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
req.setFormat(format);
@ -309,16 +312,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
private void contained(final ODataClient client, final ODataFormat format) throws EdmPrimitiveTypeException {
final URI uri = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Accounts").appendKeySegment(101).
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build();
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
appendEntitySetSegment("Accounts").appendKeySegment(101).
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build();
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
req.setFormat(format);
final ODataEntity contained = req.execute().getBody();
final ClientEntity contained = req.execute().getBody();
assertNotNull(contained);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", contained.getTypeName().toString());
assertEquals(101902,
contained.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);
contained.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);
assertEquals("Edm.DateTimeOffset", contained.getProperty("CreatedDate").getPrimitiveValue().getTypeName());
assertNotNull(contained.getProperty("CreatedDate").getPrimitiveValue().toCastValue(Timestamp.class));
}
@ -340,17 +343,17 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
private void entitySetNavigationLink(final ODataClient client, final ODataFormat format) {
final URI uri = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Accounts").appendKeySegment(101).build();
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
appendEntitySetSegment("Accounts").appendKeySegment(101).build();
final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
req.setFormat(format);
final ODataEntity entity = req.execute().getBody();
final ClientEntity entity = req.execute().getBody();
assertNotNull(entity);
// With JSON, entity set navigation links are only recognizable via Edm
if (format == ODataFormat.ATOM || client instanceof EdmEnabledODataClient) {
assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
}
}

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -28,8 +28,8 @@ import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -54,7 +54,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
final ODataRawResponse res = req.execute();
assertNotNull(res);
final ResWrap<ODataEntitySet> entitySet = res.getBodyAs(ODataEntitySet.class);
final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class);
assertNotNull(entitySet.getPayload());
assertTrue(entitySet.getContextURL().toASCIIString().endsWith("$metadata#People"));
}
@ -79,7 +79,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
final ODataRawResponse res = req.execute();
assertNotNull(res);
final ResWrap<ODataEntitySet> entitySet = res.getBodyAs(ODataEntitySet.class);
final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class);
assertEquals(5, entitySet.getPayload().getEntities().size());
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address",
@ -104,12 +104,12 @@ public class EntitySetTestITCase extends AbstractTestITCase {
private void readODataEntitySetIterator(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
final ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> req =
final ODataEntitySetIteratorRequest<ClientEntitySet, ClientEntity> req =
client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntitySetIterator<ODataEntitySet, ODataEntity>> res = req.execute();
final ODataEntitySetIterator<ODataEntitySet, ODataEntity> feedIterator = res.getBody();
final ODataRetrieveResponse<ODataEntitySetIterator<ClientEntitySet, ClientEntity>> res = req.execute();
final ODataEntitySetIterator<ClientEntitySet, ClientEntity> feedIterator = res.getBody();
assertNotNull(feedIterator);
@ -146,13 +146,13 @@ public class EntitySetTestITCase extends AbstractTestITCase {
private void readWithNext(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.build());
req.setFormat(format);
req.setPrefer(client.newPreferences().maxPageSize(5));
final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
final ODataEntitySet feed = res.getBody();
final ODataRetrieveResponse<ClientEntitySet> res = req.execute();
final ClientEntitySet feed = res.getBody();
assertNotNull(feed);

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -32,8 +32,8 @@ import org.apache.olingo.client.api.communication.request.cud.ODataReferenceAddi
import org.apache.olingo.client.api.communication.request.cud.UpdateType;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataReferenceAddingResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
@ -44,7 +44,7 @@ import org.junit.Test;
public class EntityUpdateTestITCase extends AbstractTestITCase {
private void upsert(final UpdateType updateType, final ODataFormat format) {
final ODataEntity order = getClient().getObjectFactory().
final ClientEntity order = getClient().getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("OrderID",
@ -59,13 +59,13 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
final URI upsertURI = getClient().newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Orders").appendKeySegment(9).build();
final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory().
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
getEntityUpdateRequest(upsertURI, updateType, order);
req.setFormat(format);
req.execute();
try {
final ODataEntity read = read(format, upsertURI);
final ClientEntity read = read(format, upsertURI);
assertNotNull(read);
assertEquals(order.getProperty("OrderID"), read.getProperty("OrderID"));
assertEquals(order.getProperty("OrderDate").getPrimitiveValue().toString(),
@ -115,7 +115,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
private void onContained(final ODataFormat format) {
final String newName = UUID.randomUUID().toString();
final ODataEntity changes = getClient().getObjectFactory().newEntity(
final ClientEntity changes = getClient().getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("FriendlyName",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildString(newName)));
@ -123,14 +123,14 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Accounts").appendKeySegment(101).
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101901).build();
final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory().
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
req.setFormat(format);
final ODataEntityUpdateResponse<ODataEntity> res = req.execute();
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
assertEquals(204, res.getStatusCode());
final ODataEntity actual = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
final ClientEntity actual = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
assertNotNull(actual);
assertEquals(newName, actual.getProperty("FriendlyName").getPrimitiveValue().toString());
}
@ -146,28 +146,28 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
}
private void bindOperation(final ODataFormat format) throws EdmPrimitiveTypeException {
final ODataEntity changes = getClient().getObjectFactory().newEntity(
final ClientEntity changes = getClient().getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
final ODataLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent",
final ClientLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent",
getClient().newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(1).build());
changes.getNavigationLinks().add(parent);
final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).build();
final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory().
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
req.setFormat(format);
final ODataEntityUpdateResponse<ODataEntity> res = req.execute();
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
assertEquals(204, res.getStatusCode());
final ODataEntity updated = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
final ClientEntity updated = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
assertNotNull(updated);
final ODataLink updatedLink = updated.getNavigationLink("Parent");
final ClientLink updatedLink = updated.getNavigationLink("Parent");
assertNotNull(updatedLink);
final ODataEntity updatedEntity = getClient().getRetrieveRequestFactory().getEntityRequest(updatedLink.getLink()).
final ClientEntity updatedEntity = getClient().getRetrieveRequestFactory().getEntityRequest(updatedLink.getLink()).
execute().getBody();
assertNotNull(updatedEntity);
assertEquals(1, updatedEntity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);

View File

@ -1,26 +1,26 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.fit.v4;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.domain.ODataErrorDetail;
import org.apache.olingo.commons.api.domain.ClientError;
import org.apache.olingo.commons.api.domain.ClientErrorDetail;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -42,10 +42,10 @@ public class ErrorResponseTestITCase extends AbstractTestITCase {
read(ODataFormat.JSON, readURI);
fail("should have got exception");
} catch (Exception ex) {
final ODataError err = ((ODataClientErrorException) ex).getODataError();
final ClientError err = ((ODataClientErrorException) ex).getODataError();
// verify details
final ODataErrorDetail detail = err.getDetails().get(0);
final ClientErrorDetail detail = err.getDetails().get(0);
assertEquals("Code should be correct", "301", detail.getCode());
assertEquals("Target should be correct", "$search", detail.getTarget());
assertEquals("Message should be correct", "$search query option not supported", detail.getMessage());

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -23,8 +23,8 @@ import org.apache.olingo.client.api.uri.FilterArgFactory;
import org.apache.olingo.client.api.uri.FilterFactory;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.api.uri.URIFilter;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -48,14 +48,14 @@ public class FilterFactoryTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder =
client.newURIBuilder(testStaticServiceRootURL).appendCrossjoinSegment("Customers", "Orders").filter(filter);
final ODataEntitySetRequest<ODataEntitySet> req =
final ODataEntitySetRequest<ClientEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
req.setFormat(ODataFormat.JSON_FULL_METADATA);
final ODataEntitySet feed = req.execute().getBody();
final ClientEntitySet feed = req.execute().getBody();
assertEquals(3, feed.getEntities().size());
for (ODataEntity entity : feed.getEntities()) {
for (ClientEntity entity : feed.getEntities()) {
assertEquals(2, entity.getNavigationLinks().size());
}
}

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -29,12 +29,12 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.EntityCollection;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataLinkType;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.domain.ClientLinkType;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.format.ODataFormat;
@ -62,21 +62,21 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
@Test
public void item1() throws EdmPrimitiveTypeException {
final URI uri = edmClient.newURIBuilder().
appendEntitySetSegment("Accounts").appendKeySegment(102).
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(102902).build();
final ODataEntityRequest<ODataEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
appendEntitySetSegment("Accounts").appendKeySegment(102).
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(102902).build();
final ODataEntityRequest<ClientEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
// request format (via Accept header) is set to minimal by default
assertEquals("application/json;odata.metadata=minimal", req.getAccept());
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
// response is odata.metadata=minimal
assertFalse(res.getContentType().contains("odata.metadata=none"));
assertFalse(res.getContentType().contains("odata.metadata=full"));
// response payload is understood
final ODataEntity entity = res.getBody();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", entity.getTypeName().toString());
assertEquals(102902, entity.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);
@ -89,23 +89,23 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
@Test
public void item2() {
final URI uri = edmClient.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Accounts").appendKeySegment(102).build();
final ODataEntityRequest<ODataEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
appendEntitySetSegment("Accounts").appendKeySegment(102).build();
final ODataEntityRequest<ClientEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
req.setFormat(ODataFormat.JSON_FULL_METADATA);
// request format (via Accept header) is set to full metadata
assertEquals("application/json;odata.metadata=full", req.getAccept());
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
// response is odata.metadata=full
assertTrue(res.getContentType().contains("odata.metadata=full"));
// response payload is understood (including links, only returned with full metadata)
final ODataEntity entity = res.getBody();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
}
/**
@ -119,36 +119,36 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
@Test
public void item3() throws Exception {
final String fromSection71 = "{"
+ "\"NullValue\": null,"
+ "\"TrueValue\": true,"
+ "\"FalseValue\": false,"
+ "\"BinaryValue@odata.type\": \"Binary\","
+ "\"BinaryValue\": \"T0RhdGE\","
+ "\"IntegerValue\": -128,"
+ "\"DoubleValue\": 3.1415926535897931,"
+ "\"SingleValue@odata.type\": \"Single\","
+ "\"SingleValue\": \"INF\","
+ "\"DecimalValue@odata.type\": \"Decimal\","
+ "\"DecimalValue\": 34.95,"
+ "\"StringValue\": \"Say \\\"Hello\\\",\\nthen go\","
+ "\"DateValue@odata.type\": \"Date\","
+ "\"DateValue\": \"2012-12-03\","
+ "\"DateTimeOffsetValue@odata.type\": \"DateTimeOffset\","
+ "\"DateTimeOffsetValue\": \"2012-12-03T07:16:23Z\","
+ "\"DurationValue@odata.type\": \"Duration\","
+ "\"DurationValue\": \"P12DT23H59M59.999999999999S\","
+ "\"TimeOfDayValue@odata.type\": \"TimeOfDay\","
+ "\"TimeOfDayValue\": \"07:59:59.999\","
+ "\"GuidValue@odata.type\": \"Guid\","
+ "\"GuidValue\": \"01234567-89ab-cdef-0123-456789abcdef\","
+ "\"Int64Value@odata.type\": \"Int64\","
+ "\"Int64Value\": 0,"
+ "\"ColorEnumValue@odata.type\": \"Test.Color\","
+ "\"ColorEnumValue\": \"Yellow\","
+ "\"GeographyPoint\": {\"type\": \"Point\",\"coordinates\":[142.1,64.1]}"
+ "}";
+ "\"NullValue\": null,"
+ "\"TrueValue\": true,"
+ "\"FalseValue\": false,"
+ "\"BinaryValue@odata.type\": \"Binary\","
+ "\"BinaryValue\": \"T0RhdGE\","
+ "\"IntegerValue\": -128,"
+ "\"DoubleValue\": 3.1415926535897931,"
+ "\"SingleValue@odata.type\": \"Single\","
+ "\"SingleValue\": \"INF\","
+ "\"DecimalValue@odata.type\": \"Decimal\","
+ "\"DecimalValue\": 34.95,"
+ "\"StringValue\": \"Say \\\"Hello\\\",\\nthen go\","
+ "\"DateValue@odata.type\": \"Date\","
+ "\"DateValue\": \"2012-12-03\","
+ "\"DateTimeOffsetValue@odata.type\": \"DateTimeOffset\","
+ "\"DateTimeOffsetValue\": \"2012-12-03T07:16:23Z\","
+ "\"DurationValue@odata.type\": \"Duration\","
+ "\"DurationValue\": \"P12DT23H59M59.999999999999S\","
+ "\"TimeOfDayValue@odata.type\": \"TimeOfDay\","
+ "\"TimeOfDayValue\": \"07:59:59.999\","
+ "\"GuidValue@odata.type\": \"Guid\","
+ "\"GuidValue\": \"01234567-89ab-cdef-0123-456789abcdef\","
+ "\"Int64Value@odata.type\": \"Int64\","
+ "\"Int64Value\": 0,"
+ "\"ColorEnumValue@odata.type\": \"Test.Color\","
+ "\"ColorEnumValue\": \"Yellow\","
+ "\"GeographyPoint\": {\"type\": \"Point\",\"coordinates\":[142.1,64.1]}"
+ "}";
final ODataEntity entity = client.getReader().readEntity(IOUtils.toInputStream(fromSection71), ODataFormat.JSON);
final ClientEntity entity = client.getReader().readEntity(IOUtils.toInputStream(fromSection71), ODataFormat.JSON);
assertTrue(entity.getProperty("NullValue").hasNullValue());
@ -165,29 +165,29 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
assertEquals(EdmPrimitiveTypeKind.Double, entity.getProperty("DoubleValue").getPrimitiveValue().getTypeKind());
assertEquals(3.1415926535897931,
entity.getProperty("DoubleValue").getPrimitiveValue().toCastValue(Double.class), 0);
entity.getProperty("DoubleValue").getPrimitiveValue().toCastValue(Double.class), 0);
assertEquals(EdmPrimitiveTypeKind.Single, entity.getProperty("SingleValue").getPrimitiveValue().getTypeKind());
assertEquals(Float.POSITIVE_INFINITY,
entity.getProperty("SingleValue").getPrimitiveValue().toCastValue(Float.class), 0);
entity.getProperty("SingleValue").getPrimitiveValue().toCastValue(Float.class), 0);
assertEquals(EdmPrimitiveTypeKind.Decimal, entity.getProperty("DecimalValue").getPrimitiveValue().getTypeKind());
assertEquals(BigDecimal.valueOf(34.95),
entity.getProperty("DecimalValue").getPrimitiveValue().toCastValue(BigDecimal.class));
entity.getProperty("DecimalValue").getPrimitiveValue().toCastValue(BigDecimal.class));
assertEquals(EdmPrimitiveTypeKind.String, entity.getProperty("StringValue").getPrimitiveValue().getTypeKind());
assertEquals("Say \"Hello\",\nthen go",
entity.getProperty("StringValue").getPrimitiveValue().toCastValue(String.class));
entity.getProperty("StringValue").getPrimitiveValue().toCastValue(String.class));
assertEquals(EdmPrimitiveTypeKind.Date, entity.getProperty("DateValue").getPrimitiveValue().getTypeKind());
assertEquals(EdmPrimitiveTypeKind.DateTimeOffset,
entity.getProperty("DateTimeOffsetValue").getPrimitiveValue().getTypeKind());
entity.getProperty("DateTimeOffsetValue").getPrimitiveValue().getTypeKind());
assertEquals(EdmPrimitiveTypeKind.Duration, entity.getProperty("DurationValue").getPrimitiveValue().getTypeKind());
assertEquals(EdmPrimitiveTypeKind.TimeOfDay,
entity.getProperty("TimeOfDayValue").getPrimitiveValue().getTypeKind());
entity.getProperty("TimeOfDayValue").getPrimitiveValue().getTypeKind());
assertEquals(EdmPrimitiveTypeKind.Guid, entity.getProperty("GuidValue").getPrimitiveValue().getTypeKind());
@ -196,7 +196,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
assertTrue(entity.getProperty("ColorEnumValue").hasEnumValue());
assertEquals(EdmPrimitiveTypeKind.GeographyPoint,
entity.getProperty("GeographyPoint").getPrimitiveValue().getTypeKind());
entity.getProperty("GeographyPoint").getPrimitiveValue().getTypeKind());
}
/**
@ -205,21 +205,21 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
@Test
public void item4() throws Exception {
final String fromSection45_1 = "{"
+ "\"@odata.context\": \"http://host/service/$metadata#Customers/$entity\","
+ "\"@odata.metadataEtag\": \"W/\\\"A1FF3E230954908F\\\"\","
+ "\"@odata.etag\": \"W/\\\"A1FF3E230954908G\\\"\","
+ "\"@odata.type\": \"#Model.VipCustomer\","
+ "\"@odata.id\": \"http://host/service/Employees(PersonID=3)\","
+ "\"@odata.editLink\": \"People(976)\","
+ "\"@odata.mediaEditLink\": \"Employees(1)/$value\","
+ "\"@odata.mediaContentType\": \"image/jpeg\","
+ "\"@odata.mediaEtag\": \"W/\\\"A1FF3E230954908H\\\"\","
+ "\"Parent@odata.navigationLink\": \"People(976)/Parent\","
+ "\"Parent@odata.associationLink\": \"People(976)/Parent\""
+ "}";
+ "\"@odata.context\": \"http://host/service/$metadata#Customers/$entity\","
+ "\"@odata.metadataEtag\": \"W/\\\"A1FF3E230954908F\\\"\","
+ "\"@odata.etag\": \"W/\\\"A1FF3E230954908G\\\"\","
+ "\"@odata.type\": \"#Model.VipCustomer\","
+ "\"@odata.id\": \"http://host/service/Employees(PersonID=3)\","
+ "\"@odata.editLink\": \"People(976)\","
+ "\"@odata.mediaEditLink\": \"Employees(1)/$value\","
+ "\"@odata.mediaContentType\": \"image/jpeg\","
+ "\"@odata.mediaEtag\": \"W/\\\"A1FF3E230954908H\\\"\","
+ "\"Parent@odata.navigationLink\": \"People(976)/Parent\","
+ "\"Parent@odata.associationLink\": \"People(976)/Parent\""
+ "}";
final ResWrap<Entity> entity =
client.getDeserializer(ODataFormat.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
client.getDeserializer(ODataFormat.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
assertEquals("http://host/service/$metadata#Customers/$entity", entity.getContextURL().toASCIIString());
assertEquals("W/\"A1FF3E230954908F\"", entity.getMetadataETag());
@ -234,14 +234,14 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
assertEquals("People(976)/Parent", entity.getPayload().getAssociationLink("Parent").getHref());
final String fromSection45_2 = "{"
+ " \"@odata.count\": 5,"
+ " \"value\": [],"
+ " \"@odata.nextLink\": \"Customers?$expand=Orders&$skipToken=5\","
+ " \"@odata.deltaLink\": \"Customers?$expand=Orders&$deltatoken=8015\""
+ "}";
+ " \"@odata.count\": 5,"
+ " \"value\": [],"
+ " \"@odata.nextLink\": \"Customers?$expand=Orders&$skipToken=5\","
+ " \"@odata.deltaLink\": \"Customers?$expand=Orders&$deltatoken=8015\""
+ "}";
final ResWrap<EntityCollection> entitySet =
client.getDeserializer(ODataFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
client.getDeserializer(ODataFormat.JSON).toEntitySet(IOUtils.toInputStream(fromSection45_2));
assertEquals(5, entitySet.getPayload().getCount(), 0);
assertEquals("Customers?$expand=Orders&$skipToken=5", entitySet.getPayload().getNext().toASCIIString());
@ -255,54 +255,54 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
@Test
public void item5() throws Exception {
final String sample = "{"
+ " \"@odata.context\": \"http://host/service/$metadata#Customers\","
+ " \"@odata.notdefined\": 11,"
+ " \"@com.contoso.customer.setkind\": \"VIPs\","
+ " \"value\": ["
+ " {"
+ " \"@com.contoso.display.highlight\": true,"
+ " \"ID\": \"ALFKI\","
+ " \"CompanyName@com.contoso.display.style\": { \"title\": true, \"order\": 1 },"
+ " \"CompanyName\": \"Alfreds Futterkiste\","
+ " \"Orders@com.contoso.display.style\": { \"order\": 2 },"
+ " \"Orders@odata.navigationLink\": \"People(976)/Orders\""
+ " }"
+ " ]"
+ "}";
+ " \"@odata.context\": \"http://host/service/$metadata#Customers\","
+ " \"@odata.notdefined\": 11,"
+ " \"@com.contoso.customer.setkind\": \"VIPs\","
+ " \"value\": ["
+ " {"
+ " \"@com.contoso.display.highlight\": true,"
+ " \"ID\": \"ALFKI\","
+ " \"CompanyName@com.contoso.display.style\": { \"title\": true, \"order\": 1 },"
+ " \"CompanyName\": \"Alfreds Futterkiste\","
+ " \"Orders@com.contoso.display.style\": { \"order\": 2 },"
+ " \"Orders@odata.navigationLink\": \"People(976)/Orders\""
+ " }"
+ " ]"
+ "}";
final ODataEntitySet entitySet = client.getReader().
readEntitySet(IOUtils.toInputStream(sample), ODataFormat.JSON);
final ClientEntitySet entitySet = client.getReader().
readEntitySet(IOUtils.toInputStream(sample), ODataFormat.JSON);
assertEquals(2, entitySet.getAnnotations().size());
final ODataAnnotation notdefined = entitySet.getAnnotations().get(0);
final ClientAnnotation notdefined = entitySet.getAnnotations().get(0);
assertEquals("odata.notdefined", notdefined.getTerm());
assertEquals(11, notdefined.getPrimitiveValue().toCastValue(Integer.class), 0);
final ODataAnnotation setkind = entitySet.getAnnotations().get(1);
final ClientAnnotation setkind = entitySet.getAnnotations().get(1);
assertEquals("com.contoso.customer.setkind", setkind.getTerm());
assertEquals("VIPs", setkind.getPrimitiveValue().toCastValue(String.class));
final ODataEntity entity = entitySet.getEntities().get(0);
final ClientEntity entity = entitySet.getEntities().get(0);
assertEquals(1, entity.getAnnotations().size());
final ODataAnnotation highlight = entity.getAnnotations().get(0);
final ClientAnnotation highlight = entity.getAnnotations().get(0);
assertEquals("com.contoso.display.highlight", highlight.getTerm());
assertEquals(Boolean.TRUE, highlight.getPrimitiveValue().toCastValue(Boolean.class));
final ODataProperty property = entity.getProperty("CompanyName");
final ClientProperty property = entity.getProperty("CompanyName");
assertEquals(1, property.getAnnotations().size());
final ODataAnnotation style = property.getAnnotations().get(0);
final ClientAnnotation style = property.getAnnotations().get(0);
assertEquals("com.contoso.display.style", style.getTerm());
assertTrue(style.hasComplexValue());
assertEquals(Boolean.TRUE, style.getComplexValue().get("title").getPrimitiveValue().toCastValue(Boolean.class));
assertEquals(1, style.getComplexValue().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
final ODataLink orders = entity.getNavigationLink("Orders");
final ClientLink orders = entity.getNavigationLink("Orders");
assertEquals(1, orders.getAnnotations().size());
final ODataAnnotation style2 = orders.getAnnotations().get(0);
final ClientAnnotation style2 = orders.getAnnotations().get(0);
assertEquals("com.contoso.display.style", style2.getTerm());
assertTrue(style2.hasComplexValue());
assertEquals(2, style2.getComplexValue().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
@ -314,17 +314,17 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
@Test
public void item6() throws EdmPrimitiveTypeException {
final URI uri = edmClient.newURIBuilder().
appendEntitySetSegment("Accounts").appendKeySegment(102).
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(102902).build();
final ODataEntityRequest<ODataEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
appendEntitySetSegment("Accounts").appendKeySegment(102).
appendNavigationSegment("MyPaymentInstruments").appendKeySegment(102902).build();
final ODataEntityRequest<ClientEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
// request format (via Accept header) does not contain odata.streaming=true
assertEquals("application/json;odata.metadata=minimal", req.getAccept());
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
// response payload is understood
final ODataEntity entity = res.getBody();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", entity.getTypeName().toString());
assertEquals(102902, entity.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -24,8 +24,8 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.AfterClass;
@ -52,13 +52,14 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
private void read(final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL).
appendEntitySetSegment("Accounts").appendKeySegment(101);
appendEntitySetSegment("Accounts").appendKeySegment(101);
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataEntity entity = res.getBody();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
final ClientEntity entity = res.getBody();
assertNotNull(entity);
// In JSON with minimal metadata, links are not provided
@ -89,27 +90,27 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
}
private void update(final ODataFormat format) {
final ODataEntity changes = getClient().getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
final ODataProperty middleName = getClient().getObjectFactory().newPrimitiveProperty("MiddleName",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("middle"));
final ClientEntity changes = getClient().getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
final ClientProperty middleName = getClient().getObjectFactory().newPrimitiveProperty("MiddleName",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("middle"));
changes.getProperties().add(middleName);
final URI uri = getClient().newURIBuilder(testKeyAsSegmentServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).build();
final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory().
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
appendEntitySetSegment("People").appendKeySegment(5).build();
final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().
getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
req.setFormat(format);
final ODataEntityUpdateResponse<ODataEntity> res = req.execute();
final ODataEntityUpdateResponse<ClientEntity> res = req.execute();
assertEquals(204, res.getStatusCode());
final ODataEntity updated = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
final ClientEntity updated = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
assertNotNull(updated);
assertFalse(updated.getEditLink().toASCIIString().contains("("));
assertFalse(updated.getEditLink().toASCIIString().contains(")"));
final ODataProperty updatedMiddleName = updated.getProperty("MiddleName");
final ClientProperty updatedMiddleName = updated.getProperty("MiddleName");
assertNotNull(updatedMiddleName);
assertEquals("middle", updatedMiddleName.getPrimitiveValue().toString());
}

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -36,8 +36,8 @@ import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdat
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataValuable;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientValuable;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
@ -61,16 +61,16 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
final URIBuilder builder = client.newURIBuilder(testDemoServiceRootURL).
appendEntitySetSegment("Advertisements").
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7"));
final ODataEntityRequest<ODataEntity> entityReq =
final ODataEntityRequest<ClientEntity> entityReq =
client.getRetrieveRequestFactory().getEntityRequest(builder.build());
entityReq.setFormat(format);
final ODataEntity entity = entityReq.execute().getBody();
final ClientEntity entity = entityReq.execute().getBody();
assertNotNull(entity);
assertTrue(entity.isMediaEntity());
// cast to workaround JDK 6 bug, fixed in JDK 7
assertEquals(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName().toString(),
((ODataValuable) entity.getProperty("AirDate")).getValue().getTypeName());
((ClientValuable) entity.getProperty("AirDate")).getValue().getTypeName());
final ODataMediaRequest streamReq = client.getRetrieveRequestFactory().
getMediaRequest(entity.getMediaContentSource());
@ -101,28 +101,28 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
final InputStream input = IOUtils.toInputStream(random);
final URI uri = client.newURIBuilder(testDemoServiceRootURL).appendEntitySetSegment("Advertisements").build();
final ODataMediaEntityCreateRequest<ODataEntity> createReq =
final ODataMediaEntityCreateRequest<ClientEntity> createReq =
client.getCUDRequestFactory().getMediaEntityCreateRequest(uri, input);
final MediaEntityCreateStreamManager<ODataEntity> streamManager = createReq.payloadManager();
final MediaEntityCreateStreamManager<ClientEntity> streamManager = createReq.payloadManager();
final ODataMediaEntityCreateResponse<ODataEntity> createRes = streamManager.getResponse();
final ODataMediaEntityCreateResponse<ClientEntity> createRes = streamManager.getResponse();
assertEquals(201, createRes.getStatusCode());
final Collection<String> location = createRes.getHeader(HeaderName.location);
assertNotNull(location);
final URI createdLocation = URI.create(location.iterator().next());
final ODataEntity changes = client.getObjectFactory().
final ClientEntity changes = client.getObjectFactory().
newEntity(new FullQualifiedName("ODataDemo.Advertisement"));
changes.getProperties().add(client.getObjectFactory().newPrimitiveProperty("AirDate",
getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).build()));
final ODataEntityUpdateRequest<ODataEntity> updateReq = getClient().getCUDRequestFactory().
final ODataEntityUpdateRequest<ClientEntity> updateReq = getClient().getCUDRequestFactory().
getEntityUpdateRequest(createdLocation, UpdateType.PATCH, changes);
updateReq.setFormat(format);
final ODataEntityUpdateResponse<ODataEntity> updateRes = updateReq.execute();
final ODataEntityUpdateResponse<ClientEntity> updateRes = updateReq.execute();
assertEquals(204, updateRes.getStatusCode());
final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().
@ -153,12 +153,12 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
final String random = RandomStringUtils.random(124);
// 1. update providing media content
final ODataMediaEntityUpdateRequest<ODataEntity> updateReq = client.getCUDRequestFactory().
final ODataMediaEntityUpdateRequest<ClientEntity> updateReq = client.getCUDRequestFactory().
getMediaEntityUpdateRequest(uri, IOUtils.toInputStream(random));
updateReq.setFormat(format);
final MediaEntityUpdateStreamManager<ODataEntity> streamManager = updateReq.payloadManager();
final ODataMediaEntityUpdateResponse<ODataEntity> createRes = streamManager.getResponse();
final MediaEntityUpdateStreamManager<ClientEntity> streamManager = updateReq.payloadManager();
final ODataMediaEntityUpdateResponse<ClientEntity> createRes = streamManager.getResponse();
assertEquals(204, createRes.getStatusCode());
// 2. check that media content was effectively uploaded

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -47,7 +47,7 @@ public class MetadataTestITCase extends AbstractTestITCase {
assertNotNull(edm);
final EdmEntityType order = edm.getEntityType(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService", "Order"));
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService", "Order"));
assertNotNull(order);
final EdmProperty orderDate = order.getStructuralProperty("OrderDate");
@ -68,12 +68,12 @@ public class MetadataTestITCase extends AbstractTestITCase {
assertEquals(3, record.getPropertyValues().size());
assertTrue(record.getPropertyValues().get(0).getValue().isConstant());
assertTrue(record.getPropertyValues().get(0).getValue().asConstant().getValue().asPrimitive().
toCastValue(Boolean.class));
toCastValue(Boolean.class));
assertTrue(record.getPropertyValues().get(1).getValue().asDynamic().isCollection());
assertEquals(1, record.getPropertyValues().get(1).getValue().asDynamic().asCollection().getItems().size());
assertTrue(record.getPropertyValues().get(1).getValue().asDynamic().asCollection().getItems().get(0).isDynamic());
assertEquals("OrderID", record.getPropertyValues().get(1).getValue().asDynamic().asCollection().
getItems().get(0).asDynamic().asPropertyPath().getValue());
getItems().get(0).asDynamic().asPropertyPath().getValue());
}
@Test
@ -82,7 +82,7 @@ public class MetadataTestITCase extends AbstractTestITCase {
assertNotNull(edm);
final EdmEntityContainer container = edm.getEntityContainer(
new FullQualifiedName("ODataWebExperimental.Northwind.Model", "NorthwindEntities"));
new FullQualifiedName("ODataWebExperimental.Northwind.Model", "NorthwindEntities"));
assertNotNull(container);
final EdmEntitySet categories = container.getEntitySet("Categories");
@ -93,7 +93,7 @@ public class MetadataTestITCase extends AbstractTestITCase {
@Test
public void vocabularies() {
final Edm edm = client.getRetrieveRequestFactory().
getMetadataRequest(testVocabulariesServiceRootURL).execute().getBody();
getMetadataRequest(testVocabulariesServiceRootURL).execute().getBody();
assertNotNull(edm);
// 1. core
@ -105,12 +105,12 @@ public class MetadataTestITCase extends AbstractTestITCase {
final EdmTerm descriptionTerm = edm.getTerm(new FullQualifiedName("Core.Description"));
assertNotNull(descriptionTerm);
assertEquals(descriptionTerm.getFullQualifiedName(),
edm.getTerm(new FullQualifiedName("Org.OData.Core.V1.Description")).getFullQualifiedName());
edm.getTerm(new FullQualifiedName("Org.OData.Core.V1.Description")).getFullQualifiedName());
final EdmAnnotation description = core.getAnnotation(descriptionTerm);
assertNotNull(description);
assertEquals("Core terms needed to write vocabularies",
description.getExpression().asConstant().getValue().asPrimitive().toString());
description.getExpression().asConstant().getValue().asPrimitive().toString());
final EdmTerm isLanguageDependent = edm.getTerm(new FullQualifiedName("Core.IsLanguageDependent"));
assertNotNull(isLanguageDependent);
@ -132,7 +132,7 @@ public class MetadataTestITCase extends AbstractTestITCase {
assertNotNull(scale);
final EdmAnnotation requiresTypeInScale = edm.getAnnotation(
scale.getFullQualifiedName(), edm.getTerm(new FullQualifiedName("Core.RequiresType")));
scale.getFullQualifiedName(), edm.getTerm(new FullQualifiedName("Core.RequiresType")));
assertNotNull(requiresTypeInScale);
assertEquals("Edm.Decimal", requiresTypeInScale.getExpression().asConstant().getValue().toString());
@ -140,6 +140,6 @@ public class MetadataTestITCase extends AbstractTestITCase {
final EdmTerm deleteRestrictions = edm.getTerm(new FullQualifiedName("Capabilities.DeleteRestrictions"));
assertNotNull(deleteRestrictions);
assertEquals(deleteRestrictions.getType().getFullQualifiedName(),
edm.getComplexType(new FullQualifiedName("Capabilities.DeleteRestrictionsType")).getFullQualifiedName());
edm.getComplexType(new FullQualifiedName("Capabilities.DeleteRestrictionsType")).getFullQualifiedName());
}
}

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -28,7 +28,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.ODataClientFactory;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@ -42,17 +42,17 @@ import org.apache.olingo.fit.CXFOAuth2HttpClientFactory;
public class OAuth2TestITCase extends AbstractTestITCase {
private static final URI OAUTH2_GRANT_SERVICE_URI =
URI.create("http://localhost:9080/stub/StaticService/oauth2/authorize");
URI.create("http://localhost:9080/stub/StaticService/oauth2/authorize");
private static final URI OAUTH2_TOKEN_SERVICE_URI =
URI.create("http://localhost:9080/stub/StaticService/oauth2/token");
URI.create("http://localhost:9080/stub/StaticService/oauth2/token");
private EdmEnabledODataClient _edmClient;
@BeforeClass
public static void enableOAuth2() {
client.getConfiguration().setHttpClientFactory(
new CXFOAuth2HttpClientFactory(OAUTH2_GRANT_SERVICE_URI, OAUTH2_TOKEN_SERVICE_URI));
new CXFOAuth2HttpClientFactory(OAUTH2_GRANT_SERVICE_URI, OAUTH2_TOKEN_SERVICE_URI));
}
@AfterClass
@ -64,7 +64,7 @@ public class OAuth2TestITCase extends AbstractTestITCase {
if (_edmClient == null) {
_edmClient = ODataClientFactory.getEdmEnabledClient(testOAuth2ServiceRootURL);
_edmClient.getConfiguration().setHttpClientFactory(
new CXFOAuth2HttpClientFactory(OAUTH2_GRANT_SERVICE_URI, OAUTH2_TOKEN_SERVICE_URI));
new CXFOAuth2HttpClientFactory(OAUTH2_GRANT_SERVICE_URI, OAUTH2_TOKEN_SERVICE_URI));
}
return _edmClient;
@ -72,18 +72,19 @@ public class OAuth2TestITCase extends AbstractTestITCase {
private void read(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder =
client.newURIBuilder(testOAuth2ServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
client.newURIBuilder(testOAuth2ServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(format);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
final String etag = res.getETag();
assertTrue(StringUtils.isNotBlank(etag));
final ODataEntity order = res.getBody();
final ClientEntity order = res.getBody();
assertEquals(etag, order.getETag());
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Order", order.getTypeName().toString());
assertEquals("Edm.Int32", order.getProperty("OrderID").getPrimitiveValue().getTypeName());

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -30,8 +30,8 @@ import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateR
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientComplexValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.EdmSchema;
@ -53,14 +53,14 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
}
private ODataEntity readRow(final ODataFormat format, final String uuid) {
private ClientEntity readRow(final ODataFormat format, final String uuid) {
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
return read(format, builder.build());
}
private void read(final ODataFormat format) {
ODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
ClientEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").getPrimitiveValue().getTypeKind());
assertEquals(EdmPrimitiveTypeKind.Guid, row.getProperty("Id").getPrimitiveValue().getTypeKind());
@ -81,7 +81,7 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
private void cud(final ODataFormat format) {
final Integer id = 1426;
ODataEntity rowIndex = getClient().getObjectFactory().newEntity(
ClientEntity rowIndex = getClient().getObjectFactory().newEntity(
new FullQualifiedName("Microsoft.Test.OData.Services.OpenTypesServiceV4.RowIndex"));
getClient().getBinder().add(rowIndex,
getClient().getObjectFactory().newPrimitiveProperty("Id",
@ -114,7 +114,7 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
getClient().getObjectFactory().newEnumProperty("aColor", getClient().getObjectFactory().
newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Blue")));
final ODataComplexValue contactDetails = getClient().getObjectFactory().newComplexValue(
final ClientComplexValue contactDetails = getClient().getObjectFactory().newComplexValue(
"Microsoft.Test.OData.Services.OpenTypesServiceV4.ContactDetails");
contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("FirstContacted",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildBinary("text".getBytes())));
@ -151,11 +151,11 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
getClient().getBinder().add(rowIndex,
getClient().getObjectFactory().newComplexProperty("aContact", contactDetails));
final ODataEntityCreateRequest<ODataEntity> createReq = getClient().getCUDRequestFactory().
final ODataEntityCreateRequest<ClientEntity> createReq = getClient().getCUDRequestFactory().
getEntityCreateRequest(getClient().newURIBuilder(testOpenTypeServiceRootURL).
appendEntitySetSegment("RowIndex").build(), rowIndex);
createReq.setFormat(format);
final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
assertEquals(201, createRes.getStatusCode());
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -27,15 +27,15 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
import org.apache.olingo.commons.api.domain.ODataComplexValue;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataEnumValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.client.api.communication.request.invoke.ClientNoContent;
import org.apache.olingo.commons.api.domain.ClientCollectionValue;
import org.apache.olingo.commons.api.domain.ClientComplexValue;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientEnumValue;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -44,31 +44,31 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
private void functionImports(final ODataFormat format) throws EdmPrimitiveTypeException {
// GetDefaultColor
final ODataInvokeRequest<ODataProperty> defaultColorReq = getClient().getInvokeRequestFactory().
final ODataInvokeRequest<ClientProperty> defaultColorReq = getClient().getInvokeRequestFactory().
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("GetDefaultColor").build(), ODataProperty.class);
appendOperationCallSegment("GetDefaultColor").build(), ClientProperty.class);
defaultColorReq.setFormat(format);
final ODataProperty defaultColor = defaultColorReq.execute().getBody();
final ClientProperty defaultColor = defaultColorReq.execute().getBody();
assertNotNull(defaultColor);
assertTrue(defaultColor.hasEnumValue());
assertEquals("Red", defaultColor.getEnumValue().getValue());
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", defaultColor.getEnumValue().getTypeName());
// GetPerson2
final ODataPrimitiveValue city = getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London");
final ClientPrimitiveValue city = getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London");
final ODataInvokeRequest<ODataEntity> person2Req = getClient().getInvokeRequestFactory().
final ODataInvokeRequest<ClientEntity> person2Req = getClient().getInvokeRequestFactory().
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("GetPerson2").build(), ODataEntity.class,
Collections.<String, ODataValue> singletonMap("city", city));
appendOperationCallSegment("GetPerson2").build(), ClientEntity.class,
Collections.<String, ClientValue> singletonMap("city", city));
person2Req.setFormat(format);
final ODataEntity person2 = person2Req.execute().getBody();
final ClientEntity person2 = person2Req.execute().getBody();
assertNotNull(person2);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString());
assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
// GetPerson
final ODataComplexValue address = getClient().getObjectFactory().
final ClientComplexValue address = getClient().getObjectFactory().
newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
address.add(client.getObjectFactory().newPrimitiveProperty("Street",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("1 Microsoft Way")));
@ -77,34 +77,34 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("98052")));
final ODataInvokeRequest<ODataEntity> personReq = getClient().getInvokeRequestFactory().
final ODataInvokeRequest<ClientEntity> personReq = getClient().getInvokeRequestFactory().
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("GetPerson").build(), ODataEntity.class,
Collections.<String, ODataValue> singletonMap("address", address));
appendOperationCallSegment("GetPerson").build(), ClientEntity.class,
Collections.<String, ClientValue> singletonMap("address", address));
personReq.setFormat(format);
final ODataEntity person = personReq.execute().getBody();
final ClientEntity person = personReq.execute().getBody();
assertNotNull(person);
assertEquals(person2, person);
// GetAllProducts
final ODataInvokeRequest<ODataEntitySet> productsReq = getClient().getInvokeRequestFactory()
final ODataInvokeRequest<ClientEntitySet> productsReq = getClient().getInvokeRequestFactory()
.getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("GetAllProducts").build(), ODataEntitySet.class);
appendOperationCallSegment("GetAllProducts").build(), ClientEntitySet.class);
productsReq.setFormat(format);
final ODataEntitySet products = productsReq.execute().getBody();
final ClientEntitySet products = productsReq.execute().getBody();
assertNotNull(products);
assertEquals(5, products.getEntities().size());
// GetProductsByAccessLevel
final ODataEnumValue accessLevel = getClient().getObjectFactory().
final ClientEnumValue accessLevel = getClient().getObjectFactory().
newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "None");
final ODataInvokeRequest<ODataProperty> prodByALReq = getClient().getInvokeRequestFactory().
final ODataInvokeRequest<ClientProperty> prodByALReq = getClient().getInvokeRequestFactory().
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("GetProductsByAccessLevel").build(), ODataProperty.class,
Collections.<String, ODataValue> singletonMap("accessLevel", accessLevel));
appendOperationCallSegment("GetProductsByAccessLevel").build(), ClientProperty.class,
Collections.<String, ClientValue> singletonMap("accessLevel", accessLevel));
prodByALReq.setFormat(format);
final ODataProperty prodByAL = prodByALReq.execute().getBody();
final ClientProperty prodByAL = prodByALReq.execute().getBody();
assertNotNull(prodByAL);
assertTrue(prodByAL.hasCollectionValue());
assertEquals(5, prodByAL.getCollectionValue().size());
@ -124,27 +124,27 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
@Test
public void edmEnabledFunctionImports() throws EdmPrimitiveTypeException {
// GetDefaultColor
final ODataInvokeRequest<ODataProperty> defaultColorReq = edmClient.getInvokeRequestFactory().
final ODataInvokeRequest<ClientProperty> defaultColorReq = edmClient.getInvokeRequestFactory().
getFunctionImportInvokeRequest("GetDefaultColor");
final ODataProperty defaultColor = defaultColorReq.execute().getBody();
final ClientProperty defaultColor = defaultColorReq.execute().getBody();
assertNotNull(defaultColor);
assertTrue(defaultColor.hasEnumValue());
assertEquals("Red", defaultColor.getEnumValue().getValue());
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", defaultColor.getEnumValue().getTypeName());
// GetPerson2
final ODataPrimitiveValue city =
final ClientPrimitiveValue city =
getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London");
final ODataInvokeRequest<ODataEntity> person2Req = edmClient.getInvokeRequestFactory().
final ODataInvokeRequest<ClientEntity> person2Req = edmClient.getInvokeRequestFactory().
getFunctionImportInvokeRequest(
"GetPerson2", Collections.<String, ODataValue> singletonMap("city", city));
final ODataEntity person2 = person2Req.execute().getBody();
"GetPerson2", Collections.<String, ClientValue> singletonMap("city", city));
final ClientEntity person2 = person2Req.execute().getBody();
assertNotNull(person2);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString());
assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
// GetPerson
final ODataComplexValue address = getClient().getObjectFactory().
final ClientComplexValue address = getClient().getObjectFactory().
newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
address.add(client.getObjectFactory().newPrimitiveProperty("Street",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("1 Microsoft Way")));
@ -153,29 +153,29 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("98052")));
final ODataInvokeRequest<ODataEntity> personReq = edmClient.getInvokeRequestFactory().
final ODataInvokeRequest<ClientEntity> personReq = edmClient.getInvokeRequestFactory().
getFunctionImportInvokeRequest(
"GetPerson", Collections.<String, ODataValue> singletonMap("address", address));
final ODataEntity person = personReq.execute().getBody();
"GetPerson", Collections.<String, ClientValue> singletonMap("address", address));
final ClientEntity person = personReq.execute().getBody();
assertNotNull(person);
assertEquals(person2, person);
// GetAllProducts
final ODataInvokeRequest<ODataEntitySet> productsReq = edmClient.getInvokeRequestFactory().
final ODataInvokeRequest<ClientEntitySet> productsReq = edmClient.getInvokeRequestFactory().
getFunctionImportInvokeRequest("GetAllProducts");
final ODataEntitySet products = productsReq.execute().getBody();
final ClientEntitySet products = productsReq.execute().getBody();
assertNotNull(products);
assertEquals(5, products.getEntities().size());
// GetProductsByAccessLevel
final ODataEnumValue accessLevel = getClient().getObjectFactory().
final ClientEnumValue accessLevel = getClient().getObjectFactory().
newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "None");
final ODataInvokeRequest<ODataProperty> prodByALReq = edmClient.getInvokeRequestFactory().
final ODataInvokeRequest<ClientProperty> prodByALReq = edmClient.getInvokeRequestFactory().
getFunctionImportInvokeRequest(
"GetProductsByAccessLevel",
Collections.<String, ODataValue> singletonMap("accessLevel", accessLevel));
final ODataProperty prodByAL = prodByALReq.execute().getBody();
Collections.<String, ClientValue> singletonMap("accessLevel", accessLevel));
final ClientProperty prodByAL = prodByALReq.execute().getBody();
assertNotNull(prodByAL);
assertTrue(prodByAL.hasCollectionValue());
assertEquals(5, prodByAL.getCollectionValue().size());
@ -184,17 +184,17 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
private void actionImports(final ODataFormat format) {
// Discount
final ODataPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
final ODataInvokeRequest<ODataNoContent> discountReq = getClient().getInvokeRequestFactory().
final ClientPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
final ODataInvokeRequest<ClientNoContent> discountReq = getClient().getInvokeRequestFactory().
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("Discount").build(), ODataNoContent.class,
Collections.<String, ODataValue> singletonMap("percentage", percentage));
appendOperationCallSegment("Discount").build(), ClientNoContent.class,
Collections.<String, ClientValue> singletonMap("percentage", percentage));
discountReq.setFormat(format);
final ODataNoContent discount = discountReq.execute().getBody();
final ClientNoContent discount = discountReq.execute().getBody();
assertNotNull(discount);
// ResetBossAddress
final ODataComplexValue address = getClient().getObjectFactory().
final ClientComplexValue address = getClient().getObjectFactory().
newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
address.add(client.getObjectFactory().newPrimitiveProperty("Street",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("Via Le Mani Dal Naso, 123")));
@ -203,12 +203,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010")));
final ODataInvokeRequest<ODataProperty> resetBossAddressReq = getClient().getInvokeRequestFactory().
final ODataInvokeRequest<ClientProperty> resetBossAddressReq = getClient().getInvokeRequestFactory().
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("ResetBossAddress").build(), ODataProperty.class,
Collections.<String, ODataValue> singletonMap("address", address));
appendOperationCallSegment("ResetBossAddress").build(), ClientProperty.class,
Collections.<String, ClientValue> singletonMap("address", address));
resetBossAddressReq.setFormat(format);
final ODataProperty resetBossAddress = resetBossAddressReq.execute().getBody();
final ClientProperty resetBossAddress = resetBossAddressReq.execute().getBody();
assertNotNull(resetBossAddress);
assertEquals(address, resetBossAddress.getComplexValue());
}
@ -226,15 +226,15 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
@Test
public void edmEnabledActionImports() {
// Discount
final ODataPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
final ODataInvokeRequest<ODataNoContent> discountReq = edmClient.getInvokeRequestFactory().
final ClientPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
final ODataInvokeRequest<ClientNoContent> discountReq = edmClient.getInvokeRequestFactory().
getActionImportInvokeRequest(
"Discount", Collections.<String, ODataValue> singletonMap("percentage", percentage));
final ODataNoContent discount = discountReq.execute().getBody();
"Discount", Collections.<String, ClientValue> singletonMap("percentage", percentage));
final ClientNoContent discount = discountReq.execute().getBody();
assertNotNull(discount);
// ResetBossAddress
final ODataComplexValue address = getClient().getObjectFactory().
final ClientComplexValue address = getClient().getObjectFactory().
newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
address.add(client.getObjectFactory().newPrimitiveProperty("Street",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("Via Le Mani Dal Naso, 123")));
@ -243,38 +243,38 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010")));
final ODataInvokeRequest<ODataProperty> resetBossAddressReq = edmClient.getInvokeRequestFactory().
final ODataInvokeRequest<ClientProperty> resetBossAddressReq = edmClient.getInvokeRequestFactory().
getActionImportInvokeRequest(
"ResetBossAddress", Collections.<String, ODataValue> singletonMap("address", address));
final ODataProperty resetBossAddress = resetBossAddressReq.execute().getBody();
"ResetBossAddress", Collections.<String, ClientValue> singletonMap("address", address));
final ClientProperty resetBossAddress = resetBossAddressReq.execute().getBody();
assertNotNull(resetBossAddress);
assertEquals(address.getTypeName(), resetBossAddress.getComplexValue().getTypeName());
}
private void bossEmails(final ODataFormat format) {
// ResetBossEmail
final ODataCollectionValue<org.apache.olingo.commons.api.domain.ODataValue> emails =
final ClientCollectionValue<ClientValue> emails =
getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)");
emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("first@olingo.apache.org"));
emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("second@olingo.apache.org"));
ODataInvokeRequest<ODataProperty> bossEmailsReq = getClient().getInvokeRequestFactory().
ODataInvokeRequest<ClientProperty> bossEmailsReq = getClient().getInvokeRequestFactory().
getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("ResetBossEmail").build(), ODataProperty.class,
Collections.<String, ODataValue> singletonMap("emails", emails));
appendOperationCallSegment("ResetBossEmail").build(), ClientProperty.class,
Collections.<String, ClientValue> singletonMap("emails", emails));
bossEmailsReq.setFormat(format);
final ODataProperty bossEmails = bossEmailsReq.execute().getBody();
final ClientProperty bossEmails = bossEmailsReq.execute().getBody();
assertNotNull(bossEmails);
assertTrue(bossEmails.hasCollectionValue());
assertEquals(2, bossEmails.getCollectionValue().size());
final Map<String, ODataValue> params = new LinkedHashMap<String, ODataValue>(2);
final Map<String, ClientValue> params = new LinkedHashMap<String, ClientValue>(2);
params.put("start", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(0));
params.put("count", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(100));
bossEmailsReq = getClient().getInvokeRequestFactory().getFunctionInvokeRequest(
getClient().newURIBuilder(testStaticServiceRootURL).
appendOperationCallSegment("GetBossEmails").build(), ODataProperty.class, params);
appendOperationCallSegment("GetBossEmails").build(), ClientProperty.class, params);
bossEmailsReq.setFormat(format);
final ODataProperty bossEmailsViaGET = bossEmailsReq.execute().getBody();
final ClientProperty bossEmailsViaGET = bossEmailsReq.execute().getBody();
assertNotNull(bossEmailsViaGET);
assertTrue(bossEmailsViaGET.hasCollectionValue());
assertEquals(2, bossEmailsViaGET.getCollectionValue().size());

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -34,9 +34,9 @@ import org.apache.olingo.client.api.communication.response.ODataEntityCreateResp
import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValuable;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValuable;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpMethod;
import org.junit.Test;
@ -46,15 +46,15 @@ public class PropertyTestITCase extends AbstractTestITCase {
private void _enum(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Products").appendKeySegment(5).appendPropertySegment("CoverColors");
final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
getPropertyRequest(uriBuilder.build());
req.setFormat(format);
final ODataProperty prop = req.execute().getBody();
final ClientProperty prop = req.execute().getBody();
assertNotNull(prop);
// cast to workaround JDK 6 bug, fixed in JDK 7
assertEquals("Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)",
((ODataValuable) prop).getValue().getTypeName());
((ClientValuable) prop).getValue().getTypeName());
}
@Test
@ -75,14 +75,14 @@ public class PropertyTestITCase extends AbstractTestITCase {
private void geospatial(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Home");
final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
getPropertyRequest(uriBuilder.build());
req.setFormat(format);
final ODataProperty prop = req.execute().getBody();
final ClientProperty prop = req.execute().getBody();
assertNotNull(prop);
// cast to workaround JDK 6 bug, fixed in JDK 7
assertEquals("Edm.GeographyPoint", ((ODataValuable) prop).getValue().getTypeName());
assertEquals("Edm.GeographyPoint", ((ClientValuable) prop).getValue().getTypeName());
}
@Test
@ -103,15 +103,15 @@ public class PropertyTestITCase extends AbstractTestITCase {
private void complex(final ODataClient client, final ODataFormat format) {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(2).appendPropertySegment("HomeAddress");
final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
getPropertyRequest(uriBuilder.build());
req.setFormat(format);
final ODataProperty prop = req.execute().getBody();
final ClientProperty prop = req.execute().getBody();
assertNotNull(prop);
// cast to workaround JDK 6 bug, fixed in JDK 7
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address",
((ODataValuable) prop).getValue().getTypeName());
((ClientValuable) prop).getValue().getTypeName());
}
@Test
@ -133,14 +133,14 @@ public class PropertyTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).appendPropertySegment("HomeAddress");
ODataPropertyRequest<ODataProperty> retrieveReq =
ODataPropertyRequest<ClientProperty> retrieveReq =
client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
retrieveReq.setFormat(format);
ODataRetrieveResponse<ODataProperty> retrieveRes = retrieveReq.execute();
ODataRetrieveResponse<ClientProperty> retrieveRes = retrieveReq.execute();
assertEquals(200, retrieveRes.getStatusCode());
ODataProperty homeAddress = client.getObjectFactory().newComplexProperty("HomeAddress",
ClientProperty homeAddress = client.getObjectFactory().newComplexProperty("HomeAddress",
client.getObjectFactory().newComplexValue(retrieveRes.getBody().getComplexValue().getTypeName()));
homeAddress.getComplexValue().add(client.getObjectFactory().
@ -176,17 +176,17 @@ public class PropertyTestITCase extends AbstractTestITCase {
@Test
public void createAndDelete() {
// 1. create
final ODataEntity category = client.getObjectFactory().newEntity(null);
final ClientEntity category = client.getObjectFactory().newEntity(null);
category.setId(client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Categories").appendKeySegment(1).build());
final URIBuilder createBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Products").appendKeySegment(0).appendNavigationSegment("Categories").
appendRefSegment();
final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().
final ODataEntityCreateRequest<ClientEntity> createReq = client.getCUDRequestFactory().
getEntityCreateRequest(createBuilder.build(), category);
final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute();
assertEquals(204, createRes.getStatusCode());
// 2. delete

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -28,9 +28,9 @@ import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataValuable;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientValuable;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -70,7 +70,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataPrimitiveValue property = req.execute().getBody();
final ClientPrimitiveValue property = req.execute().getBody();
assertEquals("2011-03-04T16:03:57Z", property.toString());
}
@ -80,7 +80,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataPrimitiveValue property = req.execute().getBody();
final ClientPrimitiveValue property = req.execute().getBody();
assertEquals("179", property.toString());
}
@ -90,7 +90,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataPrimitiveValue property = req.execute().getBody();
final ClientPrimitiveValue property = req.execute().getBody();
assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
+ "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=", property.toString());
}
@ -117,12 +117,12 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
public void retrieveCollectionPropertyValueTest() {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Numbers");
final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
final ODataPropertyRequest<ClientProperty> req = client.getRetrieveRequestFactory().
getPropertyRequest(uriBuilder.build());
req.setFormat(ODataFormat.XML);
final ODataProperty property = req.execute().getBody();
final ClientProperty property = req.execute().getBody();
// cast to workaround JDK 6 bug, fixed in JDK 7
assertTrue(((ODataValuable) property).getValue().isCollection());
assertTrue(((ClientValuable) property).getValue().isCollection());
assertEquals("555-555-5555", property.getCollectionValue().iterator().next().asPrimitive().toString());
}
@ -132,7 +132,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress");
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
req.setFormat(ODataFormat.TEXT_PLAIN);
final ODataPrimitiveValue property = req.execute().getBody();
final ClientPrimitiveValue property = req.execute().getBody();
assertTrue(StringUtils.isBlank(property.toString()));
}
}

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -23,9 +23,9 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySe
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.client.api.uri.QueryOption;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientInlineEntitySet;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -51,10 +51,11 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntity customer = req.execute().getBody();
assertTrue(customer.getNavigationLink("Orders") instanceof ODataInlineEntitySet);
final ClientEntity customer = req.execute().getBody();
assertTrue(customer.getNavigationLink("Orders") instanceof ClientInlineEntitySet);
}
@Test
@ -64,10 +65,11 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
expandWithOptions("Orders", Collections.<QueryOption, Object> singletonMap(
QueryOption.FILTER, getClient().getFilterFactory().gt("OrderID", 7).build()));
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntity customer = req.execute().getBody();
assertTrue(customer.getNavigationLink("Orders") instanceof ODataInlineEntitySet);
final ClientEntity customer = req.execute().getBody();
assertTrue(customer.getNavigationLink("Orders") instanceof ClientInlineEntitySet);
}
/**
@ -81,16 +83,16 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
appendEntitySetSegment("People").filter("(PersonID lt 3)");
// 1. check that filtered entity set looks as expected
ODataEntitySetRequest<ODataEntitySet> req =
ODataEntitySetRequest<ClientEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
ODataEntitySet feed = req.execute().getBody();
ClientEntitySet feed = req.execute().getBody();
assertNotNull(feed);
assertEquals(2, feed.getEntities().size());
// 2. extract PersonID values - sorted ASC by default
final List<Integer> former = new ArrayList<Integer>(2);
for (ODataEntity entity : feed.getEntities()) {
for (ClientEntity entity : feed.getEntities()) {
final Integer personID = entity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class);
assertTrue(personID < 3);
former.add(personID);
@ -105,7 +107,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
// 4. extract again VIN value - now they were required to be sorted DESC
final List<Integer> latter = new ArrayList<Integer>(2);
for (ODataEntity entity : feed.getEntities()) {
for (ClientEntity entity : feed.getEntities()) {
final Integer personID = entity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class);
assertTrue(personID < 3);
latter.add(personID);
@ -124,10 +126,11 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).format("json");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataFormat.ATOM);
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
assertNotNull(res);
assertTrue(res.getContentType().replaceAll(" ", "").
startsWith(ODataFormat.JSON.getContentType().toContentTypeString()));
@ -140,10 +143,10 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
// 1. check that filtered entity set looks as expected
final ODataEntitySetRequest<ODataEntitySet> req =
final ODataEntitySetRequest<ClientEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.skip(2).build());
final ODataEntitySet feed = req.execute().getBody();
final ClientEntitySet feed = req.execute().getBody();
assertEquals(3, feed.getEntities().size());
}
@ -154,10 +157,10 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
// 1. check that filtered entity set looks as expected
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
getEntitySetRequest(uriBuilder.top(2).build());
final ODataEntitySet feed = req.execute().getBody();
final ClientEntitySet feed = req.execute().getBody();
assertEquals(2, feed.getEntities().size());
}
@ -169,14 +172,14 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL);
uriBuilder.appendEntitySetSegment("People").skipToken("5");
final ODataEntitySetRequest<ODataEntitySet> req =
final ODataEntitySetRequest<ClientEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
final ODataEntitySet feed = req.execute().getBody();
final ClientEntitySet feed = req.execute().getBody();
assertNotNull(feed);
assertEquals(1, feed.getEntities().size());
for (ODataEntity entity : feed.getEntities()) {
for (ClientEntity entity : feed.getEntities()) {
assertTrue(entity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class) > 5);
}
}
@ -189,10 +192,10 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder =
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").count(true);
final ODataEntitySetRequest<ODataEntitySet> req =
final ODataEntitySetRequest<ClientEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
final ODataEntitySet feed = req.execute().getBody();
final ClientEntitySet feed = req.execute().getBody();
assertNotNull(feed);
assertEquals(Integer.valueOf(feed.getEntities().size()), feed.getCount());
}
@ -205,12 +208,13 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
appendEntitySetSegment("Customers").appendKeySegment(1).select("PersonID,Orders").expand("Orders");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntity customer = req.execute().getBody();
final ClientEntity customer = req.execute().getBody();
assertEquals(1, customer.getProperties().size());
assertEquals(1, customer.getNavigationLinks().size());
assertTrue((customer.getNavigationLinks().get(0) instanceof ODataInlineEntitySet));
assertTrue((customer.getNavigationLinks().get(0) instanceof ClientInlineEntitySet));
}
@Test
@ -219,9 +223,10 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
appendEntitySetSegment("relatedEntitySelect").appendEntitySetSegment("Customers").appendKeySegment(1).
expandWithSelect("Orders", "OrderID", "OrderDetails");
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataEntityRequest<ClientEntity> req =
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
final ODataRetrieveResponse<ODataEntity> res = req.execute();
final ODataRetrieveResponse<ClientEntity> res = req.execute();
assertEquals(200, res.getStatusCode());
}
@ -231,10 +236,10 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
appendEntitySetSegment("People").search(client.getSearchFactory().
or(client.getSearchFactory().literal("Bob"), client.getSearchFactory().literal("Jill")));
final ODataEntitySetRequest<ODataEntitySet> req =
final ODataEntitySetRequest<ClientEntitySet> req =
client.getRetrieveRequestFactory().getEntitySetRequest(builder.build());
final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
final ODataRetrieveResponse<ClientEntitySet> res = req.execute();
assertEquals(200, res.getStatusCode());
assertFalse(res.getBody().getEntities().isEmpty());
}

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -20,7 +20,7 @@ package org.apache.olingo.fit.v4;
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.domain.ClientServiceDocument;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.junit.Test;
@ -35,10 +35,10 @@ public class ServiceDocumentTestITCase extends AbstractTestITCase {
client.getRetrieveRequestFactory().getServiceDocumentRequest(testStaticServiceRootURL);
req.setFormat(format);
final ODataRetrieveResponse<ODataServiceDocument> res = req.execute();
final ODataRetrieveResponse<ClientServiceDocument> res = req.execute();
assertEquals(200, res.getStatusCode());
final ODataServiceDocument serviceDocument = res.getBody();
final ClientServiceDocument serviceDocument = res.getBody();
assertEquals(12, serviceDocument.getEntitySets().size());
assertEquals(6, serviceDocument.getSingletons().size());
assertEquals(6, serviceDocument.getFunctionImports().size());

View File

@ -1,18 +1,18 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
*
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@ -24,9 +24,9 @@ import org.apache.olingo.client.api.communication.request.cud.UpdateType;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataAnnotation;
import org.apache.olingo.commons.api.domain.ODataSingleton;
import org.apache.olingo.commons.api.domain.ODataValuable;
import org.apache.olingo.commons.api.domain.ClientAnnotation;
import org.apache.olingo.commons.api.domain.ClientSingleton;
import org.apache.olingo.commons.api.domain.ClientValuable;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
import org.apache.olingo.commons.api.format.ODataFormat;
@ -43,16 +43,16 @@ public class SingletonTestITCase extends AbstractTestITCase {
private void read(final ODataClient client, final ODataFormat format) throws EdmPrimitiveTypeException {
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
final ODataEntityRequest<ODataSingleton> singleton =
final ODataEntityRequest<ClientSingleton> singleton =
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
singleton.setFormat(format);
final ODataSingleton company = singleton.execute().getBody();
final ClientSingleton company = singleton.execute().getBody();
assertNotNull(company);
assertEquals(0, company.getProperty("CompanyID").getPrimitiveValue().toCastValue(Integer.class), 0);
// cast to workaround JDK 6 bug, fixed in JDK 7
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyCategory",
((ODataValuable) company.getProperty("CompanyCategory")).getValue().getTypeName());
((ClientValuable) company.getProperty("CompanyCategory")).getValue().getTypeName());
assertTrue(company.getProperty("CompanyCategory").hasEnumValue());
}
@ -75,15 +75,15 @@ public class SingletonTestITCase extends AbstractTestITCase {
throws EdmPrimitiveTypeException {
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss");
final ODataEntityRequest<ODataSingleton> singleton =
final ODataEntityRequest<ClientSingleton> singleton =
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
singleton.setFormat(format);
singleton.setPrefer(client.newPreferences().includeAnnotations("*"));
final ODataSingleton boss = singleton.execute().getBody();
final ClientSingleton boss = singleton.execute().getBody();
assertNotNull(boss);
assertFalse(boss.getAnnotations().isEmpty());
final ODataAnnotation isBoss = boss.getAnnotations().get(0);
final ClientAnnotation isBoss = boss.getAnnotations().get(0);
assertTrue(isBoss.getPrimitiveValue().toCastValue(Boolean.class));
}
@ -103,20 +103,21 @@ public class SingletonTestITCase extends AbstractTestITCase {
}
private void update(final ODataFormat format) throws EdmPrimitiveTypeException {
final ODataSingleton changes = getClient().getObjectFactory().newSingleton(
final ClientSingleton changes = getClient().getObjectFactory().newSingleton(
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Revenue",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt64(132520L)));
final URI uri = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company").build();
final ODataEntityUpdateRequest<ODataSingleton> req = getClient().getCUDRequestFactory().
final ODataEntityUpdateRequest<ClientSingleton> req = getClient().getCUDRequestFactory().
getSingletonUpdateRequest(uri, UpdateType.PATCH, changes);
req.setFormat(format);
final ODataEntityUpdateResponse<ODataSingleton> res = req.execute();
final ODataEntityUpdateResponse<ClientSingleton> res = req.execute();
assertEquals(204, res.getStatusCode());
final ODataSingleton updated = getClient().getRetrieveRequestFactory().getSingletonRequest(uri).execute().getBody();
final ClientSingleton updated =
getClient().getRetrieveRequestFactory().getSingletonRequest(uri).execute().getBody();
assertNotNull(updated);
assertEquals(132520, updated.getProperty("Revenue").getPrimitiveValue().toCastValue(Integer.class), 0);
}

View File

@ -32,7 +32,7 @@ import org.apache.olingo.client.api.serialization.ODataWriter;
import org.apache.olingo.client.api.uri.FilterFactory;
import org.apache.olingo.client.api.uri.SearchFactory;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.ClientObjectFactory;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataSerializer;
@ -65,7 +65,7 @@ public interface ODataClient {
SearchFactory getSearchFactory();
ODataObjectFactory getObjectFactory();
ClientObjectFactory getObjectFactory();
AsyncRequestFactory getAsyncRequestFactory();

View File

@ -21,12 +21,12 @@ package org.apache.olingo.client.api.communication;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.StatusLine;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.domain.ClientError;
/**
* Represents a client error in OData.
*
* @see ODataError
* @see ClientError
*/
public class ODataClientErrorException extends ODataRuntimeException {
@ -34,7 +34,7 @@ public class ODataClientErrorException extends ODataRuntimeException {
private final StatusLine statusLine;
private final ODataError error;
private final ClientError error;
/**
* Constructor.
@ -54,7 +54,7 @@ public class ODataClientErrorException extends ODataRuntimeException {
* @param statusLine request status info.
* @param error OData error to be wrapped.
*/
public ODataClientErrorException(final StatusLine statusLine, final ODataError error) {
public ODataClientErrorException(final StatusLine statusLine, final ClientError error) {
super(error == null
? statusLine.toString()
: (StringUtils.isBlank(error.getCode()) ? StringUtils.EMPTY : "(" + error.getCode() + ") ")
@ -78,7 +78,7 @@ public class ODataClientErrorException extends ODataRuntimeException {
*
* @return OData error.
*/
public ODataError getODataError() {
public ClientError getODataError() {
return error;
}
}

View File

@ -24,10 +24,10 @@ import java.net.URI;
import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest;
import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest;
import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataSingleton;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientSingleton;
public interface CUDRequestFactory {
@ -41,7 +41,7 @@ public interface CUDRequestFactory {
* @param entity entity to be created.
* @return new ODataEntityCreateRequest instance.
*/
<E extends ODataEntity> ODataEntityCreateRequest<E> getEntityCreateRequest(URI targetURI, E entity);
<E extends ClientEntity> ODataEntityCreateRequest<E> getEntityCreateRequest(URI targetURI, E entity);
/**
* Gets an update request object instance.
@ -52,7 +52,8 @@ public interface CUDRequestFactory {
* @param changes changes to be applied.
* @return new ODataEntityUpdateRequest instance.
*/
<E extends ODataEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(URI targetURI, UpdateType type, E changes);
<E extends ClientEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(URI targetURI,
UpdateType type, E changes);
/**
* Gets an update request object instance; uses entity's edit link as endpoint.
@ -62,7 +63,7 @@ public interface CUDRequestFactory {
* @param entity changes to be applied.
* @return new ODataEntityUpdateRequest instance.
*/
<E extends ODataEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(UpdateType type, E entity);
<E extends ClientEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(UpdateType type, E entity);
/**
* Gets a create request object instance.
@ -74,7 +75,7 @@ public interface CUDRequestFactory {
* @param value value to be created.
* @return new ODataValueUpdateRequest instance.
*/
ODataValueUpdateRequest getValueUpdateRequest(URI targetURI, UpdateType type, ODataPrimitiveValue value);
ODataValueUpdateRequest getValueUpdateRequest(URI targetURI, UpdateType type, ClientPrimitiveValue value);
/**
* Gets an update request object instance.
@ -85,7 +86,7 @@ public interface CUDRequestFactory {
* @param property value to be update.
* @return new ODataPropertyUpdateRequest instance.
*/
ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(URI targetURI, ODataProperty property);
ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(URI targetURI, ClientProperty property);
/**
* Gets an update request object instance.
@ -98,7 +99,7 @@ public interface CUDRequestFactory {
* @return new ODataPropertyUpdateRequest instance.
*/
ODataPropertyUpdateRequest
getPropertyComplexValueUpdateRequest(URI targetURI, UpdateType type, ODataProperty property);
getPropertyComplexValueUpdateRequest(URI targetURI, UpdateType type, ClientProperty property);
/**
* Gets an update request object instance.
@ -109,7 +110,7 @@ public interface CUDRequestFactory {
* @param property value to be update.
* @return new ODataPropertyUpdateRequest instance.
*/
ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(URI targetURI, ODataProperty property);
ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(URI targetURI, ClientProperty property);
/**
* Gets a delete request object instance.
@ -131,7 +132,7 @@ public interface CUDRequestFactory {
* @param media entity blob to be created.
* @return new ODataMediaEntityCreateRequest instance.
*/
<E extends ODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest(
<E extends ClientEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest(
URI targetURI, InputStream media);
/**
@ -155,14 +156,14 @@ public interface CUDRequestFactory {
* @param media entity blob to be updated.
* @return new ODataMediaEntityUpdateRequest instance.
*/
<E extends ODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
<E extends ClientEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
URI editURI, InputStream media);
ODataEntityUpdateRequest<ODataSingleton> getSingletonUpdateRequest(
URI targetURI, UpdateType type, ODataSingleton changes);
ODataEntityUpdateRequest<ClientSingleton> getSingletonUpdateRequest(
URI targetURI, UpdateType type, ClientSingleton changes);
ODataEntityUpdateRequest<ODataSingleton> getSingletonUpdateRequest(
UpdateType type, ODataSingleton entity);
ODataEntityUpdateRequest<ClientSingleton> getSingletonUpdateRequest(
UpdateType type, ClientSingleton entity);
/**
* A successful POST request to a navigation property's references collection adds a relationship to an existing

View File

@ -21,14 +21,14 @@ package org.apache.olingo.client.api.communication.request.cud;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* This interface describes an OData create request.
*
* @param <E> concrete ODataEntity implementation
*/
public interface ODataEntityCreateRequest<E extends ODataEntity>
public interface ODataEntityCreateRequest<E extends ClientEntity>
extends ODataBasicRequest<ODataEntityCreateResponse<E>>, ODataBatchableRequest {
//No additional methods needed for now.
}

View File

@ -21,14 +21,14 @@ package org.apache.olingo.client.api.communication.request.cud;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* This class implements an OData update request.
*
* @param <E> concrete ODataEntity implementation
*/
public interface ODataEntityUpdateRequest<E extends ODataEntity>
public interface ODataEntityUpdateRequest<E extends ClientEntity>
extends ODataBasicRequest<ODataEntityUpdateResponse<E>>, ODataBatchableRequest {
//No additional methods needed for now.
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.invoke;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ClientInvokeResult;
/**
* Marker class for invoke with no return type.
*/
public class ODataNoContent implements ODataInvokeResult {
public class ClientNoContent implements ClientInvokeResult {
//No additional methods needed for now.
}

View File

@ -21,8 +21,8 @@ package org.apache.olingo.client.api.communication.request.invoke;
import java.net.URI;
import java.util.Map;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientInvokeResult;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
@ -34,7 +34,7 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
* @param functionImportName operation to be invoked
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest(
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest(
String functionImportName);
/**
@ -45,8 +45,8 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
* @param parameters parameters to pass to operation import invocation
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest(
String functionImportName, Map<String, ODataValue> parameters);
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest(
String functionImportName, Map<String, ClientValue> parameters);
/**
* Gets an invoke request instance for the action import with the given name.
@ -55,7 +55,7 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
* @param actionImportName operation to be invoked
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest(
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest(
String actionImportName);
/**
@ -66,8 +66,8 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
* @param parameters parameters to pass to operation import invocation
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest(
String actionImportName, Map<String, ODataValue> parameters);
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest(
String actionImportName, Map<String, ClientValue> parameters);
/**
* Gets an invoke request instance for the function bound to given URI (no parameters).
@ -79,7 +79,7 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
* @param isBindingParameterCollection whether binding parameter is collection
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundFunctionInvokeRequest(
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getBoundFunctionInvokeRequest(
URI bindingParameterURI, FullQualifiedName functionName, FullQualifiedName bindingParameterTypeName,
Boolean isBindingParameterCollection);
@ -94,9 +94,9 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
* @param parameters parameters to pass to function invocation
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundFunctionInvokeRequest(
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getBoundFunctionInvokeRequest(
URI bindingParameterURI, FullQualifiedName functionName, FullQualifiedName bindingParameterTypeName,
Boolean isBindingParameterCollection, Map<String, ODataValue> parameters);
Boolean isBindingParameterCollection, Map<String, ClientValue> parameters);
/**
* Gets an invoke request instance for the action bound to given URI (no parameters).
@ -108,7 +108,7 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
* @param isBindingParameterCollection whether binding parameter is collection
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest(
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest(
URI bindingParameterURI, FullQualifiedName actionName, FullQualifiedName bindingParameterTypeName,
Boolean isBindingParameterCollection);
@ -123,8 +123,8 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory {
* @param parameters parameters to pass to function invocation
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest(
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest(
URI bindingParameterURI, FullQualifiedName actionName, FullQualifiedName bindingParameterTypeName,
Boolean isBindingParameterCollection, Map<String, ODataValue> parameters);
Boolean isBindingParameterCollection, Map<String, ClientValue> parameters);
}

View File

@ -21,8 +21,8 @@ package org.apache.olingo.client.api.communication.request.invoke;
import java.net.URI;
import java.util.Map;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientInvokeResult;
import org.apache.olingo.commons.api.domain.ClientValue;
import org.apache.olingo.commons.api.http.HttpMethod;
/**
@ -43,8 +43,8 @@ public interface InvokeRequestFactory {
* @param parameters parameters to pass to function invocation
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest(
HttpMethod method, URI uri, Class<RES> resultRef, Map<String, ODataValue> parameters);
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getInvokeRequest(
HttpMethod method, URI uri, Class<RES> resultRef, Map<String, ClientValue> parameters);
/**
* Gets an invoke request instance for the function bound to given URI (no parameters).
@ -54,7 +54,7 @@ public interface InvokeRequestFactory {
* @param resultRef reference Class for result
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionInvokeRequest(URI uri, Class<RES> resultRef);
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getFunctionInvokeRequest(URI uri, Class<RES> resultRef);
/**
* Gets an invoke request instance for the function bound to given URI (with parameters).
@ -65,8 +65,8 @@ public interface InvokeRequestFactory {
* @param parameters parameters to pass to function invocation
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionInvokeRequest(
URI uri, Class<RES> resultRef, Map<String, ODataValue> parameters);
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getFunctionInvokeRequest(
URI uri, Class<RES> resultRef, Map<String, ClientValue> parameters);
/**
* Gets an invoke request instance for the action bound to given URI (no parameters).
@ -76,7 +76,7 @@ public interface InvokeRequestFactory {
* @param resultRef reference Class for result
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionInvokeRequest(URI uri, Class<RES> resultRef);
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getActionInvokeRequest(URI uri, Class<RES> resultRef);
/**
* Gets an invoke request instance for the action bound to given URI (with parameters).
@ -87,6 +87,6 @@ public interface InvokeRequestFactory {
* @param parameters parameters to pass to action invocation
* @return new {@link ODataInvokeRequest} instance.
*/
<RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionInvokeRequest(
URI uri, Class<RES> resultRef, Map<String, ODataValue> parameters);
<RES extends ClientInvokeResult> ODataInvokeRequest<RES> getActionInvokeRequest(
URI uri, Class<RES> resultRef, Map<String, ClientValue> parameters);
}

View File

@ -22,15 +22,15 @@ import java.util.Map;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.commons.api.domain.ClientInvokeResult;
import org.apache.olingo.commons.api.domain.ClientValue;
/**
* This class implements an OData invoke operation request.
*
* @param <T> the actual invoke result
*/
public interface ODataInvokeRequest<T extends ODataInvokeResult>
public interface ODataInvokeRequest<T extends ClientInvokeResult>
extends ODataBasicRequest<ODataInvokeResponse<T>> {
/**
@ -38,5 +38,5 @@ public interface ODataInvokeRequest<T extends ODataInvokeResult>
*
* @param parameters operation parameters.
*/
void setParameters(Map<String, ODataValue> parameters);
void setParameters(Map<String, ClientValue> parameters);
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataDelta;
import org.apache.olingo.commons.api.domain.ClientDelta;
/**
* Describes an OData retrieve request returning a delta object.
*/
public interface ODataDeltaRequest extends ODataRetrieveRequest<ODataDelta> {
public interface ODataDeltaRequest extends ODataRetrieveRequest<ClientDelta> {
//No additional methods needed for now.
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* Describes an OData retrieve query request returning a single entity.
*/
public interface ODataEntityRequest<E extends ODataEntity> extends ODataRetrieveRequest<E> {
public interface ODataEntityRequest<E extends ClientEntity> extends ODataRetrieveRequest<E> {
//No additional methods needed for now.
}

View File

@ -19,13 +19,13 @@
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
/**
* This class implements an OData EntitySet query request.
*/
public interface ODataEntitySetIteratorRequest<ES extends ODataEntitySet, E extends ODataEntity>
public interface ODataEntitySetIteratorRequest<ES extends ClientEntitySet, E extends ClientEntity>
extends ODataRetrieveRequest<ODataEntitySetIterator<ES, E>> {
//No additional methods needed for now.
}

View File

@ -18,13 +18,13 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
/**
* This interface describes an OData EntitySet query request.
*
* @param <ES> concrete ODataEntitySet implementation
*/
public interface ODataEntitySetRequest<ES extends ODataEntitySet> extends ODataRetrieveRequest<ES> {
public interface ODataEntitySetRequest<ES extends ClientEntitySet> extends ODataRetrieveRequest<ES> {
//No additional methods needed for now.
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientProperty;
/**
* This class implements an OData entity property query request.
*/
public interface ODataPropertyRequest<T extends ODataProperty> extends ODataRetrieveRequest<T> {
public interface ODataPropertyRequest<T extends ClientProperty> extends ODataRetrieveRequest<T> {
//No additional methods needed for now.
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.domain.ClientServiceDocument;
/**
* This class implements an OData service document request.
*/
public interface ODataServiceDocumentRequest extends ODataRetrieveRequest<ODataServiceDocument> {
public interface ODataServiceDocumentRequest extends ODataRetrieveRequest<ClientServiceDocument> {
//No additional methods needed for now.
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
/**
* This class implements an OData entity property value query request.
*/
public interface ODataValueRequest extends ODataRetrieveRequest<ODataPrimitiveValue> {
public interface ODataValueRequest extends ODataRetrieveRequest<ClientPrimitiveValue> {
//No additional methods needed for now.
}

View File

@ -20,10 +20,10 @@ package org.apache.olingo.client.api.communication.request.retrieve;
import java.net.URI;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataSingleton;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientSingleton;
public interface RetrieveRequestFactory {
@ -63,7 +63,7 @@ public interface RetrieveRequestFactory {
* @param uri request URI.
* @return new {@link ODataEntitySetRequest} instance.
*/
ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(URI uri);
ODataEntitySetRequest<ClientEntitySet> getEntitySetRequest(URI uri);
/**
* Gets a uri request returning a set of one or more OData entities.
@ -74,7 +74,7 @@ public interface RetrieveRequestFactory {
* @param uri request URI.
* @return new {@link ODataEntitySetIteratorRequest} instance.
*/
ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(URI uri);
ODataEntitySetIteratorRequest<ClientEntitySet, ClientEntity> getEntitySetIteratorRequest(URI uri);
/**
* Gets a uri request returning a single OData entity.
@ -82,7 +82,7 @@ public interface RetrieveRequestFactory {
* @param uri request URI.
* @return new {@link ODataEntityRequest} instance.
*/
ODataEntityRequest<ODataEntity> getEntityRequest(URI uri);
ODataEntityRequest<ClientEntity> getEntityRequest(URI uri);
/**
* Gets a uri request returning a single OData entity property.
@ -90,7 +90,7 @@ public interface RetrieveRequestFactory {
* @param uri request URI.
* @return new {@link ODataPropertyRequest} instance.
*/
ODataPropertyRequest<ODataProperty> getPropertyRequest(URI uri);
ODataPropertyRequest<ClientProperty> getPropertyRequest(URI uri);
/**
* Gets a uri request returning a single OData entity property value.
@ -132,7 +132,7 @@ public interface RetrieveRequestFactory {
*/
ODataRawRequest getRawRequest(URI uri);
ODataEntityRequest<ODataSingleton> getSingletonRequest(URI uri);
ODataEntityRequest<ClientSingleton> getSingletonRequest(URI uri);
ODataDeltaRequest getDeltaRequest(URI uri);
}

View File

@ -20,14 +20,14 @@ package org.apache.olingo.client.api.communication.request.streamed;
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* Media entity payload object.
*
* @param <E> concrete ODataEntity implementation
*/
public interface MediaEntityCreateStreamManager<E extends ODataEntity>
public interface MediaEntityCreateStreamManager<E extends ClientEntity>
extends ODataPayloadManager<ODataMediaEntityCreateResponse<E>> {
//No additional methods needed for now.
}

View File

@ -20,14 +20,14 @@ package org.apache.olingo.client.api.communication.request.streamed;
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* Media entity payload object.
*
* @param <E> concrete ODataEntity implementation
*/
public interface MediaEntityUpdateStreamManager<E extends ODataEntity>
public interface MediaEntityUpdateStreamManager<E extends ClientEntity>
extends ODataPayloadManager<ODataMediaEntityUpdateResponse<E>> {
//No additional methods needed for now.
}

View File

@ -20,14 +20,14 @@ package org.apache.olingo.client.api.communication.request.streamed;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.
*
* @param <E> concrete ODataEntity implementation
*/
public interface ODataMediaEntityCreateRequest<E extends ODataEntity>
public interface ODataMediaEntityCreateRequest<E extends ClientEntity>
extends ODataStreamedEntityRequest<ODataMediaEntityCreateResponse<E>, MediaEntityCreateStreamManager<E>>,
ODataBatchableRequest{
//No additional methods needed for now.

View File

@ -20,14 +20,14 @@ package org.apache.olingo.client.api.communication.request.streamed;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* This class implements an OData Media Entity create request. Get instance by using ODataStreamedRequestFactory.
*
* @param <E> concrete ODataEntity implementation
*/
public interface ODataMediaEntityUpdateRequest<E extends ODataEntity>
public interface ODataMediaEntityUpdateRequest<E extends ClientEntity>
extends ODataStreamedEntityRequest<ODataMediaEntityUpdateResponse<E>, MediaEntityUpdateStreamManager<E>>,
ODataBatchableRequest {
//No additional methods needed for now.

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* This interface describes the response to an OData entity create request.
@ -26,7 +26,7 @@ import org.apache.olingo.commons.api.domain.ODataEntity;
* @param <E> concrete ODataEntity implementation
* @see org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest
*/
public interface ODataEntityCreateResponse<E extends ODataEntity> extends ODataResponse {
public interface ODataEntityCreateResponse<E extends ClientEntity> extends ODataResponse {
/**
* Gets created object.

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* This class implements the response to an OData update request.
@ -26,7 +26,7 @@ import org.apache.olingo.commons.api.domain.ODataEntity;
* @param <E> concrete ODataEntity implementation
* @see org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest
*/
public interface ODataEntityUpdateResponse<E extends ODataEntity> extends ODataResponse {
public interface ODataEntityUpdateResponse<E extends ClientEntity> extends ODataResponse {
/**
* Gets updated object.

View File

@ -18,14 +18,14 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ClientInvokeResult;
/**
* This class implements a response to a specific invoke request.
*
* @param <T> the actual invoke result
*/
public interface ODataInvokeResponse<T extends ODataInvokeResult> extends ODataResponse {
public interface ODataInvokeResponse<T extends ClientInvokeResult> extends ODataResponse {
/**
* Gets operation return value if exists.

View File

@ -18,14 +18,14 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* This class implements the response to an OData media entity create request.
*
* @param <E> concrete ODataEntity implementation
*/
public interface ODataMediaEntityCreateResponse<E extends ODataEntity> extends ODataResponse {
public interface ODataMediaEntityCreateResponse<E extends ClientEntity> extends ODataResponse {
/**
* Gets created object.

View File

@ -18,14 +18,14 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
/**
* This class implements the response to an Odata media entity update request.
*
* @param <E> concrete ODataEntity implementation
*/
public interface ODataMediaEntityUpdateResponse<E extends ODataEntity> extends ODataResponse {
public interface ODataMediaEntityUpdateResponse<E extends ClientEntity> extends ODataResponse {
/**
* Gets updated object.

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientProperty;
/**
* This class implements the response to an OData update entity property request.
@ -32,5 +32,5 @@ public interface ODataPropertyUpdateResponse extends ODataResponse {
*
* @return updated object.
*/
ODataProperty getBody();
ClientProperty getBody();
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
/**
* This class implements the response to an OData update entity property request.
@ -32,5 +32,5 @@ public interface ODataValueUpdateResponse extends ODataResponse {
*
* @return updated object.
*/
ODataPrimitiveValue getBody();
ClientPrimitiveValue getBody();
}

View File

@ -24,7 +24,7 @@ import java.util.List;
/**
* REST resource for an <tt>ODataServiceDocument</tt>.
*
* @see org.apache.olingo.commons.api.domain.ODataServiceDocument
* @see org.apache.olingo.commons.api.domain.ClientServiceDocument
*/
public interface ServiceDocument {

View File

@ -33,8 +33,8 @@ import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.slf4j.Logger;
@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
* @param <E> concrete ODataEntity implementation
* @param <ES> concrete ODataEntitySet implementation
*/
public class ODataEntitySetIterator<ES extends ODataEntitySet, E extends ODataEntity>
public class ODataEntitySetIterator<ES extends ClientEntitySet, E extends ClientEntity>
implements Iterator<E> {
/**

View File

@ -25,12 +25,12 @@ import org.apache.olingo.commons.api.data.EntityCollection;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataDelta;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.domain.ClientDelta;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientServiceDocument;
public interface ODataBinder {
@ -40,7 +40,7 @@ public interface ODataBinder {
* @param entitySet OData entity set.
* @return {@link EntityCollection} object.
*/
EntityCollection getEntitySet(ODataEntitySet entitySet);
EntityCollection getEntitySet(ClientEntitySet entitySet);
/**
* Gets an <tt>Entity</tt> from the given OData entity.
@ -48,7 +48,7 @@ public interface ODataBinder {
* @param entity OData entity.
* @return {@link Entity} object.
*/
Entity getEntity(ODataEntity entity);
Entity getEntity(ClientEntity entity);
/**
* Gets a <tt>Link</tt> from the given OData link.
@ -56,7 +56,7 @@ public interface ODataBinder {
* @param link OData link.
* @return <tt>Link</tt> object.
*/
Link getLink(ODataLink link);
Link getLink(ClientLink link);
/**
* Gets a <tt>Property</tt> from the given OData property.
@ -64,7 +64,7 @@ public interface ODataBinder {
* @param property OData property.
* @return <tt>Property</tt> object.
*/
Property getProperty(ODataProperty property);
Property getProperty(ClientProperty property);
/**
* Adds the given property to the given entity.
@ -73,7 +73,7 @@ public interface ODataBinder {
* @param property OData property.
* @return whether add was successful or not.
*/
boolean add(ODataEntity entity, ODataProperty property);
boolean add(ClientEntity entity, ClientProperty property);
/**
* Gets <tt>ODataServiceDocument</tt> from the given service document resource.
@ -81,31 +81,31 @@ public interface ODataBinder {
* @param resource service document resource.
* @return <tt>ODataServiceDocument</tt> object.
*/
ODataServiceDocument getODataServiceDocument(ServiceDocument resource);
ClientServiceDocument getODataServiceDocument(ServiceDocument resource);
/**
* Gets <tt>ODataEntitySet</tt> from the given entity set resource.
*
* @param resource entity set resource.
* @return {@link org.apache.olingo.commons.api.domain.ODataEntitySet} object.
* @return {@link ClientEntitySet} object.
*/
ODataEntitySet getODataEntitySet(ResWrap<EntityCollection> resource);
ClientEntitySet getODataEntitySet(ResWrap<EntityCollection> resource);
/**
* Gets <tt>ODataEntity</tt> from the given entity resource.
*
* @param resource entity resource.
* @return {@link org.apache.olingo.commons.api.domain.ODataEntity} object.
* @return {@link ClientEntity} object.
*/
ODataEntity getODataEntity(ResWrap<Entity> resource);
ClientEntity getODataEntity(ResWrap<Entity> resource);
/**
* Gets an <tt>ODataProperty</tt> from the given property resource.
*
* @param resource property resource.
* @return {@link org.apache.olingo.commons.api.domain.ODataProperty} object.
* @return {@link ClientProperty} object.
*/
ODataProperty getODataProperty(ResWrap<Property> resource);
ClientProperty getODataProperty(ResWrap<Property> resource);
ODataDelta getODataDelta(ResWrap<Delta> resource);
ClientDelta getODataDelta(ResWrap<Delta> resource);
}

View File

@ -22,11 +22,11 @@ import java.io.InputStream;
import java.util.Map;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientEntitySet;
import org.apache.olingo.commons.api.domain.ClientError;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientServiceDocument;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
import org.apache.olingo.commons.api.format.ODataFormat;
@ -65,7 +65,7 @@ public interface ODataReader {
* @return List of URIs.
* @throws ODataDeserializerException
*/
ODataServiceDocument readServiceDocument(InputStream input, ODataFormat format) throws ODataDeserializerException;
ClientServiceDocument readServiceDocument(InputStream input, ODataFormat format) throws ODataDeserializerException;
/**
* De-Serializes a stream into an OData entity set.
@ -75,7 +75,7 @@ public interface ODataReader {
* @return de-serialized entity set.
* @throws ODataDeserializerException
*/
ODataEntitySet readEntitySet(InputStream input, ODataFormat format) throws ODataDeserializerException;
ClientEntitySet readEntitySet(InputStream input, ODataFormat format) throws ODataDeserializerException;
/**
* Parses a stream taking care to de-serializes the first OData entity found.
@ -85,7 +85,7 @@ public interface ODataReader {
* @return entity de-serialized.
* @throws ODataDeserializerException
*/
ODataEntity readEntity(InputStream input, ODataFormat format) throws ODataDeserializerException;
ClientEntity readEntity(InputStream input, ODataFormat format) throws ODataDeserializerException;
/**
* Parses a stream taking care to de-serialize the first OData entity property found.
@ -95,7 +95,7 @@ public interface ODataReader {
* @return OData entity property de-serialized.
* @throws ODataDeserializerException
*/
ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
ClientProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
/**
* Parses a stream into an OData error.
@ -105,7 +105,7 @@ public interface ODataReader {
* @return OData error.
* @throws ODataDeserializerException
*/
ODataError readError(InputStream inputStream, ODataFormat format) throws ODataDeserializerException;
ClientError readError(InputStream inputStream, ODataFormat format) throws ODataDeserializerException;
/**
* Parses a stream into the object type specified by the given reference.

View File

@ -23,9 +23,9 @@ import java.net.URI;
import java.util.Collection;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientLink;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
@ -46,7 +46,7 @@ public interface ODataWriter {
* @return stream of serialized objects.
* @throws ODataSerializerException
*/
InputStream writeEntities(Collection<ODataEntity> entities, ODataFormat format)
InputStream writeEntities(Collection<ClientEntity> entities, ODataFormat format)
throws ODataSerializerException;
/**
@ -57,7 +57,7 @@ public interface ODataWriter {
* @return stream of serialized object.
* @throws ODataSerializerException
*/
InputStream writeEntity(ODataEntity entity, ODataFormat format)
InputStream writeEntity(ClientEntity entity, ODataFormat format)
throws ODataSerializerException;
/**
@ -68,7 +68,7 @@ public interface ODataWriter {
* @return stream of serialized object.
* @throws ODataSerializerException
*/
InputStream writeProperty(ODataProperty property, ODataFormat format)
InputStream writeProperty(ClientProperty property, ODataFormat format)
throws ODataSerializerException;
/**
@ -79,7 +79,7 @@ public interface ODataWriter {
* @return stream of serialized object.
* @throws ODataSerializerException
*/
InputStream writeLink(ODataLink link, ODataFormat format)
InputStream writeLink(ClientLink link, ODataFormat format)
throws ODataSerializerException;
/**

View File

@ -47,11 +47,11 @@ import org.apache.olingo.client.core.serialization.ODataReaderImpl;
import org.apache.olingo.client.core.serialization.ODataWriterImpl;
import org.apache.olingo.client.core.uri.FilterFactoryImpl;
import org.apache.olingo.client.core.uri.URIBuilderImpl;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.ClientObjectFactory;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataSerializer;
import org.apache.olingo.commons.core.domain.ODataObjectFactoryImpl;
import org.apache.olingo.commons.core.domain.ClientObjectFactoryImpl;
import org.apache.olingo.commons.core.serialization.AtomSerializer;
import org.apache.olingo.commons.core.serialization.JsonSerializer;
@ -65,7 +65,7 @@ public class ODataClientImpl implements ODataClient {
private final ODataBinder binder = new ODataBinderImpl(this);
private final ODataObjectFactory objectFactory = new ODataObjectFactoryImpl();
private final ClientObjectFactory objectFactory = new ClientObjectFactoryImpl();
private final AsyncRequestFactory asyncReqFact = new AsyncRequestFactoryImpl(this);
@ -147,7 +147,7 @@ public class ODataClientImpl implements ODataClient {
}
@Override
public ODataObjectFactory getObjectFactory() {
public ClientObjectFactory getObjectFactory() {
return objectFactory;
}

View File

@ -25,7 +25,7 @@ import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.ODataServerErrorException;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.domain.ClientError;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
import org.slf4j.Logger;
@ -35,8 +35,8 @@ public final class ODataErrorResponseChecker {
protected static final Logger LOG = LoggerFactory.getLogger(ODataErrorResponseChecker.class);
private static ODataError getGenericError(final int code, final String errorMsg) {
final ODataError error = new ODataError();
private static ClientError getGenericError(final int code, final String errorMsg) {
final ClientError error = new ClientError();
error.setCode(String.valueOf(code));
error.setMessage(errorMsg);
return error;
@ -53,7 +53,7 @@ public final class ODataErrorResponseChecker {
} else {
final ODataFormat format = accept.contains("xml") ? ODataFormat.XML : ODataFormat.JSON;
ODataError error;
ClientError error;
try {
error = odataClient.getReader().readError(entity, format);
} catch (final RuntimeException e) {

View File

@ -38,10 +38,10 @@ import org.apache.olingo.client.core.communication.request.streamed.ODataMediaEn
import org.apache.olingo.client.core.communication.request.streamed.ODataStreamUpdateRequestImpl;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ODataSingleton;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.domain.ClientPrimitiveValue;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.domain.ClientSingleton;
import org.apache.olingo.commons.api.http.HttpMethod;
public class CUDRequestFactoryImpl implements CUDRequestFactory {
@ -53,14 +53,14 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
}
@Override
public <E extends ODataEntity> ODataEntityCreateRequest<E> getEntityCreateRequest(
public <E extends ClientEntity> ODataEntityCreateRequest<E> getEntityCreateRequest(
final URI targetURI, final E entity) {
return new ODataEntityCreateRequestImpl<E>(client, targetURI, entity);
}
@Override
public <E extends ODataEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(
public <E extends ClientEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(
final URI targetURI, final UpdateType type, final E changes) {
final ODataEntityUpdateRequest<E> req;
@ -76,7 +76,7 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
}
@Override
public <E extends ODataEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(
public <E extends ClientEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(
final UpdateType type, final E entity) {
if (entity.getEditLink() == null) {
@ -97,7 +97,7 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
@Override
public ODataValueUpdateRequest getValueUpdateRequest(
final URI targetURI, final UpdateType type, final ODataPrimitiveValue value) {
final URI targetURI, final UpdateType type, final ClientPrimitiveValue value) {
final ODataValueUpdateRequest req;
@ -113,7 +113,7 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
@Override
public ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(
final URI targetURI, final ODataProperty property) {
final URI targetURI, final ClientProperty property) {
if (!property.hasPrimitiveValue()) {
throw new IllegalArgumentException("A primitive value is required");
@ -133,7 +133,7 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
@Override
public ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(
final URI targetURI, final UpdateType type, final ODataProperty property) {
final URI targetURI, final UpdateType type, final ClientProperty property) {
if (!property.hasComplexValue()) {
throw new IllegalArgumentException("A complex value is required");
@ -153,7 +153,7 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
@Override
public ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(
final URI targetURI, final ODataProperty property) {
final URI targetURI, final ClientProperty property) {
if (!property.hasCollectionValue()) {
throw new IllegalArgumentException("A collection value is required");
@ -186,7 +186,7 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
}
@Override
public <E extends ODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest(
public <E extends ClientEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest(
final URI targetURI, final InputStream media) {
return new ODataMediaEntityCreateRequestImpl<E>(client, targetURI, media);
@ -207,7 +207,7 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
}
@Override
public <E extends ODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
public <E extends ClientEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
final URI editURI, final InputStream media) {
final ODataMediaEntityUpdateRequest<E> req;
@ -223,15 +223,15 @@ public class CUDRequestFactoryImpl implements CUDRequestFactory {
}
@Override
public ODataEntityUpdateRequest<ODataSingleton> getSingletonUpdateRequest(
final UpdateType type, final ODataSingleton entity) {
public ODataEntityUpdateRequest<ClientSingleton> getSingletonUpdateRequest(
final UpdateType type, final ClientSingleton entity) {
return getEntityUpdateRequest(type, entity);
}
@Override
public ODataEntityUpdateRequest<ODataSingleton> getSingletonUpdateRequest(
final URI targetURI, final UpdateType type, final ODataSingleton changes) {
public ODataEntityUpdateRequest<ClientSingleton> getSingletonUpdateRequest(
final URI targetURI, final UpdateType type, final ClientSingleton changes) {
return getEntityUpdateRequest(targetURI, type, changes);
}

View File

@ -33,7 +33,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpMethod;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
@ -44,7 +44,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
*
* @param <E> concrete ODataEntity implementation
*/
public class ODataEntityCreateRequestImpl<E extends ODataEntity>
public class ODataEntityCreateRequestImpl<E extends ClientEntity>
extends AbstractODataBasicRequest<ODataEntityCreateResponse<E>>
implements ODataEntityCreateRequest<E> {

View File

@ -34,7 +34,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ClientEntity;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpMethod;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
@ -45,7 +45,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
*
* @param <E> concrete ODataEntity implementation
*/
public class ODataEntityUpdateRequestImpl<E extends ODataEntity>
public class ODataEntityUpdateRequestImpl<E extends ClientEntity>
extends AbstractODataBasicRequest<ODataEntityUpdateResponse<E>>
implements ODataEntityUpdateRequest<E> {

View File

@ -33,7 +33,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.ClientProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.http.HttpMethod;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
@ -48,7 +48,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
/**
* Value to be created.
*/
private final ODataProperty property;
private final ClientProperty property;
/**
* Constructor.
@ -59,7 +59,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
* @param property value to be created.
*/
ODataPropertyUpdateRequestImpl(final ODataClient odataClient,
final HttpMethod method, final URI targetURI, final ODataProperty property) {
final HttpMethod method, final URI targetURI, final ClientProperty property) {
super(odataClient, method, targetURI);
// set request body
@ -97,7 +97,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
*/
private class ODataPropertyUpdateResponseImpl extends AbstractODataResponse implements ODataPropertyUpdateResponse {
private ODataProperty resProperty = null;
private ClientProperty resProperty = null;
private ODataPropertyUpdateResponseImpl(final ODataClient odataClient, final HttpClient httpClient,
final HttpResponse res) {
@ -106,7 +106,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
}
@Override
public ODataProperty getBody() {
public ClientProperty getBody() {
if (resProperty == null) {
try {
final ResWrap<Property> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept())).

Some files were not shown because too many files have changed in this diff Show More