[OLINGO-1004] Remove duplicate EntitySetTests
Duplicated in BasicITCase
This commit is contained in:
parent
5f11f5b1d2
commit
0e5b2eff28
|
@ -22,21 +22,12 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.olingo.client.api.ODataClient;
|
||||
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;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRawResponse;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.data.ResWrap;
|
||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||
import org.apache.olingo.client.api.domain.ClientEntitySet;
|
||||
import org.apache.olingo.client.api.domain.ClientEntitySetIterator;
|
||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.format.ContentType;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -45,62 +36,6 @@ import org.junit.Test;
|
|||
*/
|
||||
public class EntitySetTestITCase extends AbstractTestITCase {
|
||||
|
||||
private void rawRequest(final ContentType contentType) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(contentType.toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
||||
final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class);
|
||||
assertNotNull(entitySet.getPayload());
|
||||
assertTrue(entitySet.getContextURL().toASCIIString().endsWith("$metadata#People"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rawRequestAsAtom() throws IOException {
|
||||
rawRequest(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rawRequestAsJSON() throws IOException {
|
||||
rawRequest(ContentType.JSON);
|
||||
}
|
||||
|
||||
private void readWithInlineCount(final ODataClient client, final ContentType contentType) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).
|
||||
appendEntitySetSegment("People").count(true);
|
||||
|
||||
final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
req.setFormat(contentType.toContentTypeString());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
||||
final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class);
|
||||
assertEquals(5, entitySet.getPayload().getEntities().size());
|
||||
|
||||
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address",
|
||||
entitySet.getPayload().getEntities().get(2).getProperty("HomeAddress").getComplexValue().getTypeName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithInlineCountAsJSON() throws IOException {
|
||||
readWithInlineCount(edmClient, ContentType.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithInlineCountAsFullJSON() throws IOException {
|
||||
readWithInlineCount(client, ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithInlineCountAsAtom() throws IOException {
|
||||
readWithInlineCount(client, ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
private void readODataEntitySetIterator(final ContentType contentType) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
||||
|
||||
|
@ -142,37 +77,4 @@ public class EntitySetTestITCase extends AbstractTestITCase {
|
|||
public void readODataEntitySetIteratorFromJSONNo() {
|
||||
readODataEntitySetIterator(ContentType.JSON_NO_METADATA);
|
||||
}
|
||||
|
||||
private void readWithNext(final ContentType format) {
|
||||
final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People");
|
||||
|
||||
final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().
|
||||
getEntitySetRequest(uriBuilder.build());
|
||||
req.setFormat(format);
|
||||
req.setPrefer(client.newPreferences().maxPageSize(5));
|
||||
|
||||
final ODataRetrieveResponse<ClientEntitySet> res = req.execute();
|
||||
final ClientEntitySet feed = res.getBody();
|
||||
|
||||
assertNotNull(feed);
|
||||
|
||||
assertEquals(5, feed.getEntities().size());
|
||||
assertNotNull(feed.getNext());
|
||||
|
||||
final URI expected = URI.create(testStaticServiceRootURL + "/People?$skiptoken=5");
|
||||
final URI found = URIUtils.getURI(testStaticServiceRootURL, feed.getNext().toASCIIString());
|
||||
|
||||
assertEquals(expected, found);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithNextFromAtom() {
|
||||
readWithNext(ContentType.APPLICATION_ATOM_XML);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readWithNextFromJSON() {
|
||||
readWithNext(ContentType.JSON_FULL_METADATA);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRe
|
|||
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.retrieve.ODataPropertyRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
|
||||
|
@ -54,7 +55,9 @@ import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
|
|||
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
|
||||
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
|
||||
import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRawResponse;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.data.ResWrap;
|
||||
import org.apache.olingo.client.api.domain.ClientAnnotation;
|
||||
import org.apache.olingo.client.api.domain.ClientComplexValue;
|
||||
import org.apache.olingo.client.api.domain.ClientEntity;
|
||||
|
@ -68,6 +71,8 @@ import org.apache.olingo.client.api.domain.ClientServiceDocument;
|
|||
import org.apache.olingo.client.api.domain.ClientValue;
|
||||
import org.apache.olingo.client.api.edm.xml.Reference;
|
||||
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
|
||||
import org.apache.olingo.client.api.uri.URIBuilder;
|
||||
import org.apache.olingo.client.core.uri.URIUtils;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
import org.apache.olingo.commons.api.edm.EdmActionImport;
|
||||
import org.apache.olingo.commons.api.edm.EdmAnnotation;
|
||||
|
@ -223,6 +228,41 @@ public class BasicITCase extends AbstractParamTecSvcITCase {
|
|||
assertShortOrInt(0, property.getPrimitiveValue().toValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readEntitySetWitInlineCount() {
|
||||
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_URI).
|
||||
appendEntitySetSegment("ESAllPrim").count(true);
|
||||
|
||||
final ODataRawRequest req = getClient().getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
|
||||
|
||||
final ODataRawResponse res = req.execute();
|
||||
assertNotNull(res);
|
||||
|
||||
final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class);
|
||||
assertEquals(3, entitySet.getPayload().getEntities().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readEntitySetWitNext() {
|
||||
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_URI).appendEntitySetSegment("ESServerSidePaging");
|
||||
|
||||
final ODataEntitySetRequest<ClientEntitySet> req = getClient().getRetrieveRequestFactory().
|
||||
getEntitySetRequest(uriBuilder.build());
|
||||
|
||||
final ODataRetrieveResponse<ClientEntitySet> res = req.execute();
|
||||
final ClientEntitySet feed = res.getBody();
|
||||
|
||||
assertNotNull(feed);
|
||||
|
||||
assertEquals(10, feed.getEntities().size());
|
||||
assertNotNull(feed.getNext());
|
||||
|
||||
final URI expected = URI.create(SERVICE_URI + "ESServerSidePaging?%24skiptoken=1%2A10");
|
||||
final URI found = URIUtils.getURI(SERVICE_URI, feed.getNext().toASCIIString());
|
||||
|
||||
assertEquals(expected, found);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readEntityCollectionCount() {
|
||||
ODataValueRequest request = getClient().getRetrieveRequestFactory()
|
||||
|
|
Loading…
Reference in New Issue