mirror of
https://github.com/apache/olingo-odata4.git
synced 2025-02-07 02:29:18 +00:00
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/olingo-odata4
This commit is contained in:
commit
156ae7ef66
@ -21,9 +21,10 @@ package org.apache.olingo.ext.proxy;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.olingo.client.api.CommonEdmEnabledODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.ext.proxy.api.PersistenceManager;
|
||||
import org.apache.olingo.ext.proxy.commons.EntityContainerInvocationHandler;
|
||||
import org.apache.olingo.ext.proxy.commons.NonTransactionalPersistenceManagerImpl;
|
||||
@ -47,7 +48,7 @@ public final class EntityContainerFactory<C extends CommonEdmEnabledODataClient<
|
||||
final C client, final boolean transactional) {
|
||||
|
||||
if (!FACTORY_PER_SERVICEROOT.containsKey(client.getServiceRoot())) {
|
||||
client.getConfiguration().setDefaultPubFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
final EntityContainerFactory<C> instance = new EntityContainerFactory<C>(client, transactional);
|
||||
FACTORY_PER_SERVICEROOT.put(client.getServiceRoot(), instance);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.communication.header.ODataPreferences;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
||||
@ -40,7 +41,7 @@ import org.apache.olingo.commons.api.domain.ODataLink;
|
||||
import org.apache.olingo.commons.api.domain.ODataLinkType;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.api.format.ODataMediaFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.ext.proxy.EntityContainerFactory;
|
||||
import org.apache.olingo.ext.proxy.api.PersistenceManager;
|
||||
import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty;
|
||||
@ -150,7 +151,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
|
||||
|
||||
final Set<EntityInvocationHandler> toBeLinked = new HashSet<EntityInvocationHandler>();
|
||||
for (Object proxy : type == ODataLinkType.ENTITY_SET_NAVIGATION
|
||||
? (Collection) property.getValue() : Collections.singleton(property.getValue())) {
|
||||
? (Collection<?>) property.getValue() : Collections.singleton(property.getValue())) {
|
||||
|
||||
final EntityInvocationHandler target = (EntityInvocationHandler) Proxy.getInvocationHandler(proxy);
|
||||
|
||||
@ -353,9 +354,9 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
|
||||
final ODataMediaEntityUpdateRequest<?> req =
|
||||
factory.getClient().getCUDRequestFactory().getMediaEntityUpdateRequest(uri, input);
|
||||
|
||||
req.setContentType(StringUtils.isBlank(handler.getEntity().getMediaContentType())
|
||||
? ODataMediaFormat.WILDCARD.toString()
|
||||
: ODataMediaFormat.fromFormat(handler.getEntity().getMediaContentType()).toString());
|
||||
if (StringUtils.isNotBlank(handler.getEntity().getMediaContentType())) {
|
||||
req.setContentType(ODataFormat.fromString(handler.getEntity().getMediaContentType()).toString());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(handler.getETag())) {
|
||||
req.setIfMatch(handler.getETag());
|
||||
|
@ -32,17 +32,17 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataProperty;
|
||||
import org.apache.olingo.commons.api.domain.ODataLinked;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.format.ODataMediaFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.ext.proxy.api.AbstractTerm;
|
||||
import org.apache.olingo.ext.proxy.api.Annotatable;
|
||||
import org.apache.olingo.ext.proxy.api.annotations.EntityType;
|
||||
@ -108,7 +108,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
|
||||
final Class<?> typeRef,
|
||||
final EntityContainerInvocationHandler containerHandler) {
|
||||
|
||||
super(typeRef, (ODataLinked) entity, containerHandler);
|
||||
super(typeRef, entity, containerHandler);
|
||||
|
||||
this.entityURI = entityURI;
|
||||
this.internal = entity;
|
||||
@ -320,13 +320,11 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
|
||||
&& typeRef.getAnnotation(EntityType.class).hasStream()
|
||||
&& contentSource != null) {
|
||||
|
||||
final String contentType =
|
||||
StringUtils.isBlank(getEntity().getMediaContentType()) ? "*/*" : getEntity().getMediaContentType();
|
||||
|
||||
final ODataMediaRequest retrieveReq = getClient().getRetrieveRequestFactory().
|
||||
getMediaEntityRequest(contentSource);
|
||||
retrieveReq.setFormat(ODataMediaFormat.fromFormat(contentType));
|
||||
|
||||
final ODataMediaRequest retrieveReq = getClient().getRetrieveRequestFactory()
|
||||
.getMediaEntityRequest(contentSource);
|
||||
if (StringUtils.isNotBlank(getEntity().getMediaContentType())) {
|
||||
retrieveReq.setFormat(ODataFormat.fromString(getEntity().getMediaContentType()));
|
||||
}
|
||||
this.stream = retrieveReq.execute().getBody();
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.tuple.ImmutableTriple;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
@ -48,7 +49,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.ext.proxy.api.AbstractEntityCollection;
|
||||
import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
|
||||
import org.apache.olingo.ext.proxy.api.AbstractSingleton;
|
||||
@ -141,7 +142,6 @@ class EntitySetInvocationHandler<
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
|
||||
if (isSelfMethod(method, args)) {
|
||||
return invokeSelfMethod(method, args);
|
||||
@ -183,7 +183,7 @@ class EntitySetInvocationHandler<
|
||||
public Long count() {
|
||||
final ODataValueRequest req = getClient().getRetrieveRequestFactory().
|
||||
getValueRequest(getClient().newURIBuilder(this.uri.toASCIIString()).count().build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
return Long.valueOf(req.execute().getBody().asPrimitive().toString());
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,13 @@ public class NonTransactionalPersistenceManagerImpl extends AbstractPersistenceM
|
||||
protected void doFlush(final PersistenceChanges changes, final TransactionItems items) {
|
||||
for (Map.Entry<ODataBatchableRequest, EntityInvocationHandler> entry : changes.getChanges().entrySet()) {
|
||||
try {
|
||||
final ODataResponse response = ((ODataBasicRequest<?, ?>) entry.getKey()).execute();
|
||||
final ODataResponse response = ((ODataBasicRequest<?>) entry.getKey()).execute();
|
||||
|
||||
if (response instanceof ODataEntityCreateResponse && response.getStatusCode() == 201) {
|
||||
entry.getValue().setEntity(((ODataEntityCreateResponse) response).getBody());
|
||||
entry.getValue().setEntity(((ODataEntityCreateResponse<?>) response).getBody());
|
||||
LOG.debug("Upgrade created object '{}'", entry.getValue());
|
||||
} else if (response instanceof ODataEntityUpdateResponse && response.getStatusCode() == 200) {
|
||||
entry.getValue().setEntity(((ODataEntityUpdateResponse) response).getBody());
|
||||
entry.getValue().setEntity(((ODataEntityUpdateResponse<?>) response).getBody());
|
||||
LOG.debug("Upgrade updated object '{}'", entry.getValue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -54,7 +54,8 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana
|
||||
protected void doFlush(final PersistenceChanges changes, final TransactionItems items) {
|
||||
final CommonODataBatchRequest request =
|
||||
factory.getClient().getBatchRequestFactory().getBatchRequest(factory.getClient().getServiceRoot());
|
||||
((ODataRequest) request).setAccept(factory.getClient().getConfiguration().getDefaultBatchAcceptFormat());
|
||||
String accept = factory.getClient().getConfiguration().getDefaultBatchAcceptFormat().toContentTypeString();
|
||||
((ODataRequest) request).setAccept(accept);
|
||||
|
||||
final BatchManager streamManager = (BatchManager) ((ODataStreamedRequest) request).payloadManager();
|
||||
|
||||
|
@ -123,6 +123,8 @@ public abstract class AbstractServices {
|
||||
private static final Pattern REF_PATTERN = Pattern.compile("([$]\\d+)");
|
||||
|
||||
protected static final String BOUNDARY = "batch_243234_25424_ef_892u748";
|
||||
protected static final String MULTIPART_MIXED = "multipart/mixed";//ContentType.MULTIPART_MIXED.toContentTypeString();
|
||||
protected static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
|
||||
|
||||
protected final ODataServiceVersion version;
|
||||
protected final Metadata metadata;
|
||||
@ -194,8 +196,8 @@ public abstract class AbstractServices {
|
||||
|
||||
@POST
|
||||
@Path("/$batch")
|
||||
@Consumes(ContentType.MULTIPART_MIXED)
|
||||
@Produces(ContentType.APPLICATION_OCTET_STREAM + ";boundary=" + BOUNDARY)
|
||||
@Consumes(MULTIPART_MIXED)
|
||||
@Produces(APPLICATION_OCTET_STREAM + ";boundary=" + BOUNDARY)
|
||||
public Response batch(
|
||||
@HeaderParam("Authorization") @DefaultValue(StringUtils.EMPTY) String authorization,
|
||||
@HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) String prefer,
|
||||
@ -611,7 +613,7 @@ public abstract class AbstractServices {
|
||||
final String entityKey;
|
||||
if (xml.isMediaContent(entitySetName)) {
|
||||
entry = new EntityImpl();
|
||||
entry.setMediaContentType(ContentType.WILDCARD);
|
||||
entry.setMediaContentType(ContentType.APPLICATION_OCTET_STREAM.toContentTypeString());
|
||||
entry.setType(entitySet.getType());
|
||||
|
||||
entityKey = xml.getDefaultEntryKey(entitySetName, entry);
|
||||
|
@ -30,7 +30,6 @@ import org.apache.olingo.commons.api.domain.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataProperty;
|
||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -79,14 +78,14 @@ public abstract class AbstractBaseTestITCase {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
StringWriter writer = new StringWriter();
|
||||
try {
|
||||
getClient().getSerializer(ODataPubFormat.ATOM).write(writer, getClient().getBinder().getEntity(entity));
|
||||
getClient().getSerializer(ODataFormat.ATOM).write(writer, getClient().getBinder().getEntity(entity));
|
||||
} catch (final ODataSerializerException e) {}
|
||||
writer.flush();
|
||||
LOG.debug(message + " (Atom)\n{}", writer.toString());
|
||||
|
||||
writer = new StringWriter();
|
||||
try {
|
||||
getClient().getSerializer(ODataPubFormat.JSON).write(writer, getClient().getBinder().getEntity(entity));
|
||||
getClient().getSerializer(ODataFormat.JSON).write(writer, getClient().getBinder().getEntity(entity));
|
||||
} catch (final ODataSerializerException e) {}
|
||||
writer.flush();
|
||||
LOG.debug(message + " (JSON)\n{}", writer.toString());
|
||||
|
@ -34,6 +34,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
||||
@ -49,7 +50,6 @@ import org.apache.olingo.client.api.http.HttpMethod;
|
||||
import org.apache.olingo.client.api.uri.v3.URIBuilder;
|
||||
import org.apache.olingo.client.api.v3.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
|
||||
@ -64,7 +64,8 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
@ -223,7 +224,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected ODataEntity getSampleCustomerInfo(final int id, final String sampleinfo) {
|
||||
protected ODataEntity getSampleCustomerInfo(final String sampleinfo) {
|
||||
final ODataEntity entity = getClient().getObjectFactory().newEntity(new FullQualifiedName(
|
||||
"Microsoft.Test.OData.Services.AstoriaDefaultService.CustomerInfo"));
|
||||
entity.setMediaEntity(true);
|
||||
@ -288,7 +289,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
if (withInlineInfo) {
|
||||
final ODataInlineEntity inlineInfo = getClient().getObjectFactory().newDeepInsertEntity(
|
||||
"Info",
|
||||
getSampleCustomerInfo(id, sampleName + "_Info"));
|
||||
getSampleCustomerInfo(sampleName + "_Info"));
|
||||
inlineInfo.getEntity().setMediaEntity(true);
|
||||
entity.addLink(inlineInfo);
|
||||
}
|
||||
@ -306,7 +307,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
}
|
||||
}
|
||||
|
||||
protected ODataEntity read(final ODataPubFormat format, final URI editLink) {
|
||||
protected ODataEntity read(final ODataFormat format, final URI editLink) {
|
||||
final ODataEntityRequest<ODataEntity> req = getClient().getRetrieveRequestFactory().
|
||||
getEntityRequest(editLink);
|
||||
req.setFormat(format);
|
||||
@ -316,7 +317,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
|
||||
assertNotNull(entity);
|
||||
|
||||
if (ODataPubFormat.JSON_FULL_METADATA == format || ODataPubFormat.ATOM == format) {
|
||||
if (ODataFormat.JSON_FULL_METADATA == format || ODataFormat.ATOM == format) {
|
||||
assertEquals(req.getURI(), entity.getEditLink());
|
||||
}
|
||||
|
||||
@ -325,7 +326,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
|
||||
protected ODataEntity createEntity(
|
||||
final String serviceRootURL,
|
||||
final ODataPubFormat format,
|
||||
final ODataFormat format,
|
||||
final ODataEntity original,
|
||||
final String entitySetName) {
|
||||
|
||||
@ -351,7 +352,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
}
|
||||
|
||||
protected ODataEntity compareEntities(final String serviceRootURL,
|
||||
final ODataPubFormat format,
|
||||
final ODataFormat format,
|
||||
final ODataEntity original,
|
||||
final int actualObjectId,
|
||||
final Collection<String> expands) {
|
||||
@ -388,7 +389,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
}
|
||||
|
||||
protected void cleanAfterCreate(
|
||||
final ODataPubFormat format,
|
||||
final ODataFormat format,
|
||||
final ODataEntity created,
|
||||
final boolean includeInline,
|
||||
final String baseUri) {
|
||||
@ -431,7 +432,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
getEntityRequest(link);
|
||||
// bug that needs to be fixed on the SampleService - cannot get entity not found with header
|
||||
// Accept: application/json;odata=minimalmetadata
|
||||
retrieveReq.setFormat(format == ODataPubFormat.JSON_FULL_METADATA ? ODataPubFormat.JSON : format);
|
||||
retrieveReq.setFormat(format == ODataFormat.JSON_FULL_METADATA ? ODataFormat.JSON : format);
|
||||
|
||||
Exception exception = null;
|
||||
try {
|
||||
@ -446,19 +447,19 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
}
|
||||
|
||||
protected void updateEntityDescription(
|
||||
final ODataPubFormat format, final ODataEntity changes, final UpdateType type) {
|
||||
final ODataFormat format, final ODataEntity changes, final UpdateType type) {
|
||||
|
||||
updateEntityDescription(format, changes, type, null);
|
||||
}
|
||||
|
||||
protected void updateEntityDescription(
|
||||
final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
|
||||
final ODataFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
|
||||
|
||||
updateEntityStringProperty("Description", format, changes, type, etag);
|
||||
}
|
||||
|
||||
protected void updateEntityStringProperty(final String propertyName,
|
||||
final ODataPubFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
|
||||
final ODataFormat format, final ODataEntity changes, final UpdateType type, final String etag) {
|
||||
|
||||
final URI editLink = changes.getEditLink();
|
||||
|
||||
@ -497,7 +498,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
}
|
||||
|
||||
protected void update(
|
||||
final UpdateType type, final ODataEntity changes, final ODataPubFormat format, final String etag) {
|
||||
final UpdateType type, final ODataEntity changes, final ODataFormat format, final String etag) {
|
||||
|
||||
final ODataEntityUpdateRequest<ODataEntity> req =
|
||||
getClient().getCUDRequestFactory().getEntityUpdateRequest(type, changes);
|
||||
|
@ -19,8 +19,8 @@
|
||||
package org.apache.olingo.fit.v3;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -28,6 +28,7 @@ import java.net.URI;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.olingo.client.api.ODataBatchConstants;
|
||||
import org.apache.olingo.client.api.communication.request.ODataPayloadManager;
|
||||
@ -56,8 +57,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import static org.apache.olingo.fit.v3.AbstractTestITCase.client;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BatchTestITCase extends AbstractTestITCase {
|
||||
@ -116,7 +116,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(
|
||||
targetURI.build(),
|
||||
getSampleCustomerProfile(100 + i, "Sample customer", false));
|
||||
createReq.setFormat(ODataPubFormat.JSON);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(
|
||||
targetURI.build(),
|
||||
getSampleCustomerProfile(105, "Sample customer", false));
|
||||
createReq.setFormat(ODataPubFormat.JSON);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
|
||||
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer");
|
||||
@ -133,7 +133,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(
|
||||
targetURI.build(),
|
||||
getSampleCustomerProfile(100 + i, "Sample customer", false));
|
||||
createReq.setFormat(ODataPubFormat.ATOM);
|
||||
createReq.setFormat(ODataFormat.ATOM);
|
||||
changeset.addRequest(createReq);
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
// create new request
|
||||
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataPubFormat.ATOM);
|
||||
queryReq.setFormat(ODataFormat.ATOM);
|
||||
|
||||
streamManager.addRequest(queryReq);
|
||||
// -------------------------------------------
|
||||
@ -340,9 +340,9 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
"Description",
|
||||
client.getObjectFactory().newPrimitiveValueBuilder().buildString("new description from batch")));
|
||||
|
||||
final ODataEntityUpdateRequest changeReq =
|
||||
final ODataEntityUpdateRequest<?> changeReq =
|
||||
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.MERGE, merge);
|
||||
changeReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
changeReq.setIfMatch(getETag(editLink));
|
||||
|
||||
changeset.addRequest(changeReq);
|
||||
@ -352,7 +352,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
final ODataEntity original = getSampleCustomerProfile(1000, "Sample customer", false);
|
||||
final ODataEntityCreateRequest<ODataEntity> createReq =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
|
||||
createReq.setFormat(ODataPubFormat.ATOM);
|
||||
createReq.setFormat(ODataFormat.ATOM);
|
||||
changeset.addRequest(createReq);
|
||||
|
||||
// Delete customer created above
|
||||
|
@ -18,14 +18,16 @@
|
||||
*/
|
||||
package org.apache.olingo.fit.v3;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
import org.apache.olingo.client.api.uri.CommonURIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CountTestITCase extends AbstractTestITCase {
|
||||
|
||||
@ -34,7 +36,7 @@ public class CountTestITCase extends AbstractTestITCase {
|
||||
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Customer").count();
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
try {
|
||||
final ODataValue value = req.execute().getBody();
|
||||
assertTrue(10 <= Integer.parseInt(value.toString()));
|
||||
@ -48,10 +50,10 @@ public class CountTestITCase extends AbstractTestITCase {
|
||||
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Customer").count();
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
req.setAccept("application/json;odata=fullmetadata");
|
||||
try {
|
||||
final ODataValue value = req.execute().getBody();
|
||||
req.execute().getBody();
|
||||
fail();
|
||||
} catch (ODataClientErrorException e) {
|
||||
assertEquals(415, e.getStatusLine().getStatusCode());
|
||||
|
@ -28,6 +28,7 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
||||
@ -48,8 +49,7 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -63,7 +63,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createAsAtom() {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final int id = 1;
|
||||
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
|
||||
|
||||
@ -75,7 +75,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createAsJSON() {
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final int id = 2;
|
||||
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
|
||||
|
||||
@ -87,7 +87,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createWithInlineAsAtom() {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final int id = 3;
|
||||
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
|
||||
|
||||
@ -101,7 +101,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
@Test
|
||||
public void createWithInlineAsJSON() {
|
||||
// this needs to be full, otherwise there is no mean to recognize links
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final int id = 4;
|
||||
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", true);
|
||||
|
||||
@ -114,12 +114,12 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createInlineWithoutLinkAsAtom() {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final int id = 5;
|
||||
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
|
||||
|
||||
original.addLink(client.getObjectFactory().newDeepInsertEntity(
|
||||
"Info", getSampleCustomerInfo(id, "Sample Customer_Info")));
|
||||
"Info", getSampleCustomerInfo("Sample Customer_Info")));
|
||||
|
||||
createEntity(getServiceRoot(), format, original, "Customer");
|
||||
final ODataEntity actual =
|
||||
@ -141,12 +141,12 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createInlineWithoutLinkAsJSON() {
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final int id = 6;
|
||||
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
|
||||
|
||||
original.addLink(client.getObjectFactory().newDeepInsertEntity(
|
||||
"Info", getSampleCustomerInfo(id, "Sample Customer_Info")));
|
||||
"Info", getSampleCustomerInfo("Sample Customer_Info")));
|
||||
|
||||
createEntity(getServiceRoot(), format, original, "Customer");
|
||||
final ODataEntity actual =
|
||||
@ -168,7 +168,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createWithNavigationAsAtom() {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final ODataEntity actual = createWithNavigationLink(format, 5);
|
||||
cleanAfterCreate(format, actual, false, getServiceRoot());
|
||||
}
|
||||
@ -176,14 +176,14 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
@Test
|
||||
public void createWithNavigationAsJSON() {
|
||||
// this needs to be full, otherwise there is no mean to recognize links
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final ODataEntity actual = createWithNavigationLink(format, 6);
|
||||
cleanAfterCreate(format, actual, false, getServiceRoot());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWithFeedNavigationAsAtom() throws EdmPrimitiveTypeException {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final ODataEntity actual = createWithFeedNavigationLink(format, 7);
|
||||
cleanAfterCreate(format, actual, false, getServiceRoot());
|
||||
}
|
||||
@ -191,14 +191,14 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
@Test
|
||||
public void createWithFeedNavigationAsJSON() throws EdmPrimitiveTypeException {
|
||||
// this needs to be full, otherwise there is no mean to recognize links
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final ODataEntity actual = createWithFeedNavigationLink(format, 8);
|
||||
cleanAfterCreate(format, actual, false, getServiceRoot());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWithBackNavigationAsAtom() throws EdmPrimitiveTypeException {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final ODataEntity actual = createWithBackNavigationLink(format, 9);
|
||||
cleanAfterCreate(format, actual, true, getServiceRoot());
|
||||
}
|
||||
@ -206,19 +206,19 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
@Test
|
||||
public void createWithBackNavigationAsJSON() throws EdmPrimitiveTypeException {
|
||||
// this needs to be full, otherwise there is no mean to recognize links
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final ODataEntity actual = createWithBackNavigationLink(format, 10);
|
||||
cleanAfterCreate(format, actual, true, getServiceRoot());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiKeyAsAtom() {
|
||||
multiKey(ODataPubFormat.ATOM);
|
||||
multiKey(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiKeyAsJSON() {
|
||||
multiKey(ODataPubFormat.JSON);
|
||||
multiKey(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -256,7 +256,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer");
|
||||
final ODataEntityCreateRequest<ODataEntity> createReq =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original);
|
||||
createReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
createReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
createReq.setContentType(ContentType.APPLICATION_ATOM_XML.getMimeType());
|
||||
createReq.setPrefer(client.newPreferences().returnContent());
|
||||
|
||||
@ -274,7 +274,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
}
|
||||
}
|
||||
|
||||
private ODataEntity createWithFeedNavigationLink(final ODataPubFormat format, final int id)
|
||||
private ODataEntity createWithFeedNavigationLink(final ODataFormat format, final int id)
|
||||
throws EdmPrimitiveTypeException {
|
||||
|
||||
final String sampleName = "Sample customer";
|
||||
@ -337,7 +337,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
return actual;
|
||||
}
|
||||
|
||||
private ODataEntity createWithNavigationLink(final ODataPubFormat format, final int id) {
|
||||
private ODataEntity createWithNavigationLink(final ODataFormat format, final int id) {
|
||||
final String sampleName = "Sample customer";
|
||||
|
||||
final ODataEntity original = getSampleCustomerProfile(id, sampleName, false);
|
||||
@ -374,7 +374,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
return actual;
|
||||
}
|
||||
|
||||
private ODataEntity createWithBackNavigationLink(final ODataPubFormat format, final int id)
|
||||
private ODataEntity createWithBackNavigationLink(final ODataFormat format, final int id)
|
||||
throws EdmPrimitiveTypeException {
|
||||
|
||||
final String sampleName = "Sample customer";
|
||||
@ -440,7 +440,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
return customer;
|
||||
}
|
||||
|
||||
private void multiKey(final ODataPubFormat format) {
|
||||
private void multiKey(final ODataFormat format) {
|
||||
final ODataEntity message = client.getObjectFactory().newEntity(new FullQualifiedName(
|
||||
"Microsoft.Test.OData.Services.AstoriaDefaultService.Message"));
|
||||
|
||||
|
@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
|
||||
@ -42,7 +43,7 @@ import org.apache.olingo.commons.api.domain.ODataLink;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -54,7 +55,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
return testStaticServiceRootURL;
|
||||
}
|
||||
|
||||
private void withInlineEntry(final ODataPubFormat format) {
|
||||
private void withInlineEntry(final ODataFormat format) {
|
||||
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Info");
|
||||
|
||||
@ -97,16 +98,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void withInlineEntryFromAtom() {
|
||||
withInlineEntry(ODataPubFormat.ATOM);
|
||||
withInlineEntry(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineEntryFromJSON() {
|
||||
// this needs to be full, otherwise there is no mean to recognize links
|
||||
withInlineEntry(ODataPubFormat.JSON_FULL_METADATA);
|
||||
withInlineEntry(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void withInlineFeed(final ODataPubFormat format) {
|
||||
private void withInlineFeed(final ODataFormat format) {
|
||||
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Orders");
|
||||
|
||||
@ -135,21 +136,21 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void withInlineFeedFromAtom() {
|
||||
withInlineFeed(ODataPubFormat.ATOM);
|
||||
withInlineFeed(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineFeedFromJSON() {
|
||||
// this needs to be full, otherwise there is no mean to recognize links
|
||||
withInlineFeed(ODataPubFormat.JSON_FULL_METADATA);
|
||||
withInlineFeed(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void rawRequest(final ODataPubFormat format) {
|
||||
private void rawRequest(final ODataFormat format) {
|
||||
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Car").appendKeySegment(16);
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.toString(client.getServiceVersion()));
|
||||
req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
@ -163,16 +164,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void rawRequestAsAtom() {
|
||||
rawRequest(ODataPubFormat.ATOM);
|
||||
rawRequest(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rawRequestAsJSON() {
|
||||
// this needs to be full, otherwise actions will not be provided
|
||||
rawRequest(ODataPubFormat.JSON_FULL_METADATA);
|
||||
rawRequest(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void multiKey(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void multiKey(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
|
||||
multiKey.put("FromUsername", "1");
|
||||
multiKey.put("MessageId", -10);
|
||||
@ -191,25 +192,25 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void multiKeyAsAtom() throws EdmPrimitiveTypeException {
|
||||
multiKey(ODataPubFormat.ATOM);
|
||||
multiKey(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiKeyAsJSON() throws EdmPrimitiveTypeException {
|
||||
multiKey(ODataPubFormat.JSON_FULL_METADATA);
|
||||
multiKey(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForETagAsAtom() {
|
||||
checkForETag(ODataPubFormat.ATOM);
|
||||
checkForETag(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForETagAsJSON() {
|
||||
checkForETag(ODataPubFormat.JSON_FULL_METADATA);
|
||||
checkForETag(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void checkForETag(final ODataPubFormat format) {
|
||||
private void checkForETag(final ODataFormat format) {
|
||||
final CommonURIBuilder<?> uriBuilder =
|
||||
client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Product").appendKeySegment(-10);
|
||||
|
||||
@ -231,14 +232,14 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Car");
|
||||
|
||||
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.JSON);
|
||||
req.setFormat(ODataFormat.JSON);
|
||||
|
||||
// this statement should cause an IllegalArgumentException bearing JsonParseException
|
||||
// since we are attempting to parse an EntitySet as if it was an Entity
|
||||
req.execute().getBody();
|
||||
}
|
||||
|
||||
private void geospatial(final ODataPubFormat format) {
|
||||
private void geospatial(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("AllGeoTypesSet").appendKeySegment(-10);
|
||||
|
||||
@ -251,11 +252,11 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void geospatialAsJSON() {
|
||||
geospatial(ODataPubFormat.JSON_FULL_METADATA);
|
||||
geospatial(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void geospatialAsAtom() {
|
||||
geospatial(ODataPubFormat.ATOM);
|
||||
geospatial(ODataFormat.ATOM);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
|
||||
@ -35,7 +36,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -49,55 +50,55 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void rawRequestAsAtom() throws IOException {
|
||||
rawRequest(ODataPubFormat.ATOM);
|
||||
rawRequest(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rawRequestAsJSON() throws IOException {
|
||||
rawRequest(ODataPubFormat.JSON);
|
||||
rawRequest(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithInlineCountAsJSON() throws IOException {
|
||||
readWithInlineCount(ODataPubFormat.JSON);
|
||||
readWithInlineCount(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithInlineCountAsAtom() throws IOException {
|
||||
readWithInlineCount(ODataPubFormat.ATOM);
|
||||
readWithInlineCount(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromAtom() {
|
||||
readODataEntitySetIterator(ODataPubFormat.ATOM);
|
||||
readODataEntitySetIterator(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromJSON() {
|
||||
readODataEntitySetIterator(ODataPubFormat.JSON);
|
||||
readODataEntitySetIterator(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromJSONFullMeta() {
|
||||
readODataEntitySetIterator(ODataPubFormat.JSON_FULL_METADATA);
|
||||
readODataEntitySetIterator(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromJSONNoMeta() {
|
||||
readODataEntitySetIterator(ODataPubFormat.JSON_NO_METADATA);
|
||||
readODataEntitySetIterator(ODataFormat.JSON_NO_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetWithNextFromAtom() {
|
||||
readEntitySetWithNextLink(ODataPubFormat.ATOM);
|
||||
readEntitySetWithNextLink(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetWithNextFromJSON() {
|
||||
readEntitySetWithNextLink(ODataPubFormat.JSON_FULL_METADATA);
|
||||
readEntitySetWithNextLink(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void readEntitySetWithNextLink(final ODataPubFormat format) {
|
||||
private void readEntitySetWithNextLink(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot());
|
||||
uriBuilder.appendEntitySetSegment("Customer");
|
||||
|
||||
@ -121,7 +122,7 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
assertEquals(expected, found);
|
||||
}
|
||||
|
||||
private void readODataEntitySetIterator(final ODataPubFormat format) {
|
||||
private void readODataEntitySetIterator(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot());
|
||||
uriBuilder.appendEntitySetSegment("Customer");
|
||||
|
||||
@ -144,12 +145,12 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
assertTrue(feedIterator.getNext().toASCIIString().endsWith("Customer?$skiptoken=-9"));
|
||||
}
|
||||
|
||||
private void readWithInlineCount(final ODataPubFormat format) {
|
||||
private void readWithInlineCount(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot());
|
||||
uriBuilder.appendEntitySetSegment("Product").inlineCount(URIBuilder.InlineCount.allpages);
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.toString(client.getServiceVersion()));
|
||||
req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
@ -158,12 +159,12 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
assertEquals(10, entitySet.getPayload().getCount());
|
||||
}
|
||||
|
||||
private void rawRequest(final ODataPubFormat format) {
|
||||
private void rawRequest(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot());
|
||||
uriBuilder.appendEntitySetSegment("Car");
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.toString(client.getServiceVersion()));
|
||||
req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
||||
@ -33,8 +34,7 @@ import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResp
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -48,7 +48,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void mergeAsAtom() {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final URI uri = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Product").appendKeySegment(-10).build();
|
||||
final String etag = getETag(uri);
|
||||
@ -59,7 +59,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void mergeAsJSON() {
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final URI uri = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Product").appendKeySegment(-10).build();
|
||||
final String etag = getETag(uri);
|
||||
@ -70,7 +70,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void patchAsAtom() {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final URI uri = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Product").appendKeySegment(-10).build();
|
||||
final String etag = getETag(uri);
|
||||
@ -81,7 +81,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void patchAsJSON() {
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final URI uri = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Product").appendKeySegment(-10).build();
|
||||
final String etag = getETag(uri);
|
||||
@ -92,7 +92,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void replaceAsAtom() {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final ODataEntity changes = read(format, client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Car").appendKeySegment(14).build());
|
||||
updateEntityDescription(format, changes, UpdateType.REPLACE);
|
||||
@ -100,7 +100,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void replaceAsJSON() {
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final ODataEntity changes = read(format, client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Car").appendKeySegment(14).build());
|
||||
updateEntityDescription(format, changes, UpdateType.REPLACE);
|
||||
@ -108,15 +108,15 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void patchLinkAsAtom() throws EdmPrimitiveTypeException {
|
||||
patchLink(ODataPubFormat.ATOM);
|
||||
patchLink(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patchLinkAsJSON() throws EdmPrimitiveTypeException {
|
||||
patchLink(ODataPubFormat.JSON_FULL_METADATA);
|
||||
patchLink(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
public void patchLink(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
public void patchLink(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
final URI uri = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Customer").appendKeySegment(-10).build();
|
||||
|
||||
@ -172,7 +172,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
// ---------------------------------------
|
||||
}
|
||||
|
||||
private ODataEntityUpdateRequest<ODataEntity> buildMultiKeyUpdateReq(final ODataPubFormat format)
|
||||
private ODataEntityUpdateRequest<ODataEntity> buildMultiKeyUpdateReq(final ODataFormat format)
|
||||
throws EdmPrimitiveTypeException {
|
||||
|
||||
final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
|
||||
@ -192,19 +192,19 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
return client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.MERGE, message);
|
||||
}
|
||||
|
||||
private void mergeMultiKey(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void mergeMultiKey(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
final ODataEntityUpdateResponse<ODataEntity> res = buildMultiKeyUpdateReq(format).execute();
|
||||
assertEquals(204, res.getStatusCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mergeMultiKeyAsAtom() throws EdmPrimitiveTypeException {
|
||||
mergeMultiKey(ODataPubFormat.ATOM);
|
||||
mergeMultiKey(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mergeMultiKeyAsJSON() throws EdmPrimitiveTypeException {
|
||||
mergeMultiKey(ODataPubFormat.JSON_FULL_METADATA);
|
||||
mergeMultiKey(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||
@ -41,7 +42,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -50,10 +51,15 @@ import org.junit.Test;
|
||||
public class ErrorTestITCase extends AbstractTestITCase {
|
||||
|
||||
private class ErrorGeneratingRequest
|
||||
extends AbstractODataBasicRequest<ODataEntityCreateResponse<ODataEntity>, ODataPubFormat> {
|
||||
extends AbstractODataBasicRequest<ODataEntityCreateResponse<ODataEntity>> {
|
||||
|
||||
public ErrorGeneratingRequest(final HttpMethod method, final URI uri) {
|
||||
super(client, ODataPubFormat.class, method, uri);
|
||||
super(client, method, uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,7 +89,7 @@ public class ErrorTestITCase extends AbstractTestITCase {
|
||||
}
|
||||
}
|
||||
|
||||
private void stacktraceError(final ODataPubFormat format) {
|
||||
private void stacktraceError(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL);
|
||||
uriBuilder.appendEntitySetSegment("Customer");
|
||||
|
||||
@ -102,15 +108,15 @@ public class ErrorTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void xmlStacktraceError() {
|
||||
stacktraceError(ODataPubFormat.ATOM);
|
||||
stacktraceError(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonStacktraceError() {
|
||||
stacktraceError(ODataPubFormat.JSON);
|
||||
stacktraceError(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void notfoundError(final ODataPubFormat format) {
|
||||
private void notfoundError(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL);
|
||||
uriBuilder.appendEntitySetSegment("Customer(154)");
|
||||
|
||||
@ -130,15 +136,15 @@ public class ErrorTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void xmlNotfoundError() {
|
||||
notfoundError(ODataPubFormat.ATOM);
|
||||
notfoundError(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonNotfoundError() {
|
||||
notfoundError(ODataPubFormat.JSON);
|
||||
notfoundError(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void instreamError(final ODataPubFormat format) {
|
||||
private void instreamError(final ODataFormat format) {
|
||||
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("InStreamErrorGetCustomer");
|
||||
final ODataInvokeRequest<ODataEntitySet> req =
|
||||
@ -152,11 +158,11 @@ public class ErrorTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void atomInstreamError() {
|
||||
instreamError(ODataPubFormat.ATOM);
|
||||
instreamError(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void jsonInstreamError() {
|
||||
instreamError(ODataPubFormat.JSON);
|
||||
instreamError(ODataFormat.JSON);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
|
||||
@ -46,12 +47,12 @@ import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class InvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void getWithNoParams(final ODataPubFormat format) {
|
||||
private void getWithNoParams(final ODataFormat format) {
|
||||
// 1. get primitive value property
|
||||
URIBuilder builder = getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("GetPrimitiveString");
|
||||
@ -83,15 +84,15 @@ public class InvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void getWithNoParamsAsAtom() {
|
||||
getWithNoParams(ODataPubFormat.ATOM);
|
||||
getWithNoParams(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWithNoParamsAsJSON() {
|
||||
getWithNoParams(ODataPubFormat.JSON);
|
||||
getWithNoParams(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void getWithParams(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void getWithParams(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
// 1. primitive result
|
||||
URIBuilder builder = getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendOperationCallSegment("GetArgumentPlusOne");
|
||||
@ -133,15 +134,15 @@ public class InvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void getWithParamsAsAtom() throws EdmPrimitiveTypeException {
|
||||
getWithParams(ODataPubFormat.ATOM);
|
||||
getWithParams(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWithParamsAsJSON() throws EdmPrimitiveTypeException {
|
||||
getWithParams(ODataPubFormat.JSON);
|
||||
getWithParams(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private ODataEntity createEmployee(final ODataPubFormat format) {
|
||||
private ODataEntity createEmployee(final ODataFormat format) {
|
||||
final ODataEntity employee = getClient().getObjectFactory().newEntity(new FullQualifiedName(
|
||||
"Microsoft.Test.OData.Services.AstoriaDefaultService.Employee"));
|
||||
|
||||
@ -169,7 +170,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
|
||||
return req.execute().getBody();
|
||||
}
|
||||
|
||||
private void deleteEmployee(final ODataPubFormat format, final Integer id) {
|
||||
private void deleteEmployee(final ODataFormat format, final Integer id) {
|
||||
final URIBuilder uriBuilder = getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Person").appendKeySegment(id);
|
||||
|
||||
@ -182,7 +183,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
|
||||
@Test
|
||||
public void boundPost() throws EdmPrimitiveTypeException {
|
||||
// 0. create an employee
|
||||
final ODataEntity created = createEmployee(ODataPubFormat.JSON_FULL_METADATA);
|
||||
final ODataEntity created = createEmployee(ODataFormat.JSON_FULL_METADATA);
|
||||
assertNotNull(created);
|
||||
final Integer createdId = created.getProperty("PersonId").getPrimitiveValue().toCastValue(Integer.class);
|
||||
assertNotNull(createdId);
|
||||
@ -192,7 +193,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
final ODataInvokeRequest<ODataNoContent> req = getClient().getInvokeRequestFactory().
|
||||
getActionInvokeRequest(operation.getTarget(), ODataNoContent.class);
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
final ODataInvokeResponse<ODataNoContent> res = req.execute();
|
||||
assertNotNull(res);
|
||||
assertEquals(204, res.getStatusCode());
|
||||
@ -202,13 +203,13 @@ public class InvokeTestITCase extends AbstractTestITCase {
|
||||
appendEntitySetSegment("Person").appendKeySegment(createdId);
|
||||
final ODataEntityRequest<ODataEntity> retrieveRes =
|
||||
getClient().getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
retrieveRes.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
retrieveRes.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
final ODataEntity read = retrieveRes.execute().getBody();
|
||||
assertEquals("0", read.getProperty("Salary").getPrimitiveValue().toString());
|
||||
assertTrue(read.getProperty("Title").getPrimitiveValue().toString().endsWith("[Sacked]"));
|
||||
|
||||
// 3. remove the test employee
|
||||
deleteEmployee(ODataPubFormat.JSON_FULL_METADATA, createdId);
|
||||
deleteEmployee(ODataFormat.JSON_FULL_METADATA, createdId);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -26,7 +26,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.v3.URIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -38,7 +38,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||
client.getConfiguration().setKeyAsSegment(true);
|
||||
}
|
||||
|
||||
private void read(final ODataPubFormat format) {
|
||||
private void read(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL).
|
||||
appendEntitySetSegment("Customer").appendKeySegment(-10);
|
||||
|
||||
@ -55,17 +55,17 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void fromAtom() {
|
||||
read(ODataPubFormat.ATOM);
|
||||
read(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromJSON() {
|
||||
read(ODataPubFormat.JSON_FULL_METADATA);
|
||||
read(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createODataEntityAsAtom() {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final int id = 1;
|
||||
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
|
||||
|
||||
@ -77,7 +77,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createODataEntityAsJSON() {
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final int id = 2;
|
||||
final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false);
|
||||
|
||||
@ -89,7 +89,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void replaceODataEntityAsAtom() {
|
||||
final ODataPubFormat format = ODataPubFormat.ATOM;
|
||||
final ODataFormat format = ODataFormat.ATOM;
|
||||
final ODataEntity changes = read(format, client.newURIBuilder(testKeyAsSegmentServiceRootURL).
|
||||
appendEntitySetSegment("Car").appendKeySegment(14).build());
|
||||
updateEntityDescription(format, changes, UpdateType.REPLACE);
|
||||
@ -97,7 +97,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void replaceODataEntityAsJSON() {
|
||||
final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA;
|
||||
final ODataFormat format = ODataFormat.JSON_FULL_METADATA;
|
||||
final ODataEntity changes = read(format, client.newURIBuilder(testKeyAsSegmentServiceRootURL).
|
||||
appendEntitySetSegment("Car").appendKeySegment(14).build());
|
||||
updateEntityDescription(format, changes, UpdateType.REPLACE);
|
||||
|
@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
|
||||
@ -39,8 +40,7 @@ import org.apache.olingo.client.api.communication.response.ODataStreamUpdateResp
|
||||
import org.apache.olingo.client.api.uri.v3.URIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
|
||||
import org.apache.olingo.commons.api.format.ODataMediaFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
@ -51,7 +51,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
appendEntitySetSegment("Car").appendKeySegment(12);
|
||||
|
||||
final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
|
||||
retrieveReq.setFormat(ODataMediaFormat.WILDCARD);
|
||||
retrieveReq.setAccept("*/*");
|
||||
|
||||
final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute();
|
||||
assertEquals(200, retrieveRes.getStatusCode());
|
||||
@ -66,7 +66,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(12);
|
||||
|
||||
final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
|
||||
retrieveReq.setFormat(ODataMediaFormat.APPLICATION_XML);
|
||||
retrieveReq.setFormat(ODataFormat.APPLICATION_XML);
|
||||
|
||||
retrieveReq.execute();
|
||||
}
|
||||
@ -77,12 +77,12 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(12);
|
||||
|
||||
final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build());
|
||||
retrieveReq.setFormat(ODataMediaFormat.APPLICATION_JSON);
|
||||
retrieveReq.setFormat(ODataFormat.APPLICATION_JSON);
|
||||
|
||||
retrieveReq.execute();
|
||||
}
|
||||
|
||||
private void updateMediaEntity(final ODataPubFormat format, final int id) throws Exception {
|
||||
private void updateMediaEntity(final ODataFormat format, final int id) throws Exception {
|
||||
final URIBuilder builder =
|
||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(id);
|
||||
|
||||
@ -106,15 +106,15 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void updateMediaEntityAsAtom() throws Exception {
|
||||
updateMediaEntity(ODataPubFormat.ATOM, 14);
|
||||
updateMediaEntity(ODataFormat.ATOM, 14);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateMediaEntityAsJson() throws Exception {
|
||||
updateMediaEntity(ODataPubFormat.JSON, 15);
|
||||
updateMediaEntity(ODataFormat.JSON, 15);
|
||||
}
|
||||
|
||||
private void createMediaEntity(final ODataPubFormat format, final InputStream input) throws Exception {
|
||||
private void createMediaEntity(final ODataFormat format, final InputStream input) throws Exception {
|
||||
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car");
|
||||
|
||||
final ODataMediaEntityCreateRequest<ODataEntity> createReq =
|
||||
@ -148,17 +148,17 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createMediaEntityAsAtom() throws Exception {
|
||||
createMediaEntity(ODataPubFormat.ATOM, IOUtils.toInputStream("buffered stream sample"));
|
||||
createMediaEntity(ODataFormat.ATOM, IOUtils.toInputStream("buffered stream sample"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createMediaEntityAsJson() throws Exception {
|
||||
createMediaEntity(ODataPubFormat.JSON, IOUtils.toInputStream("buffered stream sample"));
|
||||
createMediaEntity(ODataFormat.JSON, IOUtils.toInputStream("buffered stream sample"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issue137() throws Exception {
|
||||
createMediaEntity(ODataPubFormat.JSON, this.getClass().getResourceAsStream("/sample.png"));
|
||||
createMediaEntity(ODataFormat.JSON, this.getClass().getResourceAsStream("/sample.png"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
|
||||
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;
|
||||
@ -35,7 +36,7 @@ import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||
@ -52,13 +53,13 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||
assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
|
||||
}
|
||||
|
||||
private ODataEntity readRow(final ODataPubFormat format, final String uuid) {
|
||||
private ODataEntity 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 ODataPubFormat format) {
|
||||
private void read(final ODataFormat format) {
|
||||
ODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
|
||||
assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").getPrimitiveValue().getTypeKind());
|
||||
assertEquals(EdmPrimitiveTypeKind.Guid, row.getProperty("Id").getPrimitiveValue().getTypeKind());
|
||||
@ -69,15 +70,15 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readAsAtom() {
|
||||
read(ODataPubFormat.ATOM);
|
||||
read(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAsJSON() {
|
||||
read(ODataPubFormat.JSON_FULL_METADATA);
|
||||
read(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void cud(final ODataPubFormat format) {
|
||||
private void cud(final ODataFormat format) {
|
||||
final Integer id = 1426;
|
||||
|
||||
ODataEntity rowIndex = getClient().getObjectFactory().newEntity(
|
||||
@ -172,11 +173,11 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void cudAsAtom() {
|
||||
cud(ODataPubFormat.ATOM);
|
||||
cud(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cudAsJSON() {
|
||||
cud(ODataPubFormat.JSON_FULL_METADATA);
|
||||
cud(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
}
|
||||
|
@ -23,16 +23,16 @@ import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PrimitiveKeysTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void readEntity(final String entityType, final Object key, final ODataPubFormat format) {
|
||||
private void readEntity(final String entityType, final Object key, final ODataFormat format) {
|
||||
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(
|
||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment(entityType).
|
||||
appendKeySegment(key).
|
||||
@ -45,7 +45,7 @@ public class PrimitiveKeysTestITCase extends AbstractTestITCase {
|
||||
assertNotNull(entity.getProperty("Id"));
|
||||
}
|
||||
|
||||
private void readPrimitiveKeys(final ODataPubFormat format) {
|
||||
private void readPrimitiveKeys(final ODataFormat format) {
|
||||
readEntity("EdmBooleanSet", Boolean.TRUE, format);
|
||||
readEntity("EdmByteSet", 255, format);
|
||||
readEntity("EdmDecimalSet", new BigDecimal("79228162514264337593543950335"), format);
|
||||
@ -60,11 +60,11 @@ public class PrimitiveKeysTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readEntityAsAtom() {
|
||||
readPrimitiveKeys(ODataPubFormat.ATOM);
|
||||
readPrimitiveKeys(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readEntityAsJSON() {
|
||||
readPrimitiveKeys(ODataPubFormat.JSON_FULL_METADATA);
|
||||
readPrimitiveKeys(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
|
||||
@ -45,7 +46,6 @@ import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -59,7 +59,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void replacePropertyValue() throws Exception {
|
||||
updatePropertyValue(ODataValueFormat.TEXT, UpdateType.REPLACE);
|
||||
updatePropertyValue(ODataFormat.TEXT_PLAIN, UpdateType.REPLACE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -128,7 +128,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
||||
uriBuilder.appendEntitySetSegment("Customer").count();
|
||||
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
|
||||
final ODataRetrieveResponse<ODataPrimitiveValue> res = req.execute();
|
||||
assertEquals(200, res.getStatusCode());
|
||||
@ -159,8 +159,8 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
||||
execute();
|
||||
}
|
||||
|
||||
private void updatePropertyValue(final ODataValueFormat format, final UpdateType type)
|
||||
throws IOException, EdmPrimitiveTypeException {
|
||||
private void updatePropertyValue(final ODataFormat format, final UpdateType type)
|
||||
throws IOException, EdmPrimitiveTypeException {
|
||||
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()).
|
||||
appendEntitySetSegment("Customer").appendKeySegment(-9).
|
||||
@ -348,7 +348,7 @@ public class PropertyTestITCase extends AbstractTestITCase {
|
||||
appendEntitySetSegment("Customer").appendKeySegment(-10).appendPropertySegment("BackupContactInfo");
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.toString(client.getServiceVersion()));
|
||||
req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
@ -18,7 +18,11 @@
|
||||
*/
|
||||
package org.apache.olingo.fit.v3;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
||||
@ -26,8 +30,7 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
|
||||
import org.apache.olingo.client.api.uri.CommonURIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
import static org.junit.Assert.*;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
@ -37,7 +40,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataValue value = req.execute().getBody();
|
||||
assertNotNull(value);
|
||||
assertEquals(-10, Integer.parseInt(value.toString()));
|
||||
@ -48,7 +51,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataValue value = req.execute().getBody();
|
||||
assertNotNull(value);
|
||||
assertEquals(-10, Integer.parseInt(value.toString()));
|
||||
@ -59,7 +62,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Description");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataValue value = req.execute().getBody();
|
||||
assertNotNull(value);
|
||||
assertEquals("expdybhclurfobuyvzmhkgrnrajhamqmkhqpmiypittnp", value.toString());
|
||||
@ -71,7 +74,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment(
|
||||
"NestedComplexConcurrency/ModifiedDate");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataValue value = req.execute().getBody();
|
||||
assertNotNull(value);
|
||||
assertEquals("7866-11-16T22:25:52.747755+01:00", value.toString());
|
||||
@ -82,7 +85,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Dimensions/Height");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataValue value = req.execute().getBody();
|
||||
assertNotNull(value);
|
||||
assertEquals("-79228162514264337593543950335", value.toString());
|
||||
@ -111,11 +114,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
req.setAccept("application/atom+xml");
|
||||
ODataRetrieveResponse<ODataEntity> res = req.execute();
|
||||
assertEquals(200, res.getStatusCode());
|
||||
ODataEntity entitySet = res.getBody();
|
||||
assertNotNull(entitySet);
|
||||
assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
|
||||
+ "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=",
|
||||
entitySet.getProperties().get(0).getValue().toString());
|
||||
res.getBody();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ -126,11 +125,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
req.setAccept("application/xml");
|
||||
ODataRetrieveResponse<ODataEntity> res = req.execute();
|
||||
assertEquals(200, res.getStatusCode());
|
||||
ODataEntity entitySet = res.getBody();
|
||||
assertNotNull(entitySet);
|
||||
assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
|
||||
+ "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=",
|
||||
entitySet.getProperties().get(0).getValue().toString());
|
||||
res.getBody();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -139,7 +134,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment(
|
||||
"ComplexConcurrency/QueriedDateTime");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataValue value = req.execute().getBody();
|
||||
if (value.isPrimitive()) {
|
||||
assertNotNull(value);
|
||||
|
@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
@ -34,7 +35,7 @@ import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -44,8 +45,6 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
|
||||
|
||||
/**
|
||||
* Test <tt>$expand</tt>.
|
||||
*
|
||||
* @see EntityRetrieveTest#readODataEntityWithInline(org.apache.olingo.commons.api.format.ODataPubFormat)
|
||||
*/
|
||||
public void expand() {
|
||||
// empty
|
||||
@ -102,18 +101,16 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
|
||||
appendEntitySetSegment("Customer").appendKeySegment(-10).format("json");
|
||||
|
||||
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.ATOM);
|
||||
req.setFormat(ODataFormat.ATOM);
|
||||
|
||||
final ODataRetrieveResponse<ODataEntity> res = req.execute();
|
||||
assertNotNull(res);
|
||||
assertTrue(res.getContentType().replaceAll(" ", "").
|
||||
startsWith(ODataPubFormat.JSON.toString(client.getServiceVersion())));
|
||||
startsWith(ODataFormat.JSON.getContentType(client.getServiceVersion()).toContentTypeString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test <tt>$skip</tt>.
|
||||
*
|
||||
* @see FeedTest#readFeedWithNextLink(org.apache.olingo.commons.api.format.ODataPubFormat)
|
||||
*/
|
||||
public void skip() {
|
||||
// empty
|
||||
@ -121,8 +118,6 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
|
||||
|
||||
/**
|
||||
* Test <tt>$top</tt>.
|
||||
*
|
||||
* @see FeedTest#readFeed(org.apache.olingo.commons.api.format.ODataPubFormat)
|
||||
*/
|
||||
public void top() {
|
||||
// empty
|
||||
@ -157,7 +152,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
|
||||
|
||||
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
|
||||
getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.ATOM);
|
||||
req.setFormat(ODataFormat.ATOM);
|
||||
final ODataEntitySet feed = req.execute().getBody();
|
||||
assertNotNull(feed);
|
||||
assertEquals(feed.getEntities().size(), feed.getCount());
|
||||
|
@ -18,8 +18,12 @@
|
||||
*/
|
||||
package org.apache.olingo.fit.v4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
@ -28,7 +32,6 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
|
||||
import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
|
||||
import org.apache.olingo.client.api.v4.ODataClient;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.apache.olingo.commons.api.domain.ODataCollectionValue;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
|
||||
@ -36,10 +39,9 @@ import org.apache.olingo.commons.api.domain.v4.ODataValue;
|
||||
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.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.core.domain.v4.ODataEntityImpl;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.apache.olingo.fit.AbstractBaseTestITCase;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
@ -86,7 +88,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
return client;
|
||||
}
|
||||
|
||||
protected ODataEntity read(final ODataPubFormat format, final URI editLink) {
|
||||
protected ODataEntity read(final ODataFormat format, final URI editLink) {
|
||||
final ODataEntityRequest<ODataEntity> req = getClient().getRetrieveRequestFactory().getEntityRequest(editLink);
|
||||
req.setFormat(format);
|
||||
|
||||
@ -95,14 +97,14 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
|
||||
assertNotNull(entity);
|
||||
|
||||
if (ODataPubFormat.JSON_FULL_METADATA == format || ODataPubFormat.ATOM == format) {
|
||||
if (ODataFormat.JSON_FULL_METADATA == format || ODataFormat.ATOM == format) {
|
||||
assertEquals(req.getURI(), entity.getEditLink());
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
protected void createAndDeleteOrder(final ODataPubFormat format, final int id) {
|
||||
protected void createAndDeleteOrder(final ODataFormat format, final int id) {
|
||||
final ODataEntity order = new ODataEntityImpl(
|
||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
|
||||
|
||||
|
@ -27,6 +27,7 @@ import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||
import org.apache.olingo.client.api.communication.request.v4.AsyncRequestWrapper;
|
||||
@ -39,7 +40,7 @@ import org.apache.olingo.commons.api.domain.ODataInlineEntity;
|
||||
import org.apache.olingo.commons.api.domain.ODataLink;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AsyncTestITCase extends AbstractTestITCase {
|
||||
@ -62,7 +63,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
||||
assertFalse(res.getBody().getEntities().isEmpty());
|
||||
}
|
||||
|
||||
private void withInlineEntry(final ODataPubFormat format) {
|
||||
private void withInlineEntry(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
|
||||
|
||||
@ -85,7 +86,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
||||
|
||||
assertEquals(3, entity.getNavigationLinks().size());
|
||||
|
||||
if (ODataPubFormat.ATOM == format) {
|
||||
if (ODataFormat.ATOM == format) {
|
||||
assertTrue(entity.getAssociationLinks().isEmpty());
|
||||
// In JSON, association links for each $ref link will exist.
|
||||
}
|
||||
@ -120,16 +121,16 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void withInlineEntryAsAtom() {
|
||||
withInlineEntry(ODataPubFormat.ATOM);
|
||||
withInlineEntry(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineEntryAsJSON() {
|
||||
// this needs to be full, otherwise there is no mean to recognize links
|
||||
withInlineEntry(ODataPubFormat.JSON_FULL_METADATA);
|
||||
withInlineEntry(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void asyncOrders(final ODataPubFormat format) {
|
||||
private void asyncOrders(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("async").appendEntitySetSegment("Orders");
|
||||
|
||||
@ -154,11 +155,11 @@ public class AsyncTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void asyncOrdersAsAtom() {
|
||||
asyncOrders(ODataPubFormat.ATOM);
|
||||
asyncOrders(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asyncOrdersAsJSON() {
|
||||
asyncOrders(ODataPubFormat.JSON);
|
||||
asyncOrders(ODataFormat.JSON);
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,9 @@ package org.apache.olingo.fit.v4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import java.net.URI;
|
||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
||||
|
||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
||||
import org.apache.olingo.client.api.communication.request.batch.BatchManager;
|
||||
import org.apache.olingo.client.api.communication.request.batch.ODataChangeset;
|
||||
import org.apache.olingo.client.api.communication.request.batch.v4.ODataBatchRequest;
|
||||
@ -37,11 +36,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
private final static String ACCEPT = ContentType.APPLICATION_OCTET_STREAM;
|
||||
private final static ContentType ACCEPT = ContentType.APPLICATION_OCTET_STREAM;
|
||||
|
||||
@Test
|
||||
public void clean() throws EdmPrimitiveTypeException {
|
||||
@ -63,12 +63,11 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||
batchRequest(unauthclient, testAuthServiceRootURL);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
private void batchRequest(final ODataClient client, final String baseURL) throws EdmPrimitiveTypeException {
|
||||
// create your request
|
||||
final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(baseURL);
|
||||
request.setAccept(ACCEPT);
|
||||
request.addCustomHeader("User-Agent", "Microsoft ADO.NET Data Client xxx");
|
||||
request.setAccept(ACCEPT.toContentTypeString());
|
||||
request.addCustomHeader("User-Agent", "Apache Olingo OData Client");
|
||||
request.addCustomHeader(HeaderName.acceptCharset, "UTF-8");
|
||||
|
||||
final BatchManager streamManager = request.payloadManager();
|
||||
@ -82,7 +81,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
// create new request
|
||||
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataPubFormat.JSON);
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
|
||||
streamManager.addRequest(queryReq);
|
||||
// -------------------------------------------
|
||||
@ -106,7 +105,7 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
final ODataEntityUpdateRequest<ODataEntity> changeReq =
|
||||
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
|
||||
changeReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
changeset.addRequest(changeReq);
|
||||
// -------------------------------------------
|
||||
|
@ -18,10 +18,10 @@
|
||||
*/
|
||||
package org.apache.olingo.fit.v4;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@ -31,6 +31,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.olingo.client.api.ODataBatchConstants;
|
||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
||||
@ -65,7 +66,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
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.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BatchTestITCase extends AbstractTestITCase {
|
||||
@ -76,7 +77,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
private static final int MAX = 10000;
|
||||
|
||||
private final static String ACCEPT = ContentType.APPLICATION_OCTET_STREAM;
|
||||
private final static String ACCEPT = ContentType.APPLICATION_OCTET_STREAM.toContentTypeString();
|
||||
|
||||
@Test
|
||||
public void stringStreaming() {
|
||||
@ -126,20 +127,20 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
for (int i = 1; i <= 2; i++) {
|
||||
// Create Customer into the changeset
|
||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
|
||||
createReq.setFormat(ODataPubFormat.JSON);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
}
|
||||
|
||||
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("WrongEntitySet");
|
||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(105));
|
||||
createReq.setFormat(ODataPubFormat.JSON);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
|
||||
targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
|
||||
for (int i = 3; i <= 4; i++) {
|
||||
// Create Customer into the changeset
|
||||
createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i));
|
||||
createReq.setFormat(ODataPubFormat.JSON);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
}
|
||||
|
||||
@ -189,7 +190,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
// create new request
|
||||
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataPubFormat.JSON);
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
|
||||
streamManager.addRequest(queryReq);
|
||||
// -------------------------------------------
|
||||
@ -334,7 +335,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
// create new request
|
||||
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataPubFormat.JSON);
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
|
||||
streamManager.addRequest(queryReq);
|
||||
// -------------------------------------------
|
||||
@ -347,7 +348,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
final ODataEntity original = newOrder(2000);
|
||||
final ODataEntityCreateRequest<ODataEntity> createReq =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
|
||||
createReq.setFormat(ODataPubFormat.JSON);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
streamManager.addRequest(createReq);
|
||||
// -------------------------------------------
|
||||
|
||||
@ -401,7 +402,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
// create new request
|
||||
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataPubFormat.JSON);
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
|
||||
streamManager.addRequest(queryReq);
|
||||
// -------------------------------------------
|
||||
@ -425,7 +426,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
final ODataEntityUpdateRequest<ODataEntity> changeReq =
|
||||
client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch);
|
||||
changeReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
changeReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
changeset.addRequest(changeReq);
|
||||
|
||||
@ -434,7 +435,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
final ODataEntity original = newOrder(1000);
|
||||
final ODataEntityCreateRequest<ODataEntity> createReq =
|
||||
client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original);
|
||||
createReq.setFormat(ODataPubFormat.JSON);
|
||||
createReq.setFormat(ODataFormat.JSON);
|
||||
changeset.addRequest(createReq);
|
||||
// -------------------------------------------
|
||||
|
||||
@ -490,7 +491,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
entity = createres.getBody();
|
||||
assertEquals(new Integer(1000), entity.getProperty("OrderID").getPrimitiveValue().toCastValue(Integer.class));
|
||||
|
||||
// retrive the third item (ODataRetrieve)
|
||||
// retrieve the third item (ODataRetrieve)
|
||||
item = iter.next();
|
||||
assertTrue(item instanceof ODataSingleResponseItem);
|
||||
|
||||
@ -525,7 +526,7 @@ public class BatchTestITCase extends AbstractTestITCase {
|
||||
|
||||
// create new request
|
||||
ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build());
|
||||
queryReq.setFormat(ODataPubFormat.JSON);
|
||||
queryReq.setFormat(ODataFormat.JSON);
|
||||
|
||||
async.addRetrieve(queryReq);
|
||||
// -------------------------------------------
|
||||
|
@ -26,6 +26,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
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.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
||||
@ -42,12 +43,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataSingleton;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void functions(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void functions(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
// GetEmployeesCount
|
||||
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
||||
final ODataEntityRequest<ODataSingleton> singletonReq =
|
||||
@ -167,12 +168,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomFunctions() throws EdmPrimitiveTypeException {
|
||||
functions(ODataPubFormat.ATOM);
|
||||
functions(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonFunctions() throws EdmPrimitiveTypeException {
|
||||
functions(ODataPubFormat.JSON_FULL_METADATA);
|
||||
functions(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -261,7 +262,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||
assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0);
|
||||
}
|
||||
|
||||
private void actions(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void actions(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
// IncreaseRevenue
|
||||
URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
||||
ODataEntityRequest<ODataEntity> entityReq =
|
||||
@ -365,12 +366,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomActions() throws EdmPrimitiveTypeException {
|
||||
actions(ODataPubFormat.ATOM);
|
||||
actions(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonActions() throws EdmPrimitiveTypeException {
|
||||
actions(ODataPubFormat.JSON_FULL_METADATA);
|
||||
actions(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -19,12 +19,12 @@
|
||||
package org.apache.olingo.fit.v4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import org.junit.Test;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
|
||||
@ -53,8 +53,9 @@ import org.apache.olingo.commons.api.domain.v4.ODataValue;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.core.domain.v4.ODataEntityImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 13.2 Interoperable OData Clients
|
||||
@ -115,7 +116,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
|
||||
getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Orders").build(), order);
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
// check for OData-Version
|
||||
assertEquals("4.0", req.getHeader("OData-Version"));
|
||||
@ -123,13 +124,13 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
|
||||
// check for Content-Type
|
||||
assertEquals(
|
||||
ODataPubFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
|
||||
ODataFormat.JSON_FULL_METADATA.getContentType(ODataServiceVersion.V40).toContentTypeString(),
|
||||
req.getHeader("Content-Type"));
|
||||
assertEquals(
|
||||
ODataPubFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
|
||||
ODataFormat.JSON_FULL_METADATA.getContentType(ODataServiceVersion.V40).toContentTypeString(),
|
||||
req.getHeader(HeaderName.contentType.toString()));
|
||||
assertEquals(
|
||||
ODataPubFormat.JSON_FULL_METADATA.toString(ODataServiceVersion.V40),
|
||||
ODataFormat.JSON_FULL_METADATA.getContentType(ODataServiceVersion.V40).toContentTypeString(),
|
||||
req.getContentType());
|
||||
|
||||
final ODataEntity created = req.execute().getBody();
|
||||
@ -176,7 +177,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
|
||||
ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
|
||||
getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
req.setPrefer(client.newPreferences().maxPageSize(5));
|
||||
|
||||
ODataRetrieveResponse<ODataEntitySet> res = req.execute();
|
||||
@ -193,7 +194,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
assertEquals(expected, found);
|
||||
|
||||
req = client.getRetrieveRequestFactory().getEntitySetRequest(found);
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
res = req.execute();
|
||||
feed = res.getBody();
|
||||
@ -233,7 +234,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL).
|
||||
appendEntitySetSegment("RowIndex").appendKeySegment(id);
|
||||
|
||||
rowIndex = read(ODataPubFormat.JSON_FULL_METADATA, builder.build());
|
||||
rowIndex = read(ODataFormat.JSON_FULL_METADATA, builder.build());
|
||||
assertNotNull(rowIndex);
|
||||
assertEquals(EdmPrimitiveTypeKind.Int32, rowIndex.getProperty("Id").getPrimitiveValue().getTypeKind());
|
||||
assertEquals(EdmPrimitiveTypeKind.String, rowIndex.getProperty("aString").getPrimitiveValue().getTypeKind());
|
||||
@ -266,7 +267,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
final ODataEntityUpdateResponse<ODataEntity> res = req.execute();
|
||||
assertEquals(204, res.getStatusCode());
|
||||
|
||||
final ODataEntity actual = read(ODataPubFormat.JSON, uri);
|
||||
final ODataEntity actual = read(ODataFormat.JSON, uri);
|
||||
|
||||
assertEquals(newname, actual.getProperty("FirstName").getPrimitiveValue().toString());
|
||||
}
|
||||
@ -284,7 +285,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
|
||||
|
||||
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
assertNotNull(req.execute().getBody());
|
||||
|
||||
@ -301,7 +302,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
appendRefSegment();
|
||||
|
||||
ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
ODataRetrieveResponse<ODataEntity> res = req.execute();
|
||||
assertNotNull(res);
|
||||
@ -314,7 +315,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
appendEntityIdSegment(entity.getId().toASCIIString()).build();
|
||||
|
||||
req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
res = req.execute();
|
||||
assertNotNull(res);
|
||||
@ -335,7 +336,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
assertNotNull(customers.getDeltaLink());
|
||||
|
||||
final ODataDeltaRequest deltaReq = client.getRetrieveRequestFactory().getDeltaRequest(customers.getDeltaLink());
|
||||
deltaReq.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
deltaReq.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
final ODataDelta delta = deltaReq.execute().getBody();
|
||||
assertNotNull(delta);
|
||||
@ -377,7 +378,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
|
||||
final ODataEntitySetRequest<ODataEntitySet> req =
|
||||
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
final AsyncRequestWrapper<ODataRetrieveResponse<ODataEntitySet>> async =
|
||||
client.getAsyncRequestFactory().<ODataRetrieveResponse<ODataEntitySet>>getAsyncRequestWrapper(req);
|
||||
@ -404,7 +405,7 @@ public class ConformanceTestITCase extends AbstractTestITCase {
|
||||
|
||||
final ODataEntityRequest<ODataEntity> req =
|
||||
client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.JSON);
|
||||
req.setFormat(ODataFormat.JSON);
|
||||
|
||||
assertEquals("application/json;odata.metadata=minimal", req.getHeader("Accept"));
|
||||
assertEquals("application/json;odata.metadata=minimal", req.getHeader(HeaderName.accept.toString()));
|
||||
|
@ -27,12 +27,12 @@ import org.apache.olingo.client.api.communication.request.retrieve.v4.ODataDelta
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataDelta;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DeltaTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void parse(final ODataPubFormat format) {
|
||||
private void parse(final ODataFormat format) {
|
||||
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(
|
||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build());
|
||||
req.setPrefer(client.newPreferences().trackChanges());
|
||||
@ -76,11 +76,11 @@ public class DeltaTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomParse() {
|
||||
parse(ODataPubFormat.ATOM);
|
||||
parse(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonParse() {
|
||||
parse(ODataPubFormat.JSON);
|
||||
parse(ODataFormat.JSON);
|
||||
}
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataProperty;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataValuable;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void read(final ODataPubFormat format) {
|
||||
private void read(final ODataFormat format) {
|
||||
// 1. entity set
|
||||
URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").
|
||||
@ -66,15 +66,15 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readfromAtom() {
|
||||
read(ODataPubFormat.ATOM);
|
||||
read(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readfromJSON() {
|
||||
read(ODataPubFormat.JSON_FULL_METADATA);
|
||||
read(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void createDelete(final ODataPubFormat format) {
|
||||
private void createDelete(final ODataFormat format) {
|
||||
final ODataEntity customer = client.getObjectFactory().
|
||||
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
||||
|
||||
@ -135,11 +135,11 @@ public class DerivedTypeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createDeleteAsAtom() {
|
||||
createDelete(ODataPubFormat.ATOM);
|
||||
createDelete(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createDeleteAsJSON() {
|
||||
createDelete(ODataPubFormat.JSON_FULL_METADATA);
|
||||
createDelete(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Calendar;
|
||||
|
||||
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;
|
||||
@ -34,22 +35,22 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomCreateAndDelete() {
|
||||
createAndDeleteOrder(ODataPubFormat.ATOM, 1000);
|
||||
createAndDeleteOrder(ODataFormat.ATOM, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonCreateAndDelete() {
|
||||
createAndDeleteOrder(ODataPubFormat.JSON, 1001);
|
||||
createAndDeleteOrder(ODataFormat.JSON, 1001);
|
||||
}
|
||||
|
||||
private void onContained(final ODataPubFormat format) {
|
||||
private void onContained(final ODataFormat format) {
|
||||
final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts").
|
||||
appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build();
|
||||
|
||||
@ -99,15 +100,15 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomOnContained() {
|
||||
onContained(ODataPubFormat.ATOM);
|
||||
onContained(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonOnContained() {
|
||||
onContained(ODataPubFormat.JSON);
|
||||
onContained(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void deepInsert(final ODataPubFormat format, final int productId, final int productDetailId)
|
||||
private void deepInsert(final ODataFormat format, final int productId, final int productDetailId)
|
||||
throws EdmPrimitiveTypeException {
|
||||
|
||||
final ODataEntity product = getClient().getObjectFactory().
|
||||
@ -178,11 +179,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomDeepInsert() throws EdmPrimitiveTypeException {
|
||||
deepInsert(ODataPubFormat.ATOM, 10, 10);
|
||||
deepInsert(ODataFormat.ATOM, 10, 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonDeepInsert() throws EdmPrimitiveTypeException {
|
||||
deepInsert(ODataPubFormat.JSON_FULL_METADATA, 11, 11);
|
||||
deepInsert(ODataFormat.JSON_FULL_METADATA, 11, 11);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.net.URI;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
|
||||
@ -45,7 +46,7 @@ import org.apache.olingo.commons.api.domain.ODataLinkType;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -53,7 +54,7 @@ import org.junit.Test;
|
||||
*/
|
||||
public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void withInlineEntity(final ODataClient client, final ODataPubFormat format) {
|
||||
private void withInlineEntity(final ODataClient client, final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
|
||||
|
||||
@ -70,11 +71,11 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
assertEquals("Edm.GeographyPoint", entity.getProperty("Home").getPrimitiveValue().getTypeName());
|
||||
|
||||
// In JSON with minimal metadata, links are not provided
|
||||
if (format == ODataPubFormat.ATOM || format == ODataPubFormat.JSON_FULL_METADATA) {
|
||||
if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
|
||||
assertEquals(testStaticServiceRootURL + "/Customers(1)", entity.getEditLink().toASCIIString());
|
||||
assertEquals(3, entity.getNavigationLinks().size());
|
||||
|
||||
if (ODataPubFormat.ATOM == format) {
|
||||
if (ODataFormat.ATOM == format) {
|
||||
assertTrue(entity.getAssociationLinks().isEmpty());
|
||||
// In JSON, association links for each $ref link will exist.
|
||||
}
|
||||
@ -110,20 +111,20 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void withInlineEntityFromAtom() {
|
||||
withInlineEntity(client, ODataPubFormat.ATOM);
|
||||
withInlineEntity(client, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineEntityFromFullJSON() {
|
||||
withInlineEntity(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||
withInlineEntity(client, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineEntityFromJSON() {
|
||||
withInlineEntity(edmClient, ODataPubFormat.JSON);
|
||||
withInlineEntity(edmClient, ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void withInlineEntitySet(final ODataClient client, final ODataPubFormat format) {
|
||||
private void withInlineEntitySet(final ODataClient client, final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
|
||||
|
||||
@ -137,7 +138,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
|
||||
|
||||
// In JSON with minimal metadata, links are not provided
|
||||
if (format == ODataPubFormat.ATOM || format == ODataPubFormat.JSON_FULL_METADATA) {
|
||||
if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
|
||||
boolean found = false;
|
||||
for (ODataLink link : entity.getNavigationLinks()) {
|
||||
if (link instanceof ODataInlineEntitySet) {
|
||||
@ -153,25 +154,25 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void withInlineEntitySetFromAtom() {
|
||||
withInlineEntitySet(client, ODataPubFormat.ATOM);
|
||||
withInlineEntitySet(client, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineEntitySetFromFullJSON() {
|
||||
withInlineEntitySet(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||
withInlineEntitySet(client, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withInlineEntitySetFromJSON() {
|
||||
withInlineEntitySet(edmClient, ODataPubFormat.JSON);
|
||||
withInlineEntitySet(edmClient, ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void rawRequest(final ODataPubFormat format) {
|
||||
private void rawRequest(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5);
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.toString(client.getServiceVersion()));
|
||||
req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
@ -185,16 +186,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void rawRequestAsAtom() {
|
||||
rawRequest(ODataPubFormat.ATOM);
|
||||
rawRequest(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rawRequestAsJSON() {
|
||||
// this needs to be full, otherwise reference will not be provided
|
||||
rawRequest(ODataPubFormat.JSON_FULL_METADATA);
|
||||
rawRequest(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void multiKey(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void multiKey(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
|
||||
multiKey.put("ProductID", "6");
|
||||
multiKey.put("ProductDetailID", 1);
|
||||
@ -214,15 +215,15 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void multiKeyAsAtom() throws EdmPrimitiveTypeException {
|
||||
multiKey(ODataPubFormat.ATOM);
|
||||
multiKey(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiKeyAsJSON() throws EdmPrimitiveTypeException {
|
||||
multiKey(ODataPubFormat.JSON_FULL_METADATA);
|
||||
multiKey(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void checkForETag(final ODataClient client, final ODataPubFormat format) {
|
||||
private void checkForETag(final ODataClient client, final ODataFormat format) {
|
||||
final URIBuilder uriBuilder =
|
||||
client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
|
||||
|
||||
@ -246,17 +247,17 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void checkForETagAsAtom() {
|
||||
checkForETag(client, ODataPubFormat.ATOM);
|
||||
checkForETag(client, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForETagAsFullJSON() {
|
||||
checkForETag(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||
checkForETag(client, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForETagAsJSON() {
|
||||
checkForETag(edmClient, ODataPubFormat.JSON);
|
||||
checkForETag(edmClient, ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ -264,14 +265,14 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
|
||||
|
||||
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.JSON);
|
||||
req.setFormat(ODataFormat.JSON);
|
||||
|
||||
// this statement should cause an IllegalArgumentException bearing JsonParseException
|
||||
// since we are attempting to parse an EntitySet as if it was an Entity
|
||||
req.execute().getBody();
|
||||
}
|
||||
|
||||
private void reference(final ODataPubFormat format) {
|
||||
private void reference(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
|
||||
appendRefSegment();
|
||||
@ -299,15 +300,15 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomReference() {
|
||||
reference(ODataPubFormat.ATOM);
|
||||
reference(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonReference() {
|
||||
reference(ODataPubFormat.JSON_FULL_METADATA);
|
||||
reference(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void contained(final ODataClient client, final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
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();
|
||||
@ -324,20 +325,20 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void containedFromAtom() throws EdmPrimitiveTypeException {
|
||||
contained(client, ODataPubFormat.ATOM);
|
||||
contained(client, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containedFromFullJSON() throws EdmPrimitiveTypeException {
|
||||
contained(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||
contained(client, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containedFromJSON() throws EdmPrimitiveTypeException {
|
||||
contained(edmClient, ODataPubFormat.JSON);
|
||||
contained(edmClient, ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void entitySetNavigationLink(final ODataClient client, final ODataPubFormat format) {
|
||||
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);
|
||||
@ -347,7 +348,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
assertNotNull(entity);
|
||||
|
||||
// With JSON, entity set navigation links are only recognizable via Edm
|
||||
if (format == ODataPubFormat.ATOM || client instanceof EdmEnabledODataClient) {
|
||||
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());
|
||||
}
|
||||
@ -355,13 +356,13 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void entitySetNavigationLinkFromAtom() {
|
||||
entitySetNavigationLink(client, ODataPubFormat.ATOM);
|
||||
entitySetNavigationLink(client, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void entitySetNavigationLinkFromJSON() {
|
||||
// only JSON_FULL_METADATA has links, only Edm can recognize entity set navigation
|
||||
entitySetNavigationLink(edmClient, ODataPubFormat.JSON_FULL_METADATA);
|
||||
entitySetNavigationLink(edmClient, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
|
||||
@ -36,7 +37,7 @@ import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -44,11 +45,11 @@ import org.junit.Test;
|
||||
*/
|
||||
public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void rawRequest(final ODataPubFormat format) {
|
||||
private void rawRequest(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.toString(client.getServiceVersion()));
|
||||
req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
@ -60,20 +61,20 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void rawRequestAsAtom() throws IOException {
|
||||
rawRequest(ODataPubFormat.ATOM);
|
||||
rawRequest(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rawRequestAsJSON() throws IOException {
|
||||
rawRequest(ODataPubFormat.JSON);
|
||||
rawRequest(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void readWithInlineCount(final ODataClient client, final ODataPubFormat format) {
|
||||
private void readWithInlineCount(final ODataClient client, final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").count(true);
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(format.toString(client.getServiceVersion()));
|
||||
req.setFormat(format.getContentType(client.getServiceVersion()).toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
@ -87,20 +88,20 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readWithInlineCountAsJSON() throws IOException {
|
||||
readWithInlineCount(edmClient, ODataPubFormat.JSON);
|
||||
readWithInlineCount(edmClient, ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithInlineCountAsFullJSON() throws IOException {
|
||||
readWithInlineCount(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||
readWithInlineCount(client, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithInlineCountAsAtom() throws IOException {
|
||||
readWithInlineCount(client, ODataPubFormat.ATOM);
|
||||
readWithInlineCount(client, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
private void readODataEntitySetIterator(final ODataPubFormat format) {
|
||||
private void readODataEntitySetIterator(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
||||
|
||||
final ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> req =
|
||||
@ -124,25 +125,25 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromAtom() {
|
||||
readODataEntitySetIterator(ODataPubFormat.ATOM);
|
||||
readODataEntitySetIterator(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromJSON() {
|
||||
readODataEntitySetIterator(ODataPubFormat.JSON);
|
||||
readODataEntitySetIterator(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromJSONFull() {
|
||||
readODataEntitySetIterator(ODataPubFormat.JSON_FULL_METADATA);
|
||||
readODataEntitySetIterator(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readODataEntitySetIteratorFromJSONNo() {
|
||||
readODataEntitySetIterator(ODataPubFormat.JSON_NO_METADATA);
|
||||
readODataEntitySetIterator(ODataFormat.JSON_NO_METADATA);
|
||||
}
|
||||
|
||||
private void readWithNext(final ODataPubFormat format) {
|
||||
private void readWithNext(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
||||
|
||||
final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
|
||||
@ -166,12 +167,12 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readWithNextFromAtom() {
|
||||
readWithNext(ODataPubFormat.ATOM);
|
||||
readWithNext(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithNextFromJSON() {
|
||||
readWithNext(ODataPubFormat.JSON_FULL_METADATA);
|
||||
readWithNext(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import java.net.URI;
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
||||
import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
|
||||
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
|
||||
@ -32,12 +33,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void upsert(final UpdateType updateType, final ODataPubFormat format) {
|
||||
private void upsert(final UpdateType updateType, final ODataFormat format) {
|
||||
final ODataEntity order = getClient().getObjectFactory().
|
||||
newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
|
||||
|
||||
@ -72,17 +73,17 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomUpsert() {
|
||||
upsert(UpdateType.PATCH, ODataPubFormat.ATOM);
|
||||
upsert(UpdateType.REPLACE, ODataPubFormat.ATOM);
|
||||
upsert(UpdateType.PATCH, ODataFormat.ATOM);
|
||||
upsert(UpdateType.REPLACE, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonUpsert() {
|
||||
upsert(UpdateType.PATCH, ODataPubFormat.JSON);
|
||||
upsert(UpdateType.REPLACE, ODataPubFormat.JSON);
|
||||
upsert(UpdateType.PATCH, ODataFormat.JSON);
|
||||
upsert(UpdateType.REPLACE, ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void onContained(final ODataPubFormat format) {
|
||||
private void onContained(final ODataFormat format) {
|
||||
final String newName = UUID.randomUUID().toString();
|
||||
final ODataEntity changes = getClient().getObjectFactory().newEntity(
|
||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
|
||||
@ -106,15 +107,15 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomOnContained() {
|
||||
onContained(ODataPubFormat.ATOM);
|
||||
onContained(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonOnContained() {
|
||||
onContained(ODataPubFormat.JSON);
|
||||
onContained(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void bindOperation(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void bindOperation(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
final ODataEntity changes = getClient().getObjectFactory().newEntity(
|
||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
|
||||
final ODataLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent",
|
||||
@ -144,11 +145,11 @@ public class EntityUpdateTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomBindOperation() throws EdmPrimitiveTypeException {
|
||||
bindOperation(ODataPubFormat.ATOM);
|
||||
bindOperation(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonBindOperation() throws EdmPrimitiveTypeException {
|
||||
bindOperation(ODataPubFormat.JSON);
|
||||
bindOperation(ODataFormat.JSON);
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,11 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
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.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ErrorResponseTestITCase extends AbstractTestITCase {
|
||||
@ -38,7 +39,7 @@ public class ErrorResponseTestITCase extends AbstractTestITCase {
|
||||
build();
|
||||
|
||||
try {
|
||||
read(ODataPubFormat.JSON, readURI);
|
||||
read(ODataFormat.JSON, readURI);
|
||||
fail("should have got exception");
|
||||
} catch (Exception ex) {
|
||||
final ODataError err = ((ODataClientErrorException) ex).getODataError();
|
||||
|
@ -19,7 +19,6 @@
|
||||
package org.apache.olingo.fit.v4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.apache.olingo.fit.v4.AbstractTestITCase.client;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||
import org.apache.olingo.client.api.uri.URIFilter;
|
||||
@ -28,7 +27,7 @@ import org.apache.olingo.client.api.uri.v4.FilterFactory;
|
||||
import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FilterFactoryTestITCase extends AbstractTestITCase {
|
||||
@ -51,7 +50,7 @@ public class FilterFactoryTestITCase extends AbstractTestITCase {
|
||||
|
||||
final ODataEntitySetRequest<ODataEntitySet> req =
|
||||
client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
final ODataEntitySet feed = req.execute().getBody();
|
||||
assertEquals(3, feed.getEntities().size());
|
||||
|
@ -40,7 +40,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataLink;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -91,7 +91,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||
final URI uri = edmClient.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Accounts").appendKeySegment(102).build();
|
||||
final ODataEntityRequest<ODataEntity> req = edmClient.getRetrieveRequestFactory().getEntityRequest(uri);
|
||||
req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
|
||||
req.setFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
|
||||
// request format (via Accept header) is set to full metadata
|
||||
assertEquals("application/json;odata.metadata=full", req.getAccept());
|
||||
@ -148,7 +148,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||
+ "\"GeographyPoint\": {\"type\": \"Point\",\"coordinates\":[142.1,64.1]}"
|
||||
+ "}";
|
||||
|
||||
final ODataEntity entity = client.getReader().readEntity(IOUtils.toInputStream(fromSection71), ODataPubFormat.JSON);
|
||||
final ODataEntity entity = client.getReader().readEntity(IOUtils.toInputStream(fromSection71), ODataFormat.JSON);
|
||||
|
||||
assertTrue(entity.getProperty("NullValue").hasNullValue());
|
||||
|
||||
@ -219,7 +219,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||
+ "}";
|
||||
|
||||
final ResWrap<Entity> entity =
|
||||
client.getDeserializer(ODataPubFormat.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
|
||||
client.getDeserializer(ODataFormat.JSON).toEntity(IOUtils.toInputStream(fromSection45_1));
|
||||
|
||||
assertEquals("http://host/service/$metadata#Customers/$entity", entity.getContextURL().getURI().toASCIIString());
|
||||
assertEquals("W/\"A1FF3E230954908F\"", entity.getMetadataETag());
|
||||
@ -241,7 +241,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||
+ "}";
|
||||
|
||||
final ResWrap<EntitySet> entitySet =
|
||||
client.getDeserializer(ODataPubFormat.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());
|
||||
@ -271,7 +271,7 @@ public class JSONFormatConformanceTestITCase extends AbstractTestITCase {
|
||||
+ "}";
|
||||
|
||||
final ODataEntitySet entitySet = client.getReader().
|
||||
readEntitySet(IOUtils.toInputStream(sample), ODataPubFormat.JSON);
|
||||
readEntitySet(IOUtils.toInputStream(sample), ODataFormat.JSON);
|
||||
|
||||
assertEquals(2, entitySet.getAnnotations().size());
|
||||
|
||||
|
@ -18,11 +18,12 @@
|
||||
*/
|
||||
package org.apache.olingo.fit.v4;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
||||
import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
@ -32,7 +33,7 @@ import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -49,7 +50,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||
client.getConfiguration().setKeyAsSegment(false);
|
||||
}
|
||||
|
||||
private void read(final ODataPubFormat format) {
|
||||
private void read(final ODataFormat format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL).
|
||||
appendEntitySetSegment("Accounts").appendKeySegment(101);
|
||||
|
||||
@ -61,7 +62,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||
assertNotNull(entity);
|
||||
|
||||
// In JSON with minimal metadata, links are not provided
|
||||
if (format == ODataPubFormat.ATOM || format == ODataPubFormat.JSON_FULL_METADATA) {
|
||||
if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) {
|
||||
assertFalse(entity.getEditLink().toASCIIString().contains("("));
|
||||
assertFalse(entity.getEditLink().toASCIIString().contains(")"));
|
||||
}
|
||||
@ -69,25 +70,25 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomRead() {
|
||||
read(ODataPubFormat.ATOM);
|
||||
read(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonRead() {
|
||||
read(ODataPubFormat.JSON);
|
||||
read(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void atomCreateAndDelete() {
|
||||
createAndDeleteOrder(ODataPubFormat.ATOM, 1000);
|
||||
createAndDeleteOrder(ODataFormat.ATOM, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonCreateAndDelete() {
|
||||
createAndDeleteOrder(ODataPubFormat.JSON_FULL_METADATA, 1001);
|
||||
createAndDeleteOrder(ODataFormat.JSON_FULL_METADATA, 1001);
|
||||
}
|
||||
|
||||
private void update(final ODataPubFormat format) {
|
||||
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",
|
||||
@ -115,11 +116,11 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomUpdate() {
|
||||
update(ODataPubFormat.ATOM);
|
||||
update(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonUpdate() {
|
||||
update(ODataPubFormat.JSON);
|
||||
update(ODataFormat.JSON);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import java.net.URI;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.olingo.client.api.communication.header.HeaderName;
|
||||
@ -51,12 +52,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataValuable;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void read(final ODataClient client, final ODataPubFormat format) throws IOException {
|
||||
private void read(final ODataClient client, final ODataFormat format) throws IOException {
|
||||
final URIBuilder builder = client.newURIBuilder(testDemoServiceRootURL).
|
||||
appendEntitySetSegment("Advertisements").
|
||||
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7"));
|
||||
@ -82,20 +83,20 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readAsAtom() throws IOException {
|
||||
read(client, ODataPubFormat.ATOM);
|
||||
read(client, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAsJSON() throws IOException {
|
||||
read(ODataClientFactory.getEdmEnabledV4(testDemoServiceRootURL), ODataPubFormat.JSON);
|
||||
read(ODataClientFactory.getEdmEnabledV4(testDemoServiceRootURL), ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAsJSONFull() throws IOException {
|
||||
read(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||
read(client, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void create(final ODataPubFormat format) throws IOException {
|
||||
private void create(final ODataFormat format) throws IOException {
|
||||
final String random = RandomStringUtils.random(110);
|
||||
final InputStream input = IOUtils.toInputStream(random);
|
||||
|
||||
@ -136,15 +137,15 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void createAsAtom() throws IOException {
|
||||
create(ODataPubFormat.ATOM);
|
||||
create(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createAsJSON() throws IOException {
|
||||
create(ODataPubFormat.JSON);
|
||||
create(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
private void update(final ODataPubFormat format) throws IOException, EdmPrimitiveTypeException {
|
||||
private void update(final ODataFormat format) throws IOException, EdmPrimitiveTypeException {
|
||||
final URI uri = client.newURIBuilder(testDemoServiceRootURL).
|
||||
appendEntitySetSegment("Advertisements").
|
||||
appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).build();
|
||||
@ -172,11 +173,11 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void updateAsAtom() throws IOException, EdmPrimitiveTypeException {
|
||||
update(ODataPubFormat.ATOM);
|
||||
update(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateAsJSON() throws IOException, EdmPrimitiveTypeException {
|
||||
update(ODataPubFormat.JSON);
|
||||
update(ODataFormat.JSON);
|
||||
}
|
||||
}
|
||||
|
@ -24,18 +24,19 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
|
||||
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.client.api.uri.v4.URIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.ODataComplexValue;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.EdmSchema;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||
@ -52,13 +53,13 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||
assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
|
||||
}
|
||||
|
||||
private ODataEntity readRow(final ODataPubFormat format, final String uuid) {
|
||||
private ODataEntity 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 ODataPubFormat format) {
|
||||
private void read(final ODataFormat format) {
|
||||
ODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f");
|
||||
assertEquals(EdmPrimitiveTypeKind.Double, row.getProperty("Double").getPrimitiveValue().getTypeKind());
|
||||
assertEquals(EdmPrimitiveTypeKind.Guid, row.getProperty("Id").getPrimitiveValue().getTypeKind());
|
||||
@ -69,15 +70,15 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readAsAtom() {
|
||||
read(ODataPubFormat.ATOM);
|
||||
read(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readAsJSON() {
|
||||
read(ODataPubFormat.JSON_FULL_METADATA);
|
||||
read(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void cud(final ODataPubFormat format) {
|
||||
private void cud(final ODataFormat format) {
|
||||
final Integer id = 1426;
|
||||
|
||||
ODataEntity rowIndex = getClient().getObjectFactory().newEntity(
|
||||
@ -173,12 +174,12 @@ public class OpenTypeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void cudAsAtom() {
|
||||
cud(ODataPubFormat.ATOM);
|
||||
cud(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cudAsJSON() {
|
||||
cud(ODataPubFormat.JSON_FULL_METADATA);
|
||||
cud(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.util.Collections;
|
||||
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;
|
||||
@ -36,13 +37,12 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void functionImports(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void functionImports(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
// GetDefaultColor
|
||||
final ODataInvokeRequest<ODataProperty> defaultColorReq = getClient().getInvokeRequestFactory().
|
||||
getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL).
|
||||
@ -113,12 +113,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomFunctionImports() throws EdmPrimitiveTypeException {
|
||||
functionImports(ODataPubFormat.ATOM);
|
||||
functionImports(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonFunctionImports() throws EdmPrimitiveTypeException {
|
||||
functionImports(ODataPubFormat.JSON_FULL_METADATA);
|
||||
functionImports(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -182,7 +182,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||
assertTrue(prodByAL.getCollectionValue().asJavaCollection().contains("Car"));
|
||||
}
|
||||
|
||||
private void actionImports(final ODataPubFormat format) {
|
||||
private void actionImports(final ODataFormat format) {
|
||||
// Discount
|
||||
final ODataPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
|
||||
final ODataInvokeRequest<ODataNoContent> discountReq = getClient().getInvokeRequestFactory().
|
||||
@ -215,12 +215,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomActionImports() {
|
||||
actionImports(ODataPubFormat.ATOM);
|
||||
actionImports(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonActionImports() {
|
||||
actionImports(ODataPubFormat.JSON_FULL_METADATA);
|
||||
actionImports(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -251,7 +251,7 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||
assertEquals(address.getTypeName(), resetBossAddress.getComplexValue().getTypeName());
|
||||
}
|
||||
|
||||
private void bossEmails(final ODataPubFormat format) {
|
||||
private void bossEmails(final ODataFormat format) {
|
||||
// ResetBossEmail
|
||||
final ODataCollectionValue<org.apache.olingo.commons.api.domain.v4.ODataValue> emails =
|
||||
getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)");
|
||||
@ -284,11 +284,11 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomBossEmails() throws EdmPrimitiveTypeException {
|
||||
bossEmails(ODataPubFormat.ATOM);
|
||||
bossEmails(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonBossEmails() throws EdmPrimitiveTypeException {
|
||||
bossEmails(ODataPubFormat.JSON_FULL_METADATA);
|
||||
bossEmails(ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.communication.ODataClientErrorException;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
|
||||
@ -33,8 +34,6 @@ import org.apache.olingo.commons.api.domain.v4.ODataValuable;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
@ -44,7 +43,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
assertEquals("5", req.execute().getBody().toString());
|
||||
}
|
||||
|
||||
@ -53,7 +52,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
assertEquals("true", req.execute().getBody().toString());
|
||||
}
|
||||
|
||||
@ -62,7 +61,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
assertEquals("Peter", req.execute().getBody().toString());
|
||||
}
|
||||
|
||||
@ -71,7 +70,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataPrimitiveValue property = req.execute().getBody();
|
||||
assertEquals("2011-03-04T16:03:57Z", property.toString());
|
||||
}
|
||||
@ -81,7 +80,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataPrimitiveValue property = req.execute().getBody();
|
||||
assertEquals("179", property.toString());
|
||||
}
|
||||
@ -91,7 +90,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataPrimitiveValue property = req.execute().getBody();
|
||||
assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
|
||||
+ "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=", property.toString());
|
||||
@ -102,7 +101,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setAccept(ODataPubFormat.ATOM.toString(ODataServiceVersion.V40));
|
||||
req.setAccept(ODataFormat.ATOM.getContentType(ODataServiceVersion.V40).toContentTypeString());
|
||||
req.execute().getBody();
|
||||
}
|
||||
|
||||
@ -111,7 +110,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setAccept(ODataFormat.XML.toString(client.getServiceVersion()));
|
||||
req.setAccept(ODataFormat.XML.getContentType(client.getServiceVersion()).toContentTypeString());
|
||||
req.execute().getBody();
|
||||
}
|
||||
|
||||
@ -133,7 +132,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress");
|
||||
final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build());
|
||||
req.setFormat(ODataValueFormat.TEXT);
|
||||
req.setFormat(ODataFormat.TEXT_PLAIN);
|
||||
final ODataPrimitiveValue property = req.execute().getBody();
|
||||
assertTrue(StringUtils.isBlank(property.toString()));
|
||||
}
|
||||
|
@ -19,23 +19,24 @@
|
||||
package org.apache.olingo.fit.v4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
||||
import org.apache.olingo.client.api.uri.QueryOption;
|
||||
import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -124,12 +125,12 @@ public class QueryOptionsTestITCase extends AbstractTestITCase {
|
||||
appendEntitySetSegment("Customers").appendKeySegment(1).format("json");
|
||||
|
||||
final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
|
||||
req.setFormat(ODataPubFormat.ATOM);
|
||||
req.setFormat(ODataFormat.ATOM);
|
||||
|
||||
final ODataRetrieveResponse<ODataEntity> res = req.execute();
|
||||
assertNotNull(res);
|
||||
assertTrue(res.getContentType().replaceAll(" ", "").
|
||||
startsWith(ODataPubFormat.JSON.toString(client.getServiceVersion())));
|
||||
startsWith(ODataFormat.JSON.getContentType(client.getServiceVersion()).toContentTypeString()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,11 +19,12 @@
|
||||
package org.apache.olingo.fit.v4;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
|
||||
import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
|
||||
@ -31,16 +32,16 @@ import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResp
|
||||
import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
||||
import org.apache.olingo.client.api.v4.ODataClient;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataAnnotation;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataValuable;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataSingleton;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataValuable;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SingletonTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void read(final ODataClient client, final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void read(final ODataClient client, final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company");
|
||||
final ODataEntityRequest<ODataSingleton> singleton =
|
||||
client.getRetrieveRequestFactory().getSingletonRequest(builder.build());
|
||||
@ -57,20 +58,20 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readFromAtom() throws EdmPrimitiveTypeException {
|
||||
read(client, ODataPubFormat.ATOM);
|
||||
read(client, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readFromJSON() throws EdmPrimitiveTypeException {
|
||||
read(edmClient, ODataPubFormat.JSON);
|
||||
read(edmClient, ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readfromJSONFull() throws EdmPrimitiveTypeException {
|
||||
read(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||
read(client, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void readWithAnnotations(final ODataClient client, final ODataPubFormat format)
|
||||
private void readWithAnnotations(final ODataClient client, final ODataFormat format)
|
||||
throws EdmPrimitiveTypeException {
|
||||
|
||||
final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss");
|
||||
@ -88,20 +89,20 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void readWithAnnotationsFromAtom() throws EdmPrimitiveTypeException {
|
||||
readWithAnnotations(client, ODataPubFormat.ATOM);
|
||||
readWithAnnotations(client, ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithAnnotationsFromJSON() throws EdmPrimitiveTypeException {
|
||||
readWithAnnotations(edmClient, ODataPubFormat.JSON);
|
||||
readWithAnnotations(edmClient, ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithAnnotationsFromJSONFull() throws EdmPrimitiveTypeException {
|
||||
readWithAnnotations(client, ODataPubFormat.JSON_FULL_METADATA);
|
||||
readWithAnnotations(client, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
private void update(final ODataPubFormat format) throws EdmPrimitiveTypeException {
|
||||
private void update(final ODataFormat format) throws EdmPrimitiveTypeException {
|
||||
final ODataSingleton changes = getClient().getObjectFactory().newSingleton(
|
||||
new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"));
|
||||
changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Revenue",
|
||||
@ -122,12 +123,12 @@ public class SingletonTestITCase extends AbstractTestITCase {
|
||||
|
||||
@Test
|
||||
public void atomUpdate() throws EdmPrimitiveTypeException {
|
||||
update(ODataPubFormat.ATOM);
|
||||
update(ODataFormat.ATOM);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jsonUpdate() throws EdmPrimitiveTypeException {
|
||||
update(ODataPubFormat.JSON);
|
||||
update(ODataFormat.JSON);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,48 +18,45 @@
|
||||
*/
|
||||
package org.apache.olingo.client.api;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import org.apache.olingo.client.api.http.HttpClientFactory;
|
||||
import org.apache.olingo.client.api.http.HttpUriRequestFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataMediaFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
|
||||
/**
|
||||
* Configuration wrapper.
|
||||
*/
|
||||
public interface CommonConfiguration extends Serializable {
|
||||
public interface CommonConfiguration {
|
||||
|
||||
/**
|
||||
* Gets the configured default <tt>Accept</tt> header value format for a batch request.
|
||||
* @return configured default <tt>Accept</tt> header value for a batch request.
|
||||
*/
|
||||
String getDefaultBatchAcceptFormat();
|
||||
ContentType getDefaultBatchAcceptFormat();
|
||||
|
||||
/**
|
||||
* Set the default <tt>Accept</tt> header value format for a batch request.
|
||||
* @param contentType default <tt>Accept</tt> header value.
|
||||
*/
|
||||
void setDefaultBatchAcceptFormat(String contentType);
|
||||
void setDefaultBatchAcceptFormat(ContentType contentType);
|
||||
|
||||
/**
|
||||
* Gets the configured OData format for AtomPub exchanges. If this configuration parameter doesn't exist the
|
||||
* JSON_FULL_METADATA format will be used as default.
|
||||
*
|
||||
* @return configured OData format for AtomPub if specified; JSON_FULL_METADATA format otherwise.
|
||||
* @see ODataPubFormat#JSON_FULL_METADATA
|
||||
* @see ODataFormat#JSON_FULL_METADATA
|
||||
*/
|
||||
ODataPubFormat getDefaultPubFormat();
|
||||
ODataFormat getDefaultPubFormat();
|
||||
|
||||
/**
|
||||
* Sets the default OData format for AtomPub exchanges.
|
||||
*
|
||||
* @param format default format.
|
||||
*/
|
||||
void setDefaultPubFormat(ODataPubFormat format);
|
||||
void setDefaultPubFormat(ODataFormat format);
|
||||
|
||||
/**
|
||||
* Gets the configured OData format. This value depends on what is returned from <tt>getDefaultPubFormat()</tt>.
|
||||
@ -73,39 +70,37 @@ public interface CommonConfiguration extends Serializable {
|
||||
* Gets the configured OData value format. If this configuration parameter doesn't exist the TEXT format will be used
|
||||
* as default.
|
||||
*
|
||||
* @return configured OData value format if specified; TEXT format otherwise.
|
||||
* @see ODataValueFormat#TEXT
|
||||
* @return configured OData value format if specified; TEXT_PLAIN format otherwise.
|
||||
* @see ODataFormat#TEXT_PLAIN
|
||||
*/
|
||||
ODataValueFormat getDefaultValueFormat();
|
||||
ODataFormat getDefaultValueFormat();
|
||||
|
||||
/**
|
||||
* Sets the default OData value format.
|
||||
*
|
||||
* @param format default format.
|
||||
*/
|
||||
void setDefaultValueFormat(ODataValueFormat format);
|
||||
void setDefaultValueFormat(ODataFormat format);
|
||||
|
||||
/**
|
||||
* Gets the configured OData media format. If this configuration parameter doesn't exist the APPLICATION_OCTET_STREAM
|
||||
* format will be used as default.
|
||||
*
|
||||
* @return configured OData media format if specified; APPLICATION_OCTET_STREAM format otherwise.
|
||||
* @see ODataMediaFormat#WILDCARD
|
||||
*/
|
||||
ODataMediaFormat getDefaultMediaFormat();
|
||||
ODataFormat getDefaultMediaFormat();
|
||||
|
||||
/**
|
||||
* Sets the default OData media format.
|
||||
*
|
||||
* @param format default format.
|
||||
*/
|
||||
void setDefaultMediaFormat(ODataMediaFormat format);
|
||||
void setDefaultMediaFormat(ODataFormat format);
|
||||
|
||||
/**
|
||||
* Gets the HttpClient factory to be used for executing requests.
|
||||
*
|
||||
* @return provided implementation (if configured via <tt>setHttpClientFactory</tt> or default.
|
||||
* @see DefaultHttpClientFactory
|
||||
*/
|
||||
HttpClientFactory getHttpClientFactory();
|
||||
|
||||
@ -121,7 +116,6 @@ public interface CommonConfiguration extends Serializable {
|
||||
* Gets the HttpUriRequest factory for generating requests to be executed.
|
||||
*
|
||||
* @return provided implementation (if configured via <tt>setHttpUriRequestFactory</tt> or default.
|
||||
* @see DefaultHttpUriRequestFactory
|
||||
*/
|
||||
HttpUriRequestFactory getHttpUriRequestFactory();
|
||||
|
||||
|
@ -33,7 +33,7 @@ import org.apache.olingo.client.api.uri.CommonFilterFactory;
|
||||
import org.apache.olingo.client.api.uri.CommonURIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
import org.apache.olingo.commons.api.format.Format;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataSerializer;
|
||||
|
||||
/**
|
||||
@ -55,9 +55,9 @@ public interface CommonODataClient<UT extends CommonUpdateType> {
|
||||
|
||||
CommonFilterFactory getFilterFactory();
|
||||
|
||||
ODataSerializer getSerializer(Format format);
|
||||
ODataSerializer getSerializer(ODataFormat format);
|
||||
|
||||
ClientODataDeserializer getDeserializer(Format format);
|
||||
ClientODataDeserializer getDeserializer(ODataFormat format);
|
||||
|
||||
CommonODataReader getReader();
|
||||
|
||||
|
@ -19,37 +19,35 @@
|
||||
package org.apache.olingo.client.api.communication.request;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||
import org.apache.olingo.commons.api.format.Format;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* Basic OData request.
|
||||
*
|
||||
* @param <V> OData response type corresponding to the request implementation.
|
||||
* @param <T> Accepted content-type formats by the request in object.
|
||||
* @param <T> OData response type corresponding to the request implementation.
|
||||
*/
|
||||
public interface ODataBasicRequest<V extends ODataResponse, T extends Format> extends ODataRequest {
|
||||
public interface ODataBasicRequest<T extends ODataResponse> extends ODataRequest {
|
||||
|
||||
/**
|
||||
* Request execute.
|
||||
*
|
||||
* @return return an OData response.
|
||||
*/
|
||||
V execute();
|
||||
T execute();
|
||||
|
||||
/**
|
||||
* Async request execute.
|
||||
*
|
||||
* @return <code>Future<ODataResponse></code> about the executed request.
|
||||
*/
|
||||
Future<V> asyncExecute();
|
||||
Future<T> asyncExecute();
|
||||
|
||||
/**
|
||||
* Override configured request format.
|
||||
*
|
||||
* @param format request format.
|
||||
* @see com.msopentech.odatajclient.engine.format.ODataFormat
|
||||
* @see com.msopentech.odatajclient.engine.format.ODataPubFormat
|
||||
*/
|
||||
void setFormat(T format);
|
||||
void setFormat(ODataFormat format);
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ 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.ODataDeleteResponse;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData delete request.
|
||||
*/
|
||||
public interface ODataDeleteRequest
|
||||
extends ODataBasicRequest<ODataDeleteResponse, ODataPubFormat>, ODataBatchableRequest {
|
||||
extends ODataBasicRequest<ODataDeleteResponse>, ODataBatchableRequest {
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ 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.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
/**
|
||||
* This interface describes an OData create request.
|
||||
@ -30,5 +29,5 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
* @param <E> concrete ODataEntity implementation
|
||||
*/
|
||||
public interface ODataEntityCreateRequest<E extends CommonODataEntity>
|
||||
extends ODataBasicRequest<ODataEntityCreateResponse<E>, ODataPubFormat>, ODataBatchableRequest {
|
||||
extends ODataBasicRequest<ODataEntityCreateResponse<E>>, ODataBatchableRequest {
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ 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.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData update request.
|
||||
@ -30,5 +29,5 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
* @param <E> concrete ODataEntity implementation
|
||||
*/
|
||||
public interface ODataEntityUpdateRequest<E extends CommonODataEntity>
|
||||
extends ODataBasicRequest<ODataEntityUpdateResponse<E>, ODataPubFormat>, ODataBatchableRequest {
|
||||
extends ODataBasicRequest<ODataEntityUpdateResponse<E>>, ODataBatchableRequest {
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ 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.ODataPropertyUpdateResponse;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData update entity property request.
|
||||
*/
|
||||
public interface ODataPropertyUpdateRequest
|
||||
extends ODataBasicRequest<ODataPropertyUpdateResponse, ODataFormat>, ODataBatchableRequest {
|
||||
extends ODataBasicRequest<ODataPropertyUpdateResponse>, ODataBatchableRequest {
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ 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.ODataValueUpdateResponse;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData update entity property value request.
|
||||
*/
|
||||
public interface ODataValueUpdateRequest
|
||||
extends ODataBasicRequest<ODataValueUpdateResponse, ODataValueFormat>, ODataBatchableRequest {
|
||||
extends ODataBasicRequest<ODataValueUpdateResponse>, ODataBatchableRequest {
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.cud.v3;
|
||||
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.ODataLinkOperationResponse;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an insert link OData request.
|
||||
*/
|
||||
public interface ODataLinkCreateRequest
|
||||
extends ODataBasicRequest<ODataLinkOperationResponse, ODataFormat>, ODataBatchableRequest {
|
||||
extends ODataBasicRequest<ODataLinkOperationResponse>, ODataBatchableRequest {
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.cud.v3;
|
||||
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.ODataLinkOperationResponse;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an update link OData request.
|
||||
*/
|
||||
public interface ODataLinkUpdateRequest
|
||||
extends ODataBasicRequest<ODataLinkOperationResponse, ODataFormat>, ODataBatchableRequest {
|
||||
extends ODataBasicRequest<ODataLinkOperationResponse>, ODataBatchableRequest {
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
package org.apache.olingo.client.api.communication.request.invoke;
|
||||
|
||||
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.format.ODataPubFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData invoke operation request.
|
||||
@ -31,7 +31,7 @@ import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
* @param <T> the actual invoke result
|
||||
*/
|
||||
public interface ODataInvokeRequest<T extends ODataInvokeResult>
|
||||
extends ODataBasicRequest<ODataInvokeResponse<T>, ODataPubFormat> {
|
||||
extends ODataBasicRequest<ODataInvokeResponse<T>> {
|
||||
|
||||
/**
|
||||
* Sets operation parameters.
|
||||
|
@ -19,10 +19,9 @@
|
||||
package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements a metadata query request.
|
||||
*/
|
||||
public interface EdmMetadataRequest extends ODataRetrieveRequest<Edm, ODataFormat> {
|
||||
public interface EdmMetadataRequest extends ODataRetrieveRequest<Edm> {
|
||||
}
|
||||
|
@ -19,10 +19,9 @@
|
||||
package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
/**
|
||||
* Describes an OData retrieve query request returning a single entity.
|
||||
*/
|
||||
public interface ODataEntityRequest<E extends CommonODataEntity> extends ODataRetrieveRequest<E, ODataPubFormat> {
|
||||
public interface ODataEntityRequest<E extends CommonODataEntity> extends ODataRetrieveRequest<E> {
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData EntitySet query request.
|
||||
*/
|
||||
public interface ODataEntitySetIteratorRequest<ES extends CommonODataEntitySet, E extends CommonODataEntity>
|
||||
extends ODataRetrieveRequest<ODataEntitySetIterator<ES, E>, ODataPubFormat> {
|
||||
extends ODataRetrieveRequest<ODataEntitySetIterator<ES, E>> {
|
||||
}
|
||||
|
@ -19,13 +19,11 @@
|
||||
package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
/**
|
||||
* This interface describes an OData EntitySet query request.
|
||||
*
|
||||
* @param <ES> concrete ODataEntitySet implementation
|
||||
*/
|
||||
public interface ODataEntitySetRequest<ES extends CommonODataEntitySet>
|
||||
extends ODataRetrieveRequest<ES, ODataPubFormat> {
|
||||
public interface ODataEntitySetRequest<ES extends CommonODataEntitySet> extends ODataRetrieveRequest<ES> {
|
||||
}
|
||||
|
@ -19,10 +19,9 @@
|
||||
package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
|
||||
import java.io.InputStream;
|
||||
import org.apache.olingo.commons.api.format.ODataMediaFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData media query request.
|
||||
*/
|
||||
public interface ODataMediaRequest extends ODataRetrieveRequest<InputStream, ODataMediaFormat> {
|
||||
public interface ODataMediaRequest extends ODataRetrieveRequest<InputStream> {
|
||||
}
|
||||
|
@ -24,5 +24,5 @@ import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
/**
|
||||
* This class implements an OData entity property query request.
|
||||
*/
|
||||
public interface ODataPropertyRequest<T extends CommonODataProperty> extends ODataRetrieveRequest<T, ODataFormat> {
|
||||
public interface ODataPropertyRequest<T extends CommonODataProperty> extends ODataRetrieveRequest<T> {
|
||||
}
|
||||
|
@ -21,11 +21,10 @@ package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
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.ODataRetrieveResponse;
|
||||
import org.apache.olingo.commons.api.format.Format;
|
||||
|
||||
/**
|
||||
* This is an abstract representation of an OData retrieve query request returning one or more result item.
|
||||
*/
|
||||
public interface ODataRetrieveRequest<V, T extends Format>
|
||||
extends ODataBasicRequest<ODataRetrieveResponse<V>, T>, ODataBatchableRequest {
|
||||
public interface ODataRetrieveRequest<T>
|
||||
extends ODataBasicRequest<ODataRetrieveResponse<T>>, ODataBatchableRequest {
|
||||
}
|
||||
|
@ -19,10 +19,9 @@
|
||||
package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
|
||||
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData service document request.
|
||||
*/
|
||||
public interface ODataServiceDocumentRequest extends ODataRetrieveRequest<ODataServiceDocument, ODataFormat> {
|
||||
public interface ODataServiceDocumentRequest extends ODataRetrieveRequest<ODataServiceDocument> {
|
||||
}
|
||||
|
@ -19,10 +19,9 @@
|
||||
package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
|
||||
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData entity property value query request.
|
||||
*/
|
||||
public interface ODataValueRequest extends ODataRetrieveRequest<ODataPrimitiveValue, ODataValueFormat> {
|
||||
public interface ODataValueRequest extends ODataRetrieveRequest<ODataPrimitiveValue> {
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
package org.apache.olingo.client.api.communication.request.retrieve;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.olingo.client.api.edm.xml.Schema;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an XML metadata request.
|
||||
*/
|
||||
public interface XMLMetadataRequest extends ODataRetrieveRequest<Map<String, Schema>, ODataFormat> {
|
||||
public interface XMLMetadataRequest extends ODataRetrieveRequest<Map<String, Schema>> {
|
||||
}
|
||||
|
@ -20,10 +20,9 @@ package org.apache.olingo.client.api.communication.request.retrieve.v3;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataRetrieveRequest;
|
||||
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData link query request.
|
||||
*/
|
||||
public interface ODataLinkCollectionRequest extends ODataRetrieveRequest<ODataLinkCollection, ODataFormat> {
|
||||
public interface ODataLinkCollectionRequest extends ODataRetrieveRequest<ODataLinkCollection> {
|
||||
}
|
||||
|
@ -20,10 +20,9 @@ package org.apache.olingo.client.api.communication.request.retrieve.v4;
|
||||
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataRetrieveRequest;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataDelta;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
|
||||
/**
|
||||
* Describes an OData retrieve request returning a delta object.
|
||||
*/
|
||||
public interface ODataDeltaRequest extends ODataRetrieveRequest<ODataDelta, ODataPubFormat> {
|
||||
public interface ODataDeltaRequest extends ODataRetrieveRequest<ODataDelta> {
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ 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.request.ODataStreamedRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* Abstract class representing a request concerning a streamed entity.
|
||||
@ -36,15 +36,15 @@ public interface ODataStreamedEntityRequest<V extends ODataResponse, T extends O
|
||||
* Returns resource representation format.
|
||||
*
|
||||
* @return the configured format (or default if not specified).
|
||||
* @see org.apache.olingo.client.api.Configuration#getDefaultPubFormat()
|
||||
* @see org.apache.olingo.client.api.CommonConfiguration#getDefaultPubFormat()
|
||||
*/
|
||||
ODataPubFormat getFormat();
|
||||
ODataFormat getFormat();
|
||||
|
||||
/**
|
||||
* Override configured request format.
|
||||
*
|
||||
* @param format request format.
|
||||
* @see org.apache.olingo.client.api.format.ODataFormat
|
||||
* @see ODataFormat
|
||||
*/
|
||||
void setFormat(final ODataPubFormat format);
|
||||
void setFormat(final ODataFormat format);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -56,11 +56,11 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ODataEntitySetIterator.class);
|
||||
|
||||
private final CommonODataClient odataClient;
|
||||
private final CommonODataClient<?> odataClient;
|
||||
|
||||
private final InputStream stream;
|
||||
|
||||
private final ODataPubFormat format;
|
||||
private final ODataFormat format;
|
||||
|
||||
private ResWrap<Entity> cached;
|
||||
|
||||
@ -80,14 +80,14 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
|
||||
* @param format OData format.
|
||||
*/
|
||||
public ODataEntitySetIterator(final CommonODataClient<?> odataClient, final InputStream stream,
|
||||
final ODataPubFormat format) {
|
||||
final ODataFormat format) {
|
||||
|
||||
this.odataClient = odataClient;
|
||||
this.stream = stream;
|
||||
this.format = format;
|
||||
this.osEntitySet = new ByteArrayOutputStream();
|
||||
|
||||
if (format == ODataPubFormat.ATOM) {
|
||||
if (format == ODataFormat.ATOM) {
|
||||
namespaces = getAllElementAttributes(stream, "feed", osEntitySet);
|
||||
} else {
|
||||
namespaces = null;
|
||||
@ -112,7 +112,7 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean hasNext() {
|
||||
if (available && cached == null) {
|
||||
if (format == ODataPubFormat.ATOM) {
|
||||
if (format == ODataFormat.ATOM) {
|
||||
cached = nextAtomEntityFromEntitySet(stream, osEntitySet, namespaces);
|
||||
} else {
|
||||
cached = nextJSONEntityFromEntitySet(stream, osEntitySet);
|
||||
@ -213,7 +213,7 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
|
||||
}
|
||||
|
||||
if (c >= 0) {
|
||||
jsonEntity = odataClient.getDeserializer(ODataPubFormat.JSON).toEntity(
|
||||
jsonEntity = odataClient.getDeserializer(ODataFormat.JSON).toEntity(
|
||||
new ByteArrayInputStream(entity.toByteArray()));
|
||||
}
|
||||
} else {
|
||||
@ -242,7 +242,7 @@ public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends C
|
||||
entity.write(">".getBytes(Constants.UTF8));
|
||||
|
||||
if (consume(input, "</entry>", entity, true) >= 0) {
|
||||
atomEntity = odataClient.getDeserializer(ODataPubFormat.ATOM).
|
||||
atomEntity = odataClient.getDeserializer(ODataFormat.ATOM).
|
||||
toEntity(new ByteArrayInputStream(entity.toByteArray()));
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ import org.apache.olingo.commons.api.domain.ODataError;
|
||||
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
|
||||
|
||||
/**
|
||||
@ -77,7 +76,7 @@ public interface CommonODataReader {
|
||||
* @return de-serialized entity set.
|
||||
* @throws ODataDeserializerException
|
||||
*/
|
||||
CommonODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
|
||||
CommonODataEntitySet readEntitySet(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
||||
|
||||
/**
|
||||
* Parses a stream taking care to de-serializes the first OData entity found.
|
||||
@ -87,7 +86,7 @@ public interface CommonODataReader {
|
||||
* @return entity de-serialized.
|
||||
* @throws ODataDeserializerException
|
||||
*/
|
||||
CommonODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
|
||||
CommonODataEntity readEntity(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
||||
|
||||
/**
|
||||
* Parses a stream taking care to de-serialize the first OData entity property found.
|
||||
|
@ -25,7 +25,6 @@ import org.apache.olingo.commons.api.domain.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataProperty;
|
||||
import org.apache.olingo.commons.api.domain.ODataLink;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
|
||||
/**
|
||||
@ -45,7 +44,7 @@ public interface ODataWriter {
|
||||
* @return stream of serialized objects.
|
||||
* @throws ODataSerializerException
|
||||
*/
|
||||
InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format)
|
||||
InputStream writeEntities(Collection<CommonODataEntity> entities, ODataFormat format)
|
||||
throws ODataSerializerException;
|
||||
|
||||
/**
|
||||
@ -56,7 +55,7 @@ public interface ODataWriter {
|
||||
* @return stream of serialized object.
|
||||
* @throws ODataSerializerException
|
||||
*/
|
||||
InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format)
|
||||
InputStream writeEntity(CommonODataEntity entity, ODataFormat format)
|
||||
throws ODataSerializerException;
|
||||
|
||||
/**
|
||||
|
@ -21,21 +21,20 @@ package org.apache.olingo.client.api.serialization.v3;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.client.api.serialization.CommonODataReader;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
|
||||
|
||||
public interface ODataReader extends CommonODataReader {
|
||||
|
||||
@Override
|
||||
ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
|
||||
ODataEntitySet readEntitySet(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
||||
|
||||
@Override
|
||||
ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
|
||||
ODataEntity readEntity(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
||||
|
||||
@Override
|
||||
ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
||||
|
@ -25,16 +25,15 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
|
||||
|
||||
public interface ODataReader extends CommonODataReader {
|
||||
|
||||
@Override
|
||||
ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
|
||||
ODataEntitySet readEntitySet(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
||||
|
||||
@Override
|
||||
ODataEntity readEntity(InputStream input, ODataPubFormat format) throws ODataDeserializerException;
|
||||
ODataEntity readEntity(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
||||
|
||||
@Override
|
||||
ODataProperty readProperty(InputStream input, ODataFormat format) throws ODataDeserializerException;
|
||||
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.client.api.v3;
|
||||
|
||||
import org.apache.olingo.client.api.CommonConfiguration;
|
||||
|
||||
public interface Configuration extends CommonConfiguration {
|
||||
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.olingo.client.api.v3;
|
||||
|
||||
import org.apache.olingo.client.api.CommonConfiguration;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory;
|
||||
import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory;
|
||||
@ -26,18 +27,18 @@ import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRe
|
||||
import org.apache.olingo.client.api.serialization.v3.ODataBinder;
|
||||
import org.apache.olingo.client.api.serialization.v3.ODataDeserializer;
|
||||
import org.apache.olingo.client.api.serialization.v3.ODataReader;
|
||||
import org.apache.olingo.client.api.uri.v3.URIBuilder;
|
||||
import org.apache.olingo.client.api.uri.v3.FilterFactory;
|
||||
import org.apache.olingo.client.api.uri.v3.URIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
|
||||
import org.apache.olingo.commons.api.format.Format;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
public interface ODataClient extends CommonODataClient<UpdateType> {
|
||||
|
||||
@Override
|
||||
Configuration getConfiguration();
|
||||
CommonConfiguration getConfiguration();
|
||||
|
||||
@Override
|
||||
ODataDeserializer getDeserializer(Format format);
|
||||
ODataDeserializer getDeserializer(ODataFormat format);
|
||||
|
||||
@Override
|
||||
ODataReader getReader();
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.olingo.client.api.v4;
|
||||
|
||||
import org.apache.olingo.client.api.CommonConfiguration;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory;
|
||||
import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory;
|
||||
@ -27,19 +28,19 @@ import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory
|
||||
import org.apache.olingo.client.api.serialization.v4.ODataBinder;
|
||||
import org.apache.olingo.client.api.serialization.v4.ODataDeserializer;
|
||||
import org.apache.olingo.client.api.serialization.v4.ODataReader;
|
||||
import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
||||
import org.apache.olingo.client.api.uri.v4.FilterFactory;
|
||||
import org.apache.olingo.client.api.uri.v4.SearchFactory;
|
||||
import org.apache.olingo.client.api.uri.v4.URIBuilder;
|
||||
import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
|
||||
import org.apache.olingo.commons.api.format.Format;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
public interface ODataClient extends CommonODataClient<UpdateType> {
|
||||
|
||||
@Override
|
||||
Configuration getConfiguration();
|
||||
CommonConfiguration getConfiguration();
|
||||
|
||||
@Override
|
||||
ODataDeserializer getDeserializer(Format format);
|
||||
ODataDeserializer getDeserializer(ODataFormat format);
|
||||
|
||||
@Override
|
||||
ODataReader getReader();
|
||||
|
@ -26,8 +26,6 @@ import org.apache.olingo.client.core.serialization.ODataWriterImpl;
|
||||
|
||||
public abstract class AbstractODataClient<UT extends CommonUpdateType> implements CommonODataClient<UT> {
|
||||
|
||||
private static final long serialVersionUID = 7269096702397630265L;
|
||||
|
||||
private final ODataWriter writer = new ODataWriterImpl(this);
|
||||
|
||||
@Override
|
||||
|
@ -24,22 +24,19 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.olingo.client.api.CommonConfiguration;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataMediaFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
import org.apache.olingo.client.api.http.HttpClientFactory;
|
||||
import org.apache.olingo.client.api.http.HttpUriRequestFactory;
|
||||
import org.apache.olingo.client.core.http.DefaultHttpClientFactory;
|
||||
import org.apache.olingo.client.core.http.DefaultHttpUriRequestFactory;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
public abstract class AbstractConfiguration implements CommonConfiguration {
|
||||
public class Configuration implements CommonConfiguration {
|
||||
|
||||
private static final String DEFAULT_PUB_FORMAT = "pubFormat";
|
||||
|
||||
private static final String DEFAULT_VALUE_FORMAT = "valueFormat";
|
||||
|
||||
|
||||
private static final String DEFAULT_BATCH_ACCEPT_FORMAT = "batchAcceptFormat";
|
||||
|
||||
private static final String DEFAULT_MEDIA_FORMAT = "valueFormat";
|
||||
@ -60,8 +57,6 @@ public abstract class AbstractConfiguration implements CommonConfiguration {
|
||||
|
||||
private static final String CHUNKING = "chunking";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Map<String, Object> CONF = new HashMap<String, Object>();
|
||||
|
||||
private transient ExecutorService executor = Executors.newFixedThreadPool(10);
|
||||
@ -89,71 +84,49 @@ public abstract class AbstractConfiguration implements CommonConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultBatchAcceptFormat() {
|
||||
return getProperty(DEFAULT_BATCH_ACCEPT_FORMAT, ContentType.MULTIPART_MIXED).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultBatchAcceptFormat(final String contentType) {
|
||||
setProperty(DEFAULT_BATCH_ACCEPT_FORMAT, contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataPubFormat getDefaultPubFormat() {
|
||||
return ODataPubFormat.valueOf(
|
||||
getProperty(DEFAULT_PUB_FORMAT, ODataPubFormat.JSON_FULL_METADATA.name()).toString());
|
||||
public ContentType getDefaultBatchAcceptFormat() {
|
||||
return (ContentType) getProperty(DEFAULT_BATCH_ACCEPT_FORMAT, ContentType.MULTIPART_MIXED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultPubFormat(final ODataPubFormat format) {
|
||||
setProperty(DEFAULT_PUB_FORMAT, format.name());
|
||||
public void setDefaultBatchAcceptFormat(final ContentType contentType) {
|
||||
setProperty(DEFAULT_BATCH_ACCEPT_FORMAT, contentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultPubFormat() {
|
||||
return (ODataFormat) getProperty(DEFAULT_PUB_FORMAT, ODataFormat.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultPubFormat(final ODataFormat format) {
|
||||
setProperty(DEFAULT_PUB_FORMAT, format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
ODataFormat format;
|
||||
|
||||
switch (getDefaultPubFormat()) {
|
||||
case ATOM:
|
||||
format = ODataFormat.XML;
|
||||
break;
|
||||
|
||||
case JSON_FULL_METADATA:
|
||||
format = ODataFormat.JSON_FULL_METADATA;
|
||||
break;
|
||||
|
||||
case JSON_NO_METADATA:
|
||||
format = ODataFormat.JSON_NO_METADATA;
|
||||
break;
|
||||
|
||||
case JSON:
|
||||
default:
|
||||
format = ODataFormat.JSON;
|
||||
}
|
||||
|
||||
return format;
|
||||
ODataFormat format = getDefaultPubFormat();
|
||||
return format == ODataFormat.ATOM ? ODataFormat.XML : format;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataValueFormat getDefaultValueFormat() {
|
||||
return ODataValueFormat.valueOf(
|
||||
getProperty(DEFAULT_VALUE_FORMAT, ODataValueFormat.TEXT.name()).toString());
|
||||
public ODataFormat getDefaultValueFormat() {
|
||||
return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultValueFormat(final ODataValueFormat format) {
|
||||
setProperty(DEFAULT_VALUE_FORMAT, format.name());
|
||||
public void setDefaultValueFormat(final ODataFormat format) {
|
||||
setProperty(DEFAULT_VALUE_FORMAT, format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataMediaFormat getDefaultMediaFormat() {
|
||||
return ODataMediaFormat.valueOf(
|
||||
getProperty(DEFAULT_VALUE_FORMAT, ODataMediaFormat.APPLICATION_OCTET_STREAM.name()).toString());
|
||||
public ODataFormat getDefaultMediaFormat() {
|
||||
return (ODataFormat) getProperty(DEFAULT_VALUE_FORMAT, ODataFormat.APPLICATION_OCTET_STREAM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultMediaFormat(final ODataMediaFormat format) {
|
||||
setProperty(DEFAULT_MEDIA_FORMAT, format.name());
|
||||
public void setDefaultMediaFormat(final ODataFormat format) {
|
||||
setProperty(DEFAULT_MEDIA_FORMAT, format);
|
||||
}
|
||||
|
||||
@Override
|
@ -18,7 +18,8 @@
|
||||
*/
|
||||
package org.apache.olingo.client.core;
|
||||
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
|
||||
public final class ODataClientFactory {
|
||||
|
||||
@ -29,7 +30,7 @@ public final class ODataClientFactory {
|
||||
public static org.apache.olingo.client.api.v3.EdmEnabledODataClient getEdmEnabledV3(final String serviceRoot) {
|
||||
final org.apache.olingo.client.api.v3.EdmEnabledODataClient instance =
|
||||
new org.apache.olingo.client.core.v3.EdmEnabledODataClientImpl(serviceRoot);
|
||||
instance.getConfiguration().setDefaultPubFormat(ODataPubFormat.JSON);
|
||||
instance.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -40,7 +41,7 @@ public final class ODataClientFactory {
|
||||
public static org.apache.olingo.client.api.v4.EdmEnabledODataClient getEdmEnabledV4(final String serviceRoot) {
|
||||
final org.apache.olingo.client.api.v4.EdmEnabledODataClient instance =
|
||||
new org.apache.olingo.client.core.v4.EdmEnabledODataClientImpl(serviceRoot);
|
||||
instance.getConfiguration().setDefaultPubFormat(ODataPubFormat.JSON);
|
||||
instance.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -23,60 +23,51 @@ import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.ODataBatchConstants;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.ODataBatchConstants;
|
||||
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
|
||||
import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
||||
import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||
import org.apache.olingo.commons.api.format.Format;
|
||||
import org.apache.olingo.client.api.http.HttpMethod;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* Basic request abstract implementation.
|
||||
*
|
||||
* @param <V> OData response type corresponding to the request implementation.
|
||||
* @param <T> OData format being used.
|
||||
* @param <T> OData response type corresponding to the request implementation.
|
||||
*/
|
||||
public abstract class AbstractODataBasicRequest<V extends ODataResponse, T extends Format>
|
||||
extends AbstractODataRequest<T>
|
||||
implements ODataBasicRequest<V, T> {
|
||||
public abstract class AbstractODataBasicRequest<T extends ODataResponse>
|
||||
extends AbstractODataRequest implements ODataBasicRequest<T> {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param odataClient client instance getting this request
|
||||
* @param formatRef reference class for the format being used
|
||||
* @param method request method.
|
||||
* @param uri OData request URI.
|
||||
*/
|
||||
public AbstractODataBasicRequest(final CommonODataClient<?> odataClient,
|
||||
final Class<T> formatRef, final HttpMethod method, final URI uri) {
|
||||
|
||||
super(odataClient, formatRef, method, uri);
|
||||
public AbstractODataBasicRequest(final CommonODataClient<?> odataClient, final HttpMethod method, final URI uri) {
|
||||
super(odataClient, method, uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setFormat(final T format) {
|
||||
public void setFormat(final ODataFormat format) {
|
||||
if (format != null) {
|
||||
setAccept(format.toString(odataClient.getServiceVersion()));
|
||||
setContentType(format.toString(odataClient.getServiceVersion()));
|
||||
final String formatString = format.getContentType(odataClient.getServiceVersion()).toContentTypeString();
|
||||
setAccept(formatString);
|
||||
setContentType(formatString);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public final Future<V> asyncExecute() {
|
||||
return odataClient.getConfiguration().getExecutor().submit(new Callable<V>() {
|
||||
public final Future<T> asyncExecute() {
|
||||
return odataClient.getConfiguration().getExecutor().submit(new Callable<T>() {
|
||||
@Override
|
||||
public V call() throws Exception {
|
||||
public T call() throws Exception {
|
||||
return execute();
|
||||
}
|
||||
});
|
||||
|
@ -24,6 +24,7 @@ import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.Header;
|
||||
@ -38,33 +39,23 @@ import org.apache.olingo.client.api.communication.header.ODataHeaders;
|
||||
import org.apache.olingo.client.api.communication.request.ODataRequest;
|
||||
import org.apache.olingo.client.api.communication.request.ODataStreamer;
|
||||
import org.apache.olingo.client.api.communication.response.ODataResponse;
|
||||
import org.apache.olingo.commons.api.format.Format;
|
||||
import org.apache.olingo.client.api.http.HttpClientException;
|
||||
import org.apache.olingo.client.api.http.HttpMethod;
|
||||
import org.apache.olingo.commons.api.format.ODataMediaFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* Abstract representation of an OData request. Get instance by using factories.
|
||||
*
|
||||
* @param <T> Accepted content-type formats by the request in object.
|
||||
*
|
||||
* @see org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory
|
||||
* @see org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory
|
||||
* @see org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory
|
||||
* @see org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory
|
||||
* @see org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory
|
||||
* @see org.apache.olingo.client.api.communication.request.invoke.v4.InvokeRequestFactory
|
||||
* @see org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory
|
||||
* @see org.apache.olingo.client.api.communication.request.streamed.v4.StreamedRequestFactory
|
||||
* @see org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory
|
||||
*/
|
||||
public abstract class AbstractODataRequest<T extends Format> extends AbstractRequest implements ODataRequest {
|
||||
public abstract class AbstractODataRequest extends AbstractRequest implements ODataRequest {
|
||||
|
||||
protected final CommonODataClient<?> odataClient;
|
||||
|
||||
private final Class<T> formatRef;
|
||||
|
||||
/**
|
||||
* OData request method.
|
||||
*/
|
||||
@ -93,17 +84,13 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param odataClient client instance getting this request
|
||||
* @param formatRef reference class for the format being used
|
||||
* @param method HTTP request method. If configured X-HTTP-METHOD header will be used.
|
||||
* @param uri OData request URI.
|
||||
* @param odataClient client instance getting this request
|
||||
* @param method HTTP request method. If configured X-HTTP-METHOD header will be used.
|
||||
* @param uri OData request URI.
|
||||
*/
|
||||
protected AbstractODataRequest(final CommonODataClient<?> odataClient,
|
||||
final Class<T> formatRef, final HttpMethod method, final URI uri) {
|
||||
protected AbstractODataRequest(final CommonODataClient<?> odataClient, final HttpMethod method, final URI uri) {
|
||||
|
||||
this.odataClient = odataClient;
|
||||
|
||||
this.formatRef = formatRef;
|
||||
this.method = method;
|
||||
|
||||
// initialize default headers
|
||||
@ -123,171 +110,108 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq
|
||||
createHttpUriRequest(this.method, this.uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getDefaultFormat() {
|
||||
return (T) (formatRef.equals(ODataPubFormat.class)
|
||||
? odataClient.getConfiguration().getDefaultPubFormat()
|
||||
: (formatRef.equals(ODataValueFormat.class)
|
||||
? odataClient.getConfiguration().getDefaultValueFormat()
|
||||
: (formatRef.equals(ODataMediaFormat.class)
|
||||
? odataClient.getConfiguration().getDefaultMediaFormat()
|
||||
: odataClient.getConfiguration().getDefaultFormat())));
|
||||
}
|
||||
public abstract ODataFormat getDefaultFormat();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Collection<String> getHeaderNames() {
|
||||
return odataHeaders.getHeaderNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHeader(final String name) {
|
||||
return odataHeaders.getHeader(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataRequest setAccept(final String value) {
|
||||
odataHeaders.setHeader(HeaderName.accept, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataRequest setIfMatch(final String value) {
|
||||
odataHeaders.setHeader(HeaderName.ifMatch, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataRequest setIfNoneMatch(final String value) {
|
||||
odataHeaders.setHeader(HeaderName.ifNoneMatch, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataRequest setPrefer(final String value) {
|
||||
odataHeaders.setHeader(HeaderName.prefer, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataRequest setXHTTPMethod(final String value) {
|
||||
odataHeaders.setHeader(HeaderName.xHttpMethod, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataRequest setContentType(final String value) {
|
||||
odataHeaders.setHeader(HeaderName.contentType, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataRequest setSlug(final String value) {
|
||||
odataHeaders.setHeader(HeaderName.slug, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataRequest addCustomHeader(final String name, final String value) {
|
||||
odataHeaders.setHeader(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataRequest addCustomHeader(final HeaderName name, final String value) {
|
||||
odataHeaders.setHeader(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getAccept() {
|
||||
final String acceptHead = odataHeaders.getHeader(HeaderName.accept);
|
||||
return StringUtils.isBlank(acceptHead) ? getDefaultFormat().toString(odataClient.getServiceVersion()) : acceptHead;
|
||||
return StringUtils.isBlank(acceptHead) ?
|
||||
getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString() :
|
||||
acceptHead;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getIfMatch() {
|
||||
return odataHeaders.getHeader(HeaderName.ifMatch);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getIfNoneMatch() {
|
||||
return odataHeaders.getHeader(HeaderName.ifNoneMatch);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getPrefer() {
|
||||
return odataHeaders.getHeader(HeaderName.prefer);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getContentType() {
|
||||
final String contentTypeHead = odataHeaders.getHeader(HeaderName.contentType);
|
||||
return StringUtils.isBlank(contentTypeHead)
|
||||
? getDefaultFormat().toString(odataClient.getServiceVersion()) : contentTypeHead;
|
||||
return StringUtils.isBlank(contentTypeHead) ?
|
||||
getDefaultFormat().getContentType(odataClient.getServiceVersion()).toContentTypeString() :
|
||||
contentTypeHead;
|
||||
}
|
||||
|
||||
/**
|
||||
* ${@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return method;
|
||||
@ -302,9 +226,6 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq
|
||||
return odataHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public byte[] toByteArray() {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
@ -341,9 +262,6 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public InputStream rawExecute() {
|
||||
try {
|
||||
|
@ -95,7 +95,7 @@ public class ODataBatchUtilities {
|
||||
* <p>
|
||||
* Usually used to read an entire batch part.
|
||||
*
|
||||
* @param batchController batch controller.
|
||||
* @param controller batch controller.
|
||||
* @param os destination stream of batch part (null to discard).
|
||||
* @param checkCurrent if 'TRUE' the current line will be included into the delimiter verification.
|
||||
* @return latest read line.
|
||||
@ -111,7 +111,7 @@ public class ODataBatchUtilities {
|
||||
* <p>
|
||||
* Usually used to read an entire batch part.
|
||||
*
|
||||
* @param batchController batch controller.
|
||||
* @param controller batch controller.
|
||||
* @param os destination stream of batch part (null to discard).
|
||||
* @param count number of batch line to be read.
|
||||
* @param checkCurrent if 'TRUE' the current line will be included into the delimiter verification.
|
||||
@ -302,7 +302,7 @@ public class ODataBatchUtilities {
|
||||
final String contentType = headers.containsKey(HeaderName.contentType.toString())
|
||||
? headers.get(HeaderName.contentType.toString()).toString() : StringUtils.EMPTY;
|
||||
|
||||
if (contentType.contains(ContentType.MULTIPART_MIXED)) {
|
||||
if (contentType.contains(ContentType.MULTIPART_MIXED.toContentTypeString())) {
|
||||
nextItemType = BatchItemType.CHANGESET;
|
||||
} else if (contentType.contains(ODataBatchConstants.ITEM_CONTENT_TYPE)) {
|
||||
nextItemType = BatchItemType.RETRIEVE;
|
||||
|
@ -49,7 +49,7 @@ public class ODataBatchRequestImpl
|
||||
|
||||
public ODataBatchRequestImpl(final ODataClient odataClient, final URI uri) {
|
||||
super(odataClient, uri);
|
||||
setAccept(odataClient.getConfiguration().getDefaultBatchAcceptFormat());
|
||||
setAccept(odataClient.getConfiguration().getDefaultBatchAcceptFormat().toContentTypeString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,7 +48,7 @@ public class ODataBatchRequestImpl
|
||||
|
||||
public ODataBatchRequestImpl(final ODataClient odataClient, final URI uri) {
|
||||
super(odataClient, uri);
|
||||
setAccept(odataClient.getConfiguration().getDefaultBatchAcceptFormat());
|
||||
setAccept(odataClient.getConfiguration().getDefaultBatchAcceptFormat().toContentTypeString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,21 +20,22 @@ package org.apache.olingo.client.core.communication.request.cud;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.client.api.http.HttpMethod;
|
||||
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData delete request.
|
||||
*/
|
||||
public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDeleteResponse, ODataPubFormat>
|
||||
implements ODataDeleteRequest {
|
||||
public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDeleteResponse>
|
||||
implements ODataDeleteRequest {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -43,13 +44,16 @@ public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDelet
|
||||
* @param method HTTP method to be used
|
||||
* @param uri URI of the entity to be deleted.
|
||||
*/
|
||||
ODataDeleteRequestImpl(final CommonODataClient odataClient, final HttpMethod method, final URI uri) {
|
||||
super(odataClient, ODataPubFormat.class, method, uri);
|
||||
ODataDeleteRequestImpl(final CommonODataClient<?> odataClient, final HttpMethod method, final URI uri) {
|
||||
super(odataClient, method, uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
* <p>
|
||||
* No payload: null will be returned.
|
||||
*/
|
||||
@Override
|
||||
@ -57,9 +61,6 @@ public class ODataDeleteRequestImpl extends AbstractODataBasicRequest<ODataDelet
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public ODataDeleteResponse execute() {
|
||||
return new ODataDeleteResponseImpl(httpClient, doExecute());
|
||||
|
@ -35,7 +35,7 @@ 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.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
|
||||
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
|
||||
@ -45,7 +45,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
* @param <E> concrete ODataEntity implementation
|
||||
*/
|
||||
public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
|
||||
extends AbstractODataBasicRequest<ODataEntityCreateResponse<E>, ODataPubFormat>
|
||||
extends AbstractODataBasicRequest<ODataEntityCreateResponse<E>>
|
||||
implements ODataEntityCreateRequest<E> {
|
||||
|
||||
/**
|
||||
@ -61,25 +61,24 @@ public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
|
||||
* @param entity entity to be created.
|
||||
*/
|
||||
ODataEntityCreateRequestImpl(final CommonODataClient<?> odataClient, final URI targetURI, final E entity) {
|
||||
super(odataClient, ODataPubFormat.class, HttpMethod.POST, targetURI);
|
||||
super(odataClient, HttpMethod.POST, targetURI);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InputStream getPayload() {
|
||||
try {
|
||||
return odataClient.getWriter().writeEntity(entity, ODataPubFormat.fromString(getContentType()));
|
||||
return odataClient.getWriter().writeEntity(entity, ODataFormat.fromString(getContentType()));
|
||||
} catch (final ODataSerializerException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public ODataEntityCreateResponse<E> execute() {
|
||||
final InputStream input = getPayload();
|
||||
@ -126,7 +125,7 @@ public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
|
||||
public E getBody() {
|
||||
if (entity == null) {
|
||||
try {
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getAccept()))
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept()))
|
||||
.toEntity(getRawResponse());
|
||||
|
||||
entity = (E) odataClient.getBinder().getODataEntity(resource);
|
||||
|
@ -35,7 +35,7 @@ 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.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
|
||||
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
|
||||
@ -45,7 +45,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
* @param <E> concrete ODataEntity implementation
|
||||
*/
|
||||
public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
|
||||
extends AbstractODataBasicRequest<ODataEntityUpdateResponse<E>, ODataPubFormat>
|
||||
extends AbstractODataBasicRequest<ODataEntityUpdateResponse<E>>
|
||||
implements ODataEntityUpdateRequest<E> {
|
||||
|
||||
/**
|
||||
@ -64,13 +64,15 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
|
||||
public ODataEntityUpdateRequestImpl(final CommonODataClient<?> odataClient,
|
||||
final HttpMethod method, final URI uri, final E changes) {
|
||||
|
||||
super(odataClient, ODataPubFormat.class, method, uri);
|
||||
super(odataClient, method, uri);
|
||||
this.changes = changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataEntityUpdateResponse<E> execute() {
|
||||
final InputStream input = getPayload();
|
||||
@ -86,7 +88,7 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
|
||||
@Override
|
||||
protected InputStream getPayload() {
|
||||
try {
|
||||
return odataClient.getWriter().writeEntity(changes, ODataPubFormat.fromString(getContentType()));
|
||||
return odataClient.getWriter().writeEntity(changes, ODataFormat.fromString(getContentType()));
|
||||
} catch (final ODataSerializerException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
@ -124,7 +126,7 @@ public class ODataEntityUpdateRequestImpl<E extends CommonODataEntity>
|
||||
public E getBody() {
|
||||
if (entity == null) {
|
||||
try {
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getAccept()))
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getAccept()))
|
||||
.toEntity(getRawResponse());
|
||||
|
||||
entity = (E) odataClient.getBinder().getODataEntity(resource);
|
||||
|
@ -42,8 +42,8 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
/**
|
||||
* This class implements an OData update entity property request.
|
||||
*/
|
||||
public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<ODataPropertyUpdateResponse, ODataFormat>
|
||||
implements ODataPropertyUpdateRequest {
|
||||
public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<ODataPropertyUpdateResponse>
|
||||
implements ODataPropertyUpdateRequest {
|
||||
|
||||
/**
|
||||
* Value to be created.
|
||||
@ -61,11 +61,16 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
|
||||
ODataPropertyUpdateRequestImpl(final CommonODataClient<?> odataClient,
|
||||
final HttpMethod method, final URI targetURI, final CommonODataProperty property) {
|
||||
|
||||
super(odataClient, ODataFormat.class, method, targetURI);
|
||||
super(odataClient, method, targetURI);
|
||||
// set request body
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataPropertyUpdateResponse execute() {
|
||||
final InputStream input = getPayload();
|
||||
|
@ -20,6 +20,7 @@ package org.apache.olingo.client.core.communication.request.cud;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
@ -27,20 +28,20 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataValueUpdateResponse;
|
||||
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
|
||||
import org.apache.olingo.commons.api.format.ODataValueFormat;
|
||||
import org.apache.olingo.client.api.http.HttpClientException;
|
||||
import org.apache.olingo.client.api.http.HttpMethod;
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData update entity property value request.
|
||||
*/
|
||||
public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<ODataValueUpdateResponse, ODataValueFormat>
|
||||
implements ODataValueUpdateRequest {
|
||||
public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<ODataValueUpdateResponse>
|
||||
implements ODataValueUpdateRequest {
|
||||
|
||||
/**
|
||||
* Value to be created.
|
||||
@ -55,17 +56,19 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
|
||||
* @param targetURI entity set or entity or entity property URI.
|
||||
* @param value value to be created.
|
||||
*/
|
||||
ODataValueUpdateRequestImpl(final CommonODataClient odataClient,
|
||||
ODataValueUpdateRequestImpl(final CommonODataClient<?> odataClient,
|
||||
final HttpMethod method, final URI targetURI, final ODataPrimitiveValue value) {
|
||||
|
||||
super(odataClient, ODataValueFormat.class, method, targetURI);
|
||||
super(odataClient, method, targetURI);
|
||||
// set request body
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultValueFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataValueUpdateResponse execute() {
|
||||
final InputStream input = getPayload();
|
||||
@ -118,11 +121,11 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
|
||||
@Override
|
||||
public ODataPrimitiveValue getBody() {
|
||||
if (value == null) {
|
||||
final ODataValueFormat format = ODataValueFormat.fromString(getAccept());
|
||||
final ODataFormat format = ODataFormat.fromString(getAccept());
|
||||
|
||||
try {
|
||||
value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
|
||||
setType(format == ODataValueFormat.TEXT
|
||||
setType(format == ODataFormat.TEXT_PLAIN
|
||||
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
||||
setText(IOUtils.toString(getRawResponse())).
|
||||
build();
|
||||
|
@ -39,7 +39,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
/**
|
||||
* This class implements an insert link OData request.
|
||||
*/
|
||||
public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse, ODataFormat>
|
||||
public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse>
|
||||
implements ODataLinkCreateRequest {
|
||||
|
||||
/**
|
||||
@ -55,14 +55,16 @@ public class ODataLinkCreateRequestImpl extends AbstractODataBasicRequest<ODataL
|
||||
* @param link entity to be linked.
|
||||
*/
|
||||
ODataLinkCreateRequestImpl(final CommonODataClient<?> odataClient, final URI targetURI, final ODataLink link) {
|
||||
super(odataClient, ODataFormat.class, HttpMethod.POST, targetURI);
|
||||
super(odataClient, HttpMethod.POST, targetURI);
|
||||
// set request body
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataLinkOperationResponse execute() {
|
||||
final InputStream input = getPayload();
|
||||
|
@ -39,8 +39,8 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
/**
|
||||
* This class implements an update link OData request.
|
||||
*/
|
||||
public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse, ODataFormat>
|
||||
implements ODataLinkUpdateRequest {
|
||||
public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataLinkOperationResponse>
|
||||
implements ODataLinkUpdateRequest {
|
||||
|
||||
/**
|
||||
* Entity to be linked.
|
||||
@ -57,12 +57,16 @@ public class ODataLinkUpdateRequestImpl extends AbstractODataBasicRequest<ODataL
|
||||
*/
|
||||
ODataLinkUpdateRequestImpl(final CommonODataClient<?> odataClient,
|
||||
final HttpMethod method, final URI targetURI, final ODataLink link) {
|
||||
|
||||
super(odataClient, ODataFormat.class, method, targetURI);
|
||||
super(odataClient, method, targetURI);
|
||||
// set request body
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataLinkOperationResponse execute() {
|
||||
final InputStream input = getPayload();
|
||||
|
@ -46,7 +46,6 @@ import org.apache.olingo.commons.api.domain.CommonODataProperty;
|
||||
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
|
||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
|
||||
import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
|
||||
@ -54,7 +53,7 @@ import org.apache.olingo.commons.api.serialization.ODataSerializerException;
|
||||
* This class implements an OData invoke operation request.
|
||||
*/
|
||||
public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
|
||||
extends AbstractODataBasicRequest<ODataInvokeResponse<T>, ODataPubFormat>
|
||||
extends AbstractODataBasicRequest<ODataInvokeResponse<T>>
|
||||
implements ODataInvokeRequest<T>, ODataBatchableRequest {
|
||||
|
||||
private final Class<T> reference;
|
||||
@ -78,15 +77,12 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
|
||||
final HttpMethod method,
|
||||
final URI uri) {
|
||||
|
||||
super(odataClient, ODataPubFormat.class, method, uri);
|
||||
super(odataClient, method, uri);
|
||||
|
||||
this.reference = reference;
|
||||
this.parameters = new LinkedHashMap<String, ODataValue>();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public void setParameters(final Map<String, ODataValue> parameters) {
|
||||
this.parameters.clear();
|
||||
@ -95,20 +91,25 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
|
||||
}
|
||||
}
|
||||
|
||||
private String getActualFormat(final ODataPubFormat format) {
|
||||
return (CommonODataProperty.class.isAssignableFrom(reference) && format == ODataPubFormat.ATOM)
|
||||
? ODataFormat.XML.toString(odataClient.getServiceVersion())
|
||||
: format.toString(odataClient.getServiceVersion());
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
private String getActualFormat(final ODataFormat format) {
|
||||
return ((CommonODataProperty.class.isAssignableFrom(reference) && format == ODataFormat.ATOM)
|
||||
? ODataFormat.XML : format)
|
||||
.getContentType(odataClient.getServiceVersion()).toContentTypeString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFormat(final ODataPubFormat format) {
|
||||
public void setFormat(final ODataFormat format) {
|
||||
final String _format = getActualFormat(format);
|
||||
setAccept(_format);
|
||||
setContentType(_format);
|
||||
}
|
||||
|
||||
protected abstract ODataPubFormat getPOSTParameterFormat();
|
||||
protected abstract ODataFormat getPOSTParameterFormat();
|
||||
|
||||
@Override
|
||||
protected InputStream getPayload() {
|
||||
@ -216,10 +217,10 @@ public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
|
||||
InputStream responseStream = this.payload == null ? res.getEntity().getContent() : this.payload;
|
||||
if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
|
||||
invokeResult = reference.cast(odataClient.getReader().readEntitySet(responseStream,
|
||||
ODataPubFormat.fromString(getContentType())));
|
||||
ODataFormat.fromString(getContentType())));
|
||||
} else if (CommonODataEntity.class.isAssignableFrom(reference)) {
|
||||
invokeResult = reference.cast(odataClient.getReader().readEntity(responseStream,
|
||||
ODataPubFormat.fromString(getContentType())));
|
||||
ODataFormat.fromString(getContentType())));
|
||||
} else if (CommonODataProperty.class.isAssignableFrom(reference)) {
|
||||
invokeResult = reference.cast(odataClient.getReader().readProperty(responseStream,
|
||||
ODataFormat.fromString(getContentType())));
|
||||
|
@ -21,6 +21,7 @@ package org.apache.olingo.client.core.communication.request.invoke.v3;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.http.HttpMethod;
|
||||
@ -28,7 +29,7 @@ import org.apache.olingo.client.core.communication.request.invoke.AbstractODataI
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
|
||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends AbstractODataInvokeRequest<T> {
|
||||
|
||||
@ -39,8 +40,8 @@ public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends Abstrac
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataPubFormat getPOSTParameterFormat() {
|
||||
return ODataPubFormat.JSON;
|
||||
protected ODataFormat getPOSTParameterFormat() {
|
||||
return ODataFormat.JSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.http.HttpMethod;
|
||||
import org.apache.olingo.client.core.communication.request.invoke.AbstractODataInvokeRequest;
|
||||
@ -29,11 +30,11 @@ import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.Constants;
|
||||
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
|
||||
import org.apache.olingo.commons.api.domain.ODataValue;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends AbstractODataInvokeRequest<T> {
|
||||
|
||||
private ODataPubFormat format;
|
||||
private ODataFormat format;
|
||||
|
||||
public ODataInvokeRequestImpl(final CommonODataClient<?> odataClient, final Class<T> reference,
|
||||
final HttpMethod method, final URI uri) {
|
||||
@ -42,13 +43,13 @@ public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends Abstrac
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFormat(final ODataPubFormat format) {
|
||||
public void setFormat(final ODataFormat format) {
|
||||
super.setFormat(format);
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ODataPubFormat getPOSTParameterFormat() {
|
||||
protected ODataFormat getPOSTParameterFormat() {
|
||||
return format == null ? getDefaultFormat() : format;
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,10 @@ import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.ODataRequest;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrieveRequest<V, ODataFormat> {
|
||||
public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrieveRequest<V> {
|
||||
|
||||
public AbstractMetadataRequestImpl(final CommonODataClient odataClient, final URI query) {
|
||||
super(odataClient, ODataFormat.class, query);
|
||||
public AbstractMetadataRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
|
||||
super(odataClient, query);
|
||||
super.setAccept(ContentType.APPLICATION_XML.getMimeType());
|
||||
super.setContentType(ContentType.APPLICATION_XML.getMimeType());
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ package org.apache.olingo.client.core.communication.request.retrieve;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataRetrieveRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.commons.api.format.Format;
|
||||
import org.apache.olingo.client.api.http.HttpMethod;
|
||||
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||
@ -33,32 +33,24 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
|
||||
/**
|
||||
* This is an abstract representation of an OData retrieve query request returning one or more result item.
|
||||
*/
|
||||
public abstract class AbstractODataRetrieveRequest<V, T extends Format>
|
||||
extends AbstractODataBasicRequest<ODataRetrieveResponse<V>, T>
|
||||
implements ODataRetrieveRequest<V, T> {
|
||||
public abstract class AbstractODataRetrieveRequest<T>
|
||||
extends AbstractODataBasicRequest<ODataRetrieveResponse<T>>
|
||||
implements ODataRetrieveRequest<T> {
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*
|
||||
* @param odataClient client instance getting this request
|
||||
* @param formatRef reference class for the format being used
|
||||
* @param query query to be executed.
|
||||
*/
|
||||
public AbstractODataRetrieveRequest(final CommonODataClient<?> odataClient, final Class<T> formatRef,
|
||||
final URI query) {
|
||||
|
||||
super(odataClient, formatRef, HttpMethod.GET, query);
|
||||
public AbstractODataRetrieveRequest(final CommonODataClient<?> odataClient, final URI query) {
|
||||
super(odataClient, HttpMethod.GET, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public abstract ODataRetrieveResponse<V> execute();
|
||||
public abstract ODataRetrieveResponse<T> execute();
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
* <p>
|
||||
* This kind of request doesn't have any payload: null will be returned.
|
||||
*/
|
||||
@Override
|
||||
@ -70,7 +62,7 @@ public abstract class AbstractODataRetrieveRequest<V, T extends Format>
|
||||
* Response abstract class about an ODataRetrieveRequest.
|
||||
*/
|
||||
protected abstract class AbstractODataRetrieveResponse
|
||||
extends AbstractODataResponse implements ODataRetrieveResponse<V> {
|
||||
extends AbstractODataResponse implements ODataRetrieveResponse<T> {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -95,10 +87,7 @@ public abstract class AbstractODataRetrieveRequest<V, T extends Format>
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public abstract V getBody();
|
||||
public abstract T getBody();
|
||||
}
|
||||
}
|
||||
|
@ -28,14 +28,14 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
|
||||
import org.apache.olingo.commons.api.data.Entity;
|
||||
import org.apache.olingo.commons.api.data.ResWrap;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
|
||||
|
||||
/**
|
||||
* This class implements an OData retrieve query request returning a single entity.
|
||||
*/
|
||||
public class ODataEntityRequestImpl<E extends CommonODataEntity>
|
||||
extends AbstractODataRetrieveRequest<E, ODataPubFormat> implements ODataEntityRequest<E> {
|
||||
extends AbstractODataRetrieveRequest<E> implements ODataEntityRequest<E> {
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
@ -44,7 +44,12 @@ public class ODataEntityRequestImpl<E extends CommonODataEntity>
|
||||
* @param query query to be executed.
|
||||
*/
|
||||
public ODataEntityRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
|
||||
super(odataClient, ODataPubFormat.class, query);
|
||||
super(odataClient, query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,7 +88,7 @@ public class ODataEntityRequestImpl<E extends CommonODataEntity>
|
||||
public E getBody() {
|
||||
if (entity == null) {
|
||||
try {
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataPubFormat.fromString(getContentType()))
|
||||
final ResWrap<Entity> resource = odataClient.getDeserializer(ODataFormat.fromString(getContentType()))
|
||||
.toEntity(getRawResponse());
|
||||
|
||||
entity = (E) odataClient.getBinder().getODataEntity(resource);
|
||||
|
@ -19,6 +19,7 @@
|
||||
package org.apache.olingo.client.core.communication.request.retrieve;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
@ -27,16 +28,16 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse
|
||||
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntity;
|
||||
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
|
||||
import org.apache.olingo.commons.api.format.ODataPubFormat;
|
||||
import org.apache.olingo.commons.api.format.ODataFormat;
|
||||
|
||||
/**
|
||||
* This class implements an OData EntitySet query request.
|
||||
*/
|
||||
public class ODataEntitySetIteratorRequestImpl<ES extends CommonODataEntitySet, E extends CommonODataEntity>
|
||||
extends AbstractODataRetrieveRequest<ODataEntitySetIterator<ES, E>, ODataPubFormat>
|
||||
extends AbstractODataRetrieveRequest<ODataEntitySetIterator<ES, E>>
|
||||
implements ODataEntitySetIteratorRequest<ES, E> {
|
||||
|
||||
private ODataEntitySetIterator entitySetIterator = null;
|
||||
private ODataEntitySetIterator<ES, E> entitySetIterator = null;
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
@ -45,12 +46,14 @@ public class ODataEntitySetIteratorRequestImpl<ES extends CommonODataEntitySet,
|
||||
* @param query query to be executed.
|
||||
*/
|
||||
public ODataEntitySetIteratorRequestImpl(final CommonODataClient<?> odataClient, final URI query) {
|
||||
super(odataClient, ODataPubFormat.class, query);
|
||||
super(odataClient, query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ODataFormat getDefaultFormat() {
|
||||
return odataClient.getConfiguration().getDefaultPubFormat();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
public ODataRetrieveResponse<ODataEntitySetIterator<ES, E>> execute() {
|
||||
final HttpResponse res = doExecute();
|
||||
@ -72,15 +75,11 @@ public class ODataEntitySetIteratorRequestImpl<ES extends CommonODataEntitySet,
|
||||
super(client, res);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc }
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public ODataEntitySetIterator<ES, E> getBody() {
|
||||
if (entitySetIterator == null) {
|
||||
entitySetIterator = new ODataEntitySetIterator<ES, E>(
|
||||
odataClient, getRawResponse(), ODataPubFormat.fromString(getContentType()));
|
||||
odataClient, getRawResponse(), ODataFormat.fromString(getContentType()));
|
||||
}
|
||||
return entitySetIterator;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user