You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/04/29 11:51:46 UTC
[02/11] [OLINGO-236] Refactor complete
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java
deleted file mode 100644
index 4feea96..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityRetrieveTestITCase.java
+++ /dev/null
@@ -1,367 +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.core.it.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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;
-import org.apache.olingo.client.api.communication.response.ODataRawResponse;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.uri.v4.URIBuilder;
-import org.apache.olingo.client.api.v4.EdmEnabledODataClient;
-import org.apache.olingo.client.api.v4.ODataClient;
-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.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataInlineEntity;
-import org.apache.olingo.commons.api.domain.ODataInlineEntitySet;
-import org.apache.olingo.commons.api.domain.ODataLink;
-import org.apache.olingo.commons.api.domain.ODataLinkType;
-import org.apache.olingo.commons.api.domain.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.junit.Test;
-
-/**
- * This is the unit test class to check entity retrieve operations.
- */
-public class EntityRetrieveTestITCase extends AbstractTestITCase {
-
- private void withInlineEntry(final ODataClient client, final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company");
-
- final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().
- getEntityRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- final ODataEntity entity = res.getBody();
-
- assertNotNull(entity);
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
- assertTrue(entity.getProperty("Home").hasPrimitiveValue());
- assertEquals("Edm.GeographyPoint", entity.getProperty("Home").getPrimitiveValue().getTypeName());
- assertEquals(testStaticServiceRootURL + "/Customers(1)", entity.getEditLink().toASCIIString());
-
- // In JSON with minimal metadata, links are not provided
- if (format == ODataPubFormat.ATOM || format == ODataPubFormat.JSON_FULL_METADATA) {
- assertEquals(3, entity.getNavigationLinks().size());
-
- if (ODataPubFormat.ATOM == format) {
- assertTrue(entity.getAssociationLinks().isEmpty());
- // In JSON, association links for each $ref link will exist.
- }
-
- boolean found = false;
-
- for (ODataLink link : entity.getNavigationLinks()) {
- if (link instanceof ODataInlineEntity) {
- final CommonODataEntity inline = ((ODataInlineEntity) link).getEntity();
- assertNotNull(inline);
-
- final List<? extends CommonODataProperty> properties = inline.getProperties();
- assertEquals(5, properties.size());
-
- assertTrue(properties.get(0).getName().equals("CompanyID")
- || properties.get(1).getName().equals("CompanyID")
- || properties.get(2).getName().equals("CompanyID")
- || properties.get(3).getName().equals("CompanyID")
- || properties.get(4).getName().equals("CompanyID"));
- assertTrue(properties.get(0).getValue().toString().equals("0")
- || properties.get(1).getValue().toString().equals("0")
- || properties.get(2).getValue().toString().equals("0")
- || properties.get(3).getValue().toString().equals("0")
- || properties.get(4).getValue().toString().equals("0"));
-
- found = true;
- }
- }
-
- assertTrue(found);
- }
- }
-
- @Test
- public void withInlineEntryFromAtom() {
- withInlineEntry(client, ODataPubFormat.ATOM);
- }
-
- @Test
- public void withInlineEntryFromFullJSON() {
- withInlineEntry(client, ODataPubFormat.JSON_FULL_METADATA);
- }
-
- @Test
- public void withInlineEntryFromJSON() {
- withInlineEntry(edmClient, ODataPubFormat.JSON);
- }
-
- private void withInlineFeed(final ODataClient client, final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders");
-
- final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().
- getEntityRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
-
- // In JSON with minimal metadata, links are not provided
- if (format == ODataPubFormat.ATOM || format == ODataPubFormat.JSON_FULL_METADATA) {
- boolean found = false;
- for (ODataLink link : entity.getNavigationLinks()) {
- if (link instanceof ODataInlineEntitySet) {
- final CommonODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet();
- assertNotNull(inline);
-
- found = true;
- }
- }
- assertTrue(found);
- }
- }
-
- @Test
- public void withInlineFeedFromAtom() {
- withInlineFeed(client, ODataPubFormat.ATOM);
- }
-
- @Test
- public void withInlineFeedFromFullJSON() {
- withInlineFeed(client, ODataPubFormat.JSON_FULL_METADATA);
- }
-
- @Test
- public void withInlineFeedFromJSON() {
- withInlineFeed(edmClient, ODataPubFormat.JSON);
- }
-
- private void rawRequest(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5);
-
- final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
-
- final ODataRawResponse res = req.execute();
- assertNotNull(res);
-
- final ResWrap<ODataEntitySet> entitySet = res.getBodyAs(ODataEntitySet.class);
- assertNull(entitySet);
-
- final ResWrap<ODataEntity> entity = res.getBodyAs(ODataEntity.class);
- assertTrue(entity.getPayload().getReference().endsWith("/StaticService/V40/Static.svc/People(5)"));
- }
-
- @Test
- public void rawRequestAsAtom() {
- rawRequest(ODataPubFormat.ATOM);
- }
-
- @Test
- public void rawRequestAsJSON() {
- // this needs to be full, otherwise reference will not be provided
- rawRequest(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- private void multiKey(final ODataPubFormat format) throws EdmPrimitiveTypeException {
- final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>();
- multiKey.put("ProductID", "6");
- multiKey.put("ProductDetailID", 1);
-
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("ProductDetails").appendKeySegment(multiKey);
-
- final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
- assertEquals(Integer.valueOf(1),
- entity.getProperty("ProductDetailID").getPrimitiveValue().toCastValue(Integer.class));
- }
-
- @Test
- public void multiKeyAsAtom() throws EdmPrimitiveTypeException {
- multiKey(ODataPubFormat.ATOM);
- }
-
- @Test
- public void multiKeyAsJSON() throws EdmPrimitiveTypeException {
- multiKey(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- private void checkForETag(final ODataClient client, final ODataPubFormat format) {
- final URIBuilder uriBuilder =
- client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8);
-
- final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertEquals(200, res.getStatusCode());
-
- final String etag = res.getETag();
- assertTrue(StringUtils.isNotBlank(etag));
-
- final ODataEntity order = res.getBody();
- assertEquals(etag, order.getETag());
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Order", order.getTypeName().toString());
- assertEquals("Edm.Int32", order.getProperty("OrderID").getPrimitiveValue().getTypeName());
- assertEquals("Edm.DateTimeOffset", order.getProperty("OrderDate").getPrimitiveValue().getTypeName());
- assertEquals("Edm.Duration", order.getProperty("ShelfLife").getPrimitiveValue().getTypeName());
- assertEquals("Collection(Edm.Duration)", order.getProperty("OrderShelfLifes").getCollectionValue().getTypeName());
- }
-
- @Test
- public void checkForETagAsATOM() {
- checkForETag(client, ODataPubFormat.ATOM);
- }
-
- @Test
- public void checkForETagAsFullJSON() {
- checkForETag(client, ODataPubFormat.JSON_FULL_METADATA);
- }
-
- @Test
- public void checkForETagAsJSON() {
- checkForETag(edmClient, ODataPubFormat.JSON);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void issue99() {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders");
-
- final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.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) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder").
- appendRefSegment();
-
- ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
-
- ODataRetrieveResponse<ODataEntity> res = req.execute();
- assertNotNull(res);
-
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
- assertTrue(entity.getReference().endsWith("/StaticService/V40/Static.svc/Customers(PersonID=1)"));
-
- final URI referenceURI =
- client.getURIBuilder(testStaticServiceRootURL).appendEntityIdSegment(entity.getReference()).build();
-
- req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI);
- req.setFormat(format);
-
- res = req.execute();
- assertNotNull(res);
- assertNotNull(res.getBody());
- }
-
- @Test
- public void atomReference() {
- reference(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonReference() {
- reference(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- private void contained(final ODataClient client, final ODataPubFormat format) throws EdmPrimitiveTypeException {
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Accounts").appendKeySegment(101).
- appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101901).build();
- final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
- req.setFormat(format);
-
- final ODataEntity contained = req.execute().getBody();
- assertNotNull(contained);
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", contained.getTypeName().toString());
- assertEquals(101901,
- contained.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0);
- assertEquals("Edm.DateTimeOffset", contained.getProperty("CreatedDate").getPrimitiveValue().getTypeName());
- }
-
- @Test
- public void containedFromAtom() throws EdmPrimitiveTypeException {
- contained(client, ODataPubFormat.ATOM);
- }
-
- @Test
- public void containedFromFullJSON() throws EdmPrimitiveTypeException {
- contained(client, ODataPubFormat.JSON_FULL_METADATA);
- }
-
- @Test
- public void containedFromJSON() throws EdmPrimitiveTypeException {
- contained(edmClient, ODataPubFormat.JSON);
- }
-
- private void entitySetNavigationLink(final ODataClient client, final ODataPubFormat format) {
- final URI uri = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Accounts").appendKeySegment(101).build();
- final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri);
- req.setFormat(format);
-
- final ODataEntity entity = req.execute().getBody();
- assertNotNull(entity);
-
- // With JSON, entity set navigation links are only recognizable via Edm
- if (format == ODataPubFormat.ATOM || client instanceof EdmEnabledODataClient) {
- assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType());
- assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType());
- }
- }
-
- @Test
- public void entitySetNavigationLinkFromAtom() {
- entitySetNavigationLink(client, ODataPubFormat.ATOM);
- }
-
- @Test
- public void entitySetNavigationLinkFromJSON() {
- // only JSON_FULL_METADATA has links, only Edm can recognize entity set navigation
- entitySetNavigationLink(edmClient, ODataPubFormat.JSON_FULL_METADATA);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java
deleted file mode 100644
index e4265fe..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntitySetTestITCase.java
+++ /dev/null
@@ -1,179 +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.core.it.v4;
-
-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.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.domain.ODataEntitySetIterator;
-import org.apache.olingo.client.api.uri.v4.URIBuilder;
-import org.apache.olingo.client.api.v4.ODataClient;
-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.junit.Test;
-
-/**
- * This is the unit test class to check basic feed operations.
- */
-public class EntitySetTestITCase extends AbstractTestITCase {
-
- private void rawRequest(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
- uriBuilder.appendEntitySetSegment("People");
-
- final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
-
- final ODataRawResponse res = req.execute();
- assertNotNull(res);
-
- final ResWrap<ODataEntitySet> entitySet = res.getBodyAs(ODataEntitySet.class);
- assertNotNull(entitySet.getPayload());
- assertTrue(entitySet.getContextURL().getURI().toASCIIString().endsWith("$metadata#People"));
- }
-
- @Test
- public void rawRequestAsAtom() throws IOException {
- rawRequest(ODataPubFormat.ATOM);
- }
-
- @Test
- public void rawRequestAsJSON() throws IOException {
- rawRequest(ODataPubFormat.JSON);
- }
-
- private void readWithInlineCount(final ODataClient client, final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
- uriBuilder.appendEntitySetSegment("People").count(true);
-
- final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build());
- req.setFormat(format.toString(client.getServiceVersion()));
-
- final ODataRawResponse res = req.execute();
- assertNotNull(res);
-
- final ResWrap<ODataEntitySet> entitySet = res.getBodyAs(ODataEntitySet.class);
- assertEquals(5, entitySet.getPayload().getCount());
-
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address",
- entitySet.getPayload().getEntities().get(2).getProperty("HomeAddress").getComplexValue().getTypeName());
- }
-
- @Test
- public void readWithInlineCountAsJSON() throws IOException {
- readWithInlineCount(edmClient, ODataPubFormat.JSON);
- }
-
- @Test
- public void readWithInlineCountAsFullJSON() throws IOException {
- readWithInlineCount(client, ODataPubFormat.JSON_FULL_METADATA);
- }
-
- @Test
- public void readWithInlineCountAsAtom() throws IOException {
- readWithInlineCount(client, ODataPubFormat.ATOM);
- }
-
- private void readODataEntitySetIterator(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
- uriBuilder.appendEntitySetSegment("People");
-
- final ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> req =
- client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntitySetIterator<ODataEntitySet, ODataEntity>> res = req.execute();
- final ODataEntitySetIterator<ODataEntitySet, ODataEntity> feedIterator = res.getBody();
-
- assertNotNull(feedIterator);
-
- int count = 0;
-
- while (feedIterator.hasNext()) {
- assertNotNull(feedIterator.next());
- count++;
- }
- assertEquals(5, count);
- assertTrue(feedIterator.getNext().toASCIIString().endsWith("People?$skiptoken=5"));
- }
-
- @Test
- public void readODataEntitySetIteratorFromAtom() {
- readODataEntitySetIterator(ODataPubFormat.ATOM);
- }
-
- @Test
- public void readODataEntitySetIteratorFromJSON() {
- readODataEntitySetIterator(ODataPubFormat.JSON);
- }
-
- @Test
- public void readODataEntitySetIteratorFromJSONFull() {
- readODataEntitySetIterator(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- @Test
- public void readODataEntitySetIteratorFromJSONNo() {
- readODataEntitySetIterator(ODataPubFormat.JSON_NO_METADATA);
- }
-
- private void readEntitySetWithNextLink(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL);
- uriBuilder.appendEntitySetSegment("People");
-
- final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().
- getEntitySetRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntitySet> res = req.execute();
- final ODataEntitySet 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 readODataEntitySetWithNextFromAtom() {
- readEntitySetWithNextLink(ODataPubFormat.ATOM);
- }
-
- @Test
- public void readODataEntitySetWithNextFromJSON() {
- readEntitySetWithNextLink(ODataPubFormat.JSON_FULL_METADATA);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityUpdateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityUpdateTestITCase.java
deleted file mode 100644
index 30e6607..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityUpdateTestITCase.java
+++ /dev/null
@@ -1,154 +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.core.it.v4;
-
-import static org.junit.Assert.assertEquals;
-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;
-import org.apache.olingo.commons.api.domain.ODataLink;
-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.junit.Test;
-
-public class EntityUpdateTestITCase extends AbstractTestITCase {
-
- private void upsert(final UpdateType updateType, final ODataPubFormat format) {
- final ODataEntity order = getClient().getObjectFactory().
- newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order"));
-
- order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("OrderID",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(9)));
- order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("OrderDate",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).build()));
- order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ShelfLife",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.Duration).setText("PT0.0000002S").build()));
-
- final URI upsertURI = getClient().getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Orders").appendKeySegment(9).build();
- final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory().
- getEntityUpdateRequest(upsertURI, updateType, order);
- req.setFormat(format);
-
- req.execute();
- try {
- final ODataEntity read = read(format, upsertURI);
- assertNotNull(read);
- assertEquals(order.getProperty("OrderID"), read.getProperty("OrderID"));
- assertEquals(order.getProperty("OrderDate").getPrimitiveValue().toString(),
- read.getProperty("OrderDate").getPrimitiveValue().toString());
- assertEquals(order.getProperty("ShelfLife").getPrimitiveValue().toString(),
- read.getProperty("ShelfLife").getPrimitiveValue().toString());
- } finally {
- getClient().getCUDRequestFactory().getDeleteRequest(upsertURI).execute();
- }
- }
-
- @Test
- public void atomUpsert() {
- upsert(UpdateType.PATCH, ODataPubFormat.ATOM);
- upsert(UpdateType.REPLACE, ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonUpsert() {
- upsert(UpdateType.PATCH, ODataPubFormat.JSON);
- upsert(UpdateType.REPLACE, ODataPubFormat.JSON);
- }
-
- private void onContained(final ODataPubFormat format) {
- final String newName = UUID.randomUUID().toString();
- final ODataEntity changes = getClient().getObjectFactory().newEntity(
- new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument"));
- changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("FriendlyName",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildString(newName)));
-
- final URI uri = getClient().getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Accounts").appendKeySegment(101).
- appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101901).build();
- final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory().
- getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
- req.setFormat(format);
-
- final ODataEntityUpdateResponse<ODataEntity> res = req.execute();
- assertEquals(204, res.getStatusCode());
-
- final ODataEntity actual = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
- assertNotNull(actual);
- assertEquals(newName, actual.getProperty("FriendlyName").getPrimitiveValue().toString());
- }
-
- @Test
- public void atomOnContained() {
- onContained(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonOnContained() {
- onContained(ODataPubFormat.JSON);
- }
-
- private void bindOperation(final ODataPubFormat format) throws EdmPrimitiveTypeException {
- final ODataEntity changes = getClient().getObjectFactory().newEntity(
- new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
- final ODataLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent",
- getClient().getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(1).build());
- changes.getNavigationLinks().add(parent);
-
- final URI uri = getClient().getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).build();
- final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory().
- getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
- req.setFormat(format);
-
- final ODataEntityUpdateResponse<ODataEntity> res = req.execute();
- assertEquals(204, res.getStatusCode());
-
- final ODataEntity updated = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
- assertNotNull(updated);
- final ODataLink updatedLink = updated.getNavigationLink("Parent");
- assertNotNull(updatedLink);
-
- final ODataEntity updatedEntity = getClient().getRetrieveRequestFactory().getEntityRequest(updatedLink.getLink()).
- execute().getBody();
- assertNotNull(updatedEntity);
- assertEquals(1, updatedEntity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
- }
-
- @Test
- public void atomBindOperation() throws EdmPrimitiveTypeException {
- bindOperation(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonBindOperation() throws EdmPrimitiveTypeException {
- bindOperation(ODataPubFormat.JSON);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/FilterFactoryTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/FilterFactoryTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/FilterFactoryTestITCase.java
deleted file mode 100644
index 4062de5..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/FilterFactoryTestITCase.java
+++ /dev/null
@@ -1,63 +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.core.it.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.apache.olingo.client.core.it.v4.AbstractTestITCase.client;
-
-import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
-import org.apache.olingo.client.api.uri.URIFilter;
-import org.apache.olingo.client.api.uri.v4.FilterArgFactory;
-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.junit.Test;
-
-public class FilterFactoryTestITCase extends AbstractTestITCase {
-
- private FilterFactory getFilterFactory() {
- return getClient().getFilterFactory();
- }
-
- private FilterArgFactory getFilterArgFactory() {
- return getFilterFactory().getArgFactory();
- }
-
- @Test
- public void crossjoin() {
- final URIFilter filter = getFilterFactory().eq(
- getFilterArgFactory().property("Orders/OrderID"), getFilterArgFactory().property("Customers/Order"));
-
- final URIBuilder uriBuilder =
- client.getURIBuilder(testStaticServiceRootURL).appendCrossjoinSegment("Customers", "Orders").filter(filter);
-
- final ODataEntitySetRequest<ODataEntitySet> req =
- client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build());
- req.setFormat(ODataPubFormat.JSON_FULL_METADATA);
-
- final ODataEntitySet feed = req.execute().getBody();
- assertEquals(3, feed.getEntities().size());
-
- for (ODataEntity entity : feed.getEntities()) {
- assertEquals(2, entity.getNavigationLinks().size());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/KeyAsSegmentTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/KeyAsSegmentTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/KeyAsSegmentTestITCase.java
deleted file mode 100644
index 91d4c85..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/KeyAsSegmentTestITCase.java
+++ /dev/null
@@ -1,122 +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.core.it.v4;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-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;
-import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.uri.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.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class KeyAsSegmentTestITCase extends AbstractTestITCase {
-
- @BeforeClass
- public static void enableKeyAsSegment() {
- client.getConfiguration().setKeyAsSegment(true);
- }
-
- private void read(final ODataPubFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testKeyAsSegmentServiceRootURL).
- appendEntitySetSegment("Accounts").appendKeySegment(101);
-
- final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataRetrieveResponse<ODataEntity> res = req.execute();
- final ODataEntity entity = res.getBody();
- assertNotNull(entity);
-
- assertFalse(entity.getEditLink().toASCIIString().contains("("));
- assertFalse(entity.getEditLink().toASCIIString().contains(")"));
- }
-
- @Test
- public void atomRead() {
- read(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonRead() {
- read(ODataPubFormat.JSON);
- }
-
- @Test
- public void atomCreateAndDelete() {
- createAndDeleteOrder(ODataPubFormat.ATOM, 1000);
- }
-
- @Test
- public void jsonCreateAndDelete() {
- createAndDeleteOrder(ODataPubFormat.JSON, 1001);
- }
-
- private void update(final ODataPubFormat format) {
- final ODataEntity changes = getClient().getObjectFactory().newEntity(
- new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer"));
- final ODataProperty middleName = getClient().getObjectFactory().newPrimitiveProperty("MiddleName",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("middle"));
- changes.getProperties().add(middleName);
-
- final URI uri = getClient().getURIBuilder(testKeyAsSegmentServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).build();
- final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory().
- getEntityUpdateRequest(uri, UpdateType.PATCH, changes);
- req.setFormat(format);
-
- final ODataEntityUpdateResponse<ODataEntity> res = req.execute();
- assertEquals(204, res.getStatusCode());
-
- final ODataEntity updated = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody();
- assertNotNull(updated);
- assertFalse(updated.getEditLink().toASCIIString().contains("("));
- assertFalse(updated.getEditLink().toASCIIString().contains(")"));
-
- final ODataProperty updatedMiddleName = updated.getProperty("MiddleName");
- assertNotNull(updatedMiddleName);
- assertEquals("middle", updatedMiddleName.getPrimitiveValue().toString());
- }
-
- @Test
- public void atomUpdate() {
- update(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonUpdate() {
- update(ODataPubFormat.JSON);
- }
-
- @AfterClass
- public static void disableKeyAsSegment() {
- client.getConfiguration().setKeyAsSegment(false);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/MetadataTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/MetadataTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/MetadataTestITCase.java
deleted file mode 100644
index 4bac063..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/MetadataTestITCase.java
+++ /dev/null
@@ -1,71 +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.core.it.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.core.ODataClientFactory;
-import org.apache.olingo.client.core.it.AbstractMetadataTestITCase;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.junit.Test;
-
-public class MetadataTestITCase extends AbstractMetadataTestITCase {
-
- @Override
- protected ODataClient getClient() {
- return ODataClientFactory.getV4();
- }
-
- @Test
- public void retrieve() {
- final Edm metadata = getClient().getRetrieveRequestFactory().
- getMetadataRequest(getTestServiceRoot()).execute().getBody();
- assertNotNull(metadata);
-
- final EdmEntityType order = metadata.getEntityType(
- new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService", "Order"));
- assertNotNull(order);
-
- final EdmProperty orderDate = order.getStructuralProperty("OrderDate");
- assertNotNull(orderDate);
- assertEquals("Edm.DateTimeOffset", orderDate.getType().getFullQualifiedName().toString());
- }
-
- @Test
- public void include() {
- final Edm metadata = getClient().getRetrieveRequestFactory().
- getMetadataRequest(getNorthwindServiceRoot()).execute().getBody();
- assertNotNull(metadata);
-
- final EdmEntityContainer container = metadata.getEntityContainer(
- new FullQualifiedName("ODataWebExperimental.Northwind.Model", "NorthwindEntities"));
- assertNotNull(container);
-
- final EdmEntitySet categories = container.getEntitySet("Categories");
- assertNotNull(categories);
- assertEquals("NorthwindModel", categories.getEntityType().getNamespace());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OpenTypeTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OpenTypeTestITCase.java
deleted file mode 100644
index 475a0fb..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OpenTypeTestITCase.java
+++ /dev/null
@@ -1,188 +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.core.it.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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.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.junit.Test;
-
-public class OpenTypeTestITCase extends AbstractTestITCase {
-
- @Test
- public void checkOpenTypeEntityTypesExist() {
- final Edm metadata = getClient().getRetrieveRequestFactory().
- getMetadataRequest(testOpenTypeServiceRootURL).execute().getBody();
-
- final EdmSchema schema = metadata.getSchemas().get(0);
-
- assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "Row")).isOpenType());
- assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "IndexedRow")).isOpenType());
- assertTrue(metadata.getEntityType(new FullQualifiedName(schema.getNamespace(), "RowIndex")).isOpenType());
- }
-
- private ODataEntity readRow(final ODataPubFormat format, final String uuid) {
- final URIBuilder builder = getClient().getURIBuilder(testOpenTypeServiceRootURL).
- appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid));
- return read(format, builder.build());
- }
-
- private void read(final ODataPubFormat 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());
-
- row = readRow(format, "672b8250-1e6e-4785-80cf-b94b572e42b3");
- assertEquals(EdmPrimitiveTypeKind.Decimal, row.getProperty("Decimal").getPrimitiveValue().getTypeKind());
- }
-
- @Test
- public void readAsAtom() {
- read(ODataPubFormat.ATOM);
- }
-
- @Test
- public void readAsJSON() {
- read(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- private void cud(final ODataPubFormat format) {
- final Integer id = 1426;
-
- ODataEntity rowIndex = getClient().getObjectFactory().newEntity(
- new FullQualifiedName("Microsoft.Test.OData.Services.OpenTypesService.RowIndex"));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("Id",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id)));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aString",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("string")));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aBoolean",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildBoolean(true)));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aDouble",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.5D)));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aByte",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.SByte).setValue(Byte.MAX_VALUE).
- build()));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aDate",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).
- build()));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newPrimitiveProperty("aDate",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).
- build()));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newEnumProperty("aColor", getClient().getObjectFactory().
- newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Blue")));
-
- final ODataComplexValue<ODataProperty> contactDetails = getClient().getObjectFactory().newComplexValue(
- "Microsoft.Test.OData.Services.OpenTypesService.ContactDetails");
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("FirstContacted",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildBinary("text".getBytes())));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("LastContacted",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.DateTimeOffset).setText("2001-04-05T05:05:05.001+00:01").build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Contacted",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.Date).setText("2001-04-05").build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("GUID",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildGuid(UUID.randomUUID())));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("PreferedContactTime",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.Duration).setText("-P9DT51M10.5063807S").build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Byte",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.Byte).setValue(24).build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("SignedByte",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.SByte).setValue(Byte.MAX_VALUE).build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Double",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildDouble(Double.MAX_VALUE)));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Single",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildSingle(Float.MAX_VALUE)));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Short",
- getClient().getObjectFactory().newPrimitiveValueBuilder().
- setType(EdmPrimitiveTypeKind.Int16).setValue(Short.MAX_VALUE).build()));
- contactDetails.add(getClient().getObjectFactory().newPrimitiveProperty("Int",
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(Integer.MAX_VALUE)));
- getClient().getBinder().add(rowIndex,
- getClient().getObjectFactory().newComplexProperty("aContact", contactDetails));
-
- final ODataEntityCreateRequest<ODataEntity> createReq = getClient().getCUDRequestFactory().
- getEntityCreateRequest(getClient().getURIBuilder(testOpenTypeServiceRootURL).
- appendEntitySetSegment("RowIndex").build(), rowIndex);
- createReq.setFormat(format);
- final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute();
- assertEquals(201, createRes.getStatusCode());
-
- final URIBuilder builder = getClient().getURIBuilder(testOpenTypeServiceRootURL).
- appendEntitySetSegment("RowIndex").appendKeySegment(id);
- rowIndex = read(format, builder.build());
- assertNotNull(rowIndex);
- assertEquals(EdmPrimitiveTypeKind.Int32,
- rowIndex.getProperty("Id").getPrimitiveValue().getTypeKind());
- assertEquals(EdmPrimitiveTypeKind.String,
- rowIndex.getProperty("aString").getPrimitiveValue().getTypeKind());
- assertEquals(EdmPrimitiveTypeKind.Boolean,
- rowIndex.getProperty("aBoolean").getPrimitiveValue().getTypeKind());
- assertTrue(rowIndex.getProperty("aDouble").hasPrimitiveValue());
- assertTrue(rowIndex.getProperty("aByte").hasPrimitiveValue());
- assertTrue(rowIndex.getProperty("aDate").hasPrimitiveValue());
- assertNotNull(rowIndex.getProperty("aColor"));
- assertTrue(rowIndex.getProperty("aContact").hasComplexValue());
- assertTrue(rowIndex.getProperty("aContact").getComplexValue().get("SignedByte").hasPrimitiveValue());
-
- final ODataDeleteResponse deleteRes = getClient().getCUDRequestFactory().
- getDeleteRequest(rowIndex.getEditLink()).execute();
- assertEquals(204, deleteRes.getStatusCode());
- }
-
- @Test
- public void cudAsAtom() {
- cud(ODataPubFormat.ATOM);
- }
-
- @Test
- public void cudAsJSON() {
- cud(ODataPubFormat.JSON_FULL_METADATA);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OperationImportInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OperationImportInvokeTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OperationImportInvokeTestITCase.java
deleted file mode 100644
index 96ec485..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/OperationImportInvokeTestITCase.java
+++ /dev/null
@@ -1,258 +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.core.it.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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;
-import org.apache.olingo.commons.api.domain.ODataComplexValue;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.ODataValue;
-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.ODataEnumValue;
-import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmActionImport;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-
-import org.junit.Test;
-
-public class OperationImportInvokeTestITCase extends AbstractTestITCase {
-
- private Edm getEdm() {
- final Edm edm = getClient().getRetrieveRequestFactory().
- getMetadataRequest(testStaticServiceRootURL).execute().getBody();
- assertNotNull(edm);
-
- return edm;
- }
-
- private void functionImports(final ODataPubFormat format) throws EdmPrimitiveTypeException {
- final Edm edm = getEdm();
- final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer();
- assertNotNull(container);
-
- // GetDefaultColor
- EdmFunctionImport funcImp = container.getFunctionImport("GetDefaultColor");
-
- final ODataInvokeRequest<ODataProperty> defaultColorReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(funcImp.getName()).build(),
- funcImp.getUnboundFunctions().get(0));
- defaultColorReq.setFormat(format);
- final ODataProperty defaultColor = defaultColorReq.execute().getBody();
- assertNotNull(defaultColor);
- assertTrue(defaultColor.hasEnumValue());
- assertEquals("Red", defaultColor.getEnumValue().getValue());
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", defaultColor.getEnumValue().getTypeName());
-
- // GetPerson2
- funcImp = container.getFunctionImport("GetPerson2");
-
- final ODataPrimitiveValue city =
- getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London");
-
- final ODataInvokeRequest<ODataEntity> person2Req = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(funcImp.getName()).build(),
- funcImp.getUnboundFunctions().get(0),
- Collections.<String, ODataValue>singletonMap("city", city));
- person2Req.setFormat(format);
- final ODataEntity person2 = person2Req.execute().getBody();
- assertNotNull(person2);
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString());
- assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0);
-
- // GetPerson
- funcImp = container.getFunctionImport("GetPerson");
-
- final ODataComplexValue<ODataProperty> address = getClient().getObjectFactory().
- newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
- address.add(client.getObjectFactory().newPrimitiveProperty("Street",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("1 Microsoft Way")));
- address.add(client.getObjectFactory().newPrimitiveProperty("City",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("London")));
- address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("98052")));
-
- final ODataInvokeRequest<ODataEntity> personReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(funcImp.getName()).build(),
- funcImp.getUnboundFunctions().get(0),
- Collections.<String, ODataValue>singletonMap("address", address));
- personReq.setFormat(format);
- final ODataEntity person = personReq.execute().getBody();
- assertNotNull(person);
- assertEquals(person2, person);
-
- // GetAllProducts
- funcImp = container.getFunctionImport("GetAllProducts");
-
- final ODataInvokeRequest<ODataEntitySet> productsReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(funcImp.getName()).build(),
- funcImp.getUnboundFunctions().get(0));
- productsReq.setFormat(format);
- final ODataEntitySet products = productsReq.execute().getBody();
- assertNotNull(products);
- assertEquals(5, products.getCount());
-
- // GetProductsByAccessLevel
- funcImp = container.getFunctionImport("GetProductsByAccessLevel");
-
- final ODataEnumValue accessLevel = getClient().getObjectFactory().
- newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "None");
-
- final ODataInvokeRequest<ODataProperty> prodByALReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(funcImp.getName()).build(),
- funcImp.getUnboundFunctions().get(0),
- Collections.<String, ODataValue>singletonMap("accessLevel", accessLevel));
- prodByALReq.setFormat(format);
- final ODataProperty prodByAL = prodByALReq.execute().getBody();
- assertNotNull(prodByAL);
- assertTrue(prodByAL.hasCollectionValue());
- assertEquals(5, prodByAL.getCollectionValue().size());
- assertTrue(prodByAL.getCollectionValue().asJavaCollection().contains("Car"));
- }
-
- @Test
- public void atomFunctionImports() throws EdmPrimitiveTypeException {
- functionImports(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonFunctionImports() throws EdmPrimitiveTypeException {
- functionImports(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- private void actionImports(final ODataPubFormat format) {
- final Edm edm = getEdm();
- final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer();
- assertNotNull(container);
-
- // Discount
- EdmActionImport actImp = container.getActionImport("Discount");
-
- final ODataPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22);
- final ODataInvokeRequest<ODataNoContent> discountReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(actImp.getName()).build(),
- actImp.getUnboundAction(),
- Collections.<String, ODataValue>singletonMap("percentage", percentage));
- discountReq.setFormat(format);
- final ODataNoContent discount = discountReq.execute().getBody();
- assertNotNull(discount);
-
- // ResetBossAddress
- actImp = container.getActionImport("ResetBossAddress");
-
- final ODataComplexValue<ODataProperty> address = getClient().getObjectFactory().
- newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address");
- address.add(client.getObjectFactory().newPrimitiveProperty("Street",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("Via Le Mani Dal Naso, 123")));
- address.add(client.getObjectFactory().newPrimitiveProperty("City",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("Tollo")));
- address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode",
- client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010")));
-
- final ODataInvokeRequest<ODataProperty> resetBossAddressReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(actImp.getName()).build(),
- actImp.getUnboundAction(),
- Collections.<String, ODataValue>singletonMap("address", address));
- resetBossAddressReq.setFormat(format);
- final ODataProperty resetBossAddress = resetBossAddressReq.execute().getBody();
- assertNotNull(resetBossAddress);
- }
-
- @Test
- public void atomActionImports() {
- actionImports(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonActionImports() {
- actionImports(ODataPubFormat.JSON_FULL_METADATA);
- }
-
- private void bossEmails(final ODataPubFormat format) {
- final Edm edm = getEdm();
- final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer();
- assertNotNull(container);
-
- // ResetBossEmail
- final EdmActionImport actImp = container.getActionImport("ResetBossEmail");
-
- final ODataCollectionValue<org.apache.olingo.commons.api.domain.v4.ODataValue> emails =
- getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)");
- emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("first@olingo.apache.org"));
- emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("second@olingo.apache.org"));
- ODataInvokeRequest<ODataProperty> bossEmailsReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(actImp.getName()).build(),
- actImp.getUnboundAction(),
- Collections.<String, ODataValue>singletonMap("emails", emails));
- bossEmailsReq.setFormat(format);
- final ODataProperty bossEmails = bossEmailsReq.execute().getBody();
- assertNotNull(bossEmails);
- assertTrue(bossEmails.hasCollectionValue());
- assertEquals(2, bossEmails.getCollectionValue().size());
-
- final EdmFunctionImport funcImp = container.getFunctionImport("GetBossEmails");
-
- final Map<String, ODataValue> params = new LinkedHashMap<String, ODataValue>(2);
- params.put("start", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(0));
- params.put("count", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(100));
- bossEmailsReq = getClient().getInvokeRequestFactory().
- getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(funcImp.getName()).build(),
- funcImp.getUnboundFunctions().get(0),
- params);
- bossEmailsReq.setFormat(format);
- final ODataProperty bossEmailsViaGET = bossEmailsReq.execute().getBody();
- assertNotNull(bossEmailsViaGET);
- assertTrue(bossEmailsViaGET.hasCollectionValue());
- assertEquals(2, bossEmailsViaGET.getCollectionValue().size());
- assertEquals(bossEmails.getCollectionValue().asJavaCollection(),
- bossEmailsViaGET.getCollectionValue().asJavaCollection());
- }
-
- @Test
- public void atomBossEmails() throws EdmPrimitiveTypeException {
- bossEmails(ODataPubFormat.ATOM);
- }
-
- @Test
- public void jsonBossEmails() throws EdmPrimitiveTypeException {
- bossEmails(ODataPubFormat.JSON_FULL_METADATA);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyTestITCase.java
deleted file mode 100644
index 78605bf..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyTestITCase.java
+++ /dev/null
@@ -1,164 +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.core.it.v4;
-
-import java.io.IOException;
-import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
-import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
-import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.http.HttpMethod;
-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.ODataProperty;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.junit.Test;
-
-public class PropertyTestITCase extends AbstractTestITCase {
-
- private void _enum(final ODataClient client, final ODataFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Products").appendKeySegment(5).appendPropertySegment("CoverColors");
- final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
- getPropertyRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataProperty prop = req.execute().getBody();
- assertNotNull(prop);
- assertEquals("Collection(Microsoft.Test.OData.Services.ODataWCFService.Color)", prop.getValue().getTypeName());
- }
-
- @Test
- public void enumFromXML() {
- _enum(client, ODataFormat.XML);
- }
-
- @Test
- public void enumFromJSON() {
- _enum(edmClient, ODataFormat.JSON);
- }
-
- @Test
- public void enumFromFullJSON() {
- _enum(client, ODataFormat.JSON_FULL_METADATA);
- }
-
- private void geospatial(final ODataClient client, final ODataFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Home");
- final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
- getPropertyRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataProperty prop = req.execute().getBody();
- assertNotNull(prop);
- assertEquals("Edm.GeographyPoint", prop.getValue().getTypeName());
- }
-
- @Test
- public void geospatialFromXML() {
- geospatial(client, ODataFormat.XML);
- }
-
- @Test
- public void geospatialFromJSON() {
- geospatial(edmClient, ODataFormat.JSON);
- }
-
- @Test
- public void geospatialFromFullJSON() {
- geospatial(client, ODataFormat.JSON_FULL_METADATA);
- }
-
- private void complex(final ODataClient client, final ODataFormat format) {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(2).appendPropertySegment("HomeAddress");
- final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
- getPropertyRequest(uriBuilder.build());
- req.setFormat(format);
-
- final ODataProperty prop = req.execute().getBody();
- assertNotNull(prop);
- assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address", prop.getValue().getTypeName());
- }
-
- @Test
- public void complexFromXML() {
- complex(client, ODataFormat.XML);
- }
-
- @Test
- public void complexFromJSON() {
- complex(edmClient, ODataFormat.JSON);
- }
-
- @Test
- public void complexFromFullJSON() {
- complex(client, ODataFormat.JSON_FULL_METADATA);
- }
-
- @Test
- public void patchComplexPropertyAsJSON() throws IOException {
- updateComplexProperty(ODataFormat.JSON_FULL_METADATA, UpdateType.PATCH);
- }
-
- private void updateComplexProperty(final ODataFormat format, final UpdateType type) throws IOException {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Customers").appendKeySegment(1).appendPropertySegment("HomeAddress");
-
- ODataPropertyRequest<ODataProperty> retrieveReq =
- client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
- retrieveReq.setFormat(format);
-
- ODataRetrieveResponse<ODataProperty> retrieveRes = retrieveReq.execute();
- assertEquals(200, retrieveRes.getStatusCode());
-
- ODataProperty homeAddress =
- client.getObjectFactory().newComplexProperty("HomeAddress",
- client.getObjectFactory().newComplexValue(retrieveRes.getBody().getComplexValue().getTypeName()));
-
- homeAddress.getComplexValue().add(client.getObjectFactory().
- newPrimitiveProperty("City", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Pescara")));
-
- final ODataPropertyUpdateRequest updateReq = client.getCUDRequestFactory().
- getPropertyComplexValueUpdateRequest(uriBuilder.build(), type, homeAddress);
- if (client.getConfiguration().isUseXHTTPMethod()) {
- assertEquals(HttpMethod.POST, updateReq.getMethod());
- } else {
- assertEquals(type.getMethod(), updateReq.getMethod());
- }
- updateReq.setFormat(format);
-
- final ODataPropertyUpdateResponse updateRes = updateReq.execute();
- assertEquals(204, updateRes.getStatusCode());
-
- retrieveReq = client.getRetrieveRequestFactory().getPropertyRequest(uriBuilder.build());
- retrieveReq.setFormat(format);
-
- retrieveRes = retrieveReq.execute();
- assertEquals(200, retrieveRes.getStatusCode());
-
- homeAddress = retrieveRes.getBody();
- assertEquals("Pescara", homeAddress.getComplexValue().get("City").getPrimitiveValue().toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8042913b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java
deleted file mode 100644
index 4b457be..0000000
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/PropertyValueTestITCase.java
+++ /dev/null
@@ -1,147 +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.core.it.v4;
-
-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;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
-import org.apache.olingo.client.api.uri.v4.URIBuilder;
-import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
-import org.apache.olingo.commons.api.domain.v4.ODataProperty;
-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 {
-
- @Test
- public void retrieveIntPropertyValueTest() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID").
- appendValueSegment();
- final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
- assertEquals("5", req.execute().getBody().toString());
- }
-
- @Test
- public void retrieveBooleanPropertyValueTest() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered").
- appendValueSegment();
- final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
- assertEquals("true", req.execute().getBody().toString());
- }
-
- @Test
- public void retrieveStringPropertyValueTest() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName").
- appendValueSegment();
- final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
- assertEquals("Peter", req.execute().getBody().toString());
- }
-
- @Test
- public void retrieveDatePropertyValueTest() {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate").
- appendValueSegment();
- final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
- final ODataPrimitiveValue property = req.execute().getBody();
- assertEquals("2011-03-04T16:03:57Z", property.toString());
- }
-
- @Test
- public void retrieveDecimalPropertyValueTest() throws EdmPrimitiveTypeException {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height").
- appendValueSegment();
- final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
- final ODataPrimitiveValue property = req.execute().getBody();
- assertEquals("179", property.toString());
- }
-
- @Test
- public void retrieveBinaryPropertyValueTest() throws IOException {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC").
- appendValueSegment();
- final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
- final ODataPrimitiveValue property = req.execute().getBody();
- assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ"
- + "VIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=", property.toString());
- }
-
- @Test(expected = ODataClientErrorException.class)
- public void retrieveBinaryPropertyValueTestWithAtom() throws IOException {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC").
- appendValueSegment();
- final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setAccept(ODataPubFormat.ATOM.toString(ODataServiceVersion.V40));
- req.execute().getBody();
- }
-
- @Test(expected = ODataClientErrorException.class)
- public void retrieveBinaryPropertyValueTestWithXML() throws IOException {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC").
- appendValueSegment();
- final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setAccept(ODataFormat.XML.toString(client.getServiceVersion()));
- req.execute().getBody();
- }
-
- @Test
- public void retrieveCollectionPropertyValueTest() {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Numbers");
- final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory().
- getPropertyRequest(uriBuilder.build());
- req.setFormat(ODataFormat.XML);
- final ODataProperty property = req.execute().getBody();
- assertTrue(property.getValue().isCollection());
- assertEquals("555-555-5555", property.getCollectionValue().iterator().next().asPrimitive().toString());
- }
-
- @Test
- public void retrieveNullPropertyValueTest() {
- final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).
- appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress").
- appendValueSegment();
- final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build());
- req.setFormat(ODataValueFormat.TEXT);
- final ODataPrimitiveValue property = req.execute().getBody();
- assertTrue(StringUtils.isBlank(property.toString()));
- }
-}