http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java index 0e456ba..b48902f 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java @@ -1,18 +1,18 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -21,16 +21,16 @@ package org.apache.olingo.fit.v4; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest; import org.apache.olingo.client.api.uri.URIBuilder; -import org.apache.olingo.commons.api.domain.ODataCollectionValue; -import org.apache.olingo.commons.api.domain.ODataComplexValue; -import org.apache.olingo.commons.api.domain.ODataEntity; -import org.apache.olingo.commons.api.domain.ODataEntitySet; -import org.apache.olingo.commons.api.domain.ODataEnumValue; -import org.apache.olingo.commons.api.domain.ODataOperation; -import org.apache.olingo.commons.api.domain.ODataPrimitiveValue; -import org.apache.olingo.commons.api.domain.ODataProperty; -import org.apache.olingo.commons.api.domain.ODataSingleton; -import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.ClientCollectionValue; +import org.apache.olingo.commons.api.domain.ClientComplexValue; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientEntitySet; +import org.apache.olingo.commons.api.domain.ClientEnumValue; +import org.apache.olingo.commons.api.domain.ClientOperation; +import org.apache.olingo.commons.api.domain.ClientPrimitiveValue; +import org.apache.olingo.commons.api.domain.ClientProperty; +import org.apache.olingo.commons.api.domain.ClientSingleton; +import org.apache.olingo.commons.api.domain.ClientValue; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -53,40 +53,40 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { private void functions(final ODataFormat format) throws EdmPrimitiveTypeException { // GetEmployeesCount URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); - final ODataEntityRequest<ODataSingleton> singletonReq = + final ODataEntityRequest<ClientSingleton> singletonReq = client.getRetrieveRequestFactory().getSingletonRequest(builder.build()); singletonReq.setFormat(format); - final ODataSingleton company = singletonReq.execute().getBody(); + final ClientSingleton company = singletonReq.execute().getBody(); assertNotNull(company); - ODataOperation boundOp = company.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount"); + ClientOperation boundOp = company.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount"); assertNotNull(boundOp); - final ODataInvokeRequest<ODataProperty> getEmployeesCountReq = - client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataProperty.class); + final ODataInvokeRequest<ClientProperty> getEmployeesCountReq = + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class); getEmployeesCountReq.setFormat(format); - final ODataProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody(); + final ClientProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody(); assertNotNull(getEmployeesCountRes); assertTrue(getEmployeesCountRes.hasPrimitiveValue()); // GetProductDetails builder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Products").appendKeySegment(5); - ODataEntityRequest<ODataEntity> entityReq = client.getRetrieveRequestFactory(). + ODataEntityRequest<ClientEntity> entityReq = client.getRetrieveRequestFactory(). getEntityRequest(builder.build()); entityReq.setFormat(format); - ODataEntity entity = entityReq.execute().getBody(); + ClientEntity entity = entityReq.execute().getBody(); assertNotNull(entity); boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"); assertNotNull(boundOp); - final ODataPrimitiveValue count = client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1); - final ODataInvokeRequest<ODataEntitySet> getProductDetailsReq = - client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataEntitySet.class, - Collections.<String, ODataValue> singletonMap("count", count)); + final ClientPrimitiveValue count = client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1); + final ODataInvokeRequest<ClientEntitySet> getProductDetailsReq = + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntitySet.class, + Collections.<String, ClientValue> singletonMap("count", count)); getProductDetailsReq.setFormat(format); - final ODataEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody(); + final ClientEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody(); assertNotNull(getProductDetailsRes); assertEquals(1, getProductDetailsRes.getEntities().size()); @@ -104,10 +104,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct"); assertNotNull(boundOp); - final ODataInvokeRequest<ODataEntity> getRelatedProductReq = - client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataEntity.class); + final ODataInvokeRequest<ClientEntity> getRelatedProductReq = + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class); getRelatedProductReq.setFormat(format); - final ODataEntity getRelatedProductRes = getRelatedProductReq.execute().getBody(); + final ClientEntity getRelatedProductRes = getRelatedProductReq.execute().getBody(); assertNotNull(getRelatedProductRes); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Product", getRelatedProductRes.getTypeName().toString()); @@ -124,10 +124,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI"); assertNotNull(boundOp); - final ODataInvokeRequest<ODataEntity> getDefaultPIReq = - client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataEntity.class); + final ODataInvokeRequest<ClientEntity> getDefaultPIReq = + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientEntity.class); getDefaultPIReq.setFormat(format); - final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); + final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); assertNotNull(getDefaultPIRes); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", getDefaultPIRes.getTypeName().toString()); @@ -138,10 +138,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo"); assertNotNull(boundOp); - final ODataInvokeRequest<ODataProperty> getAccountInfoReq = - client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataProperty.class); + final ODataInvokeRequest<ClientProperty> getAccountInfoReq = + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class); getAccountInfoReq.setFormat(format); - final ODataProperty getAccountInfoRes = getAccountInfoReq.execute().getBody(); + final ClientProperty getAccountInfoRes = getAccountInfoReq.execute().getBody(); assertNotNull(getAccountInfoRes); assertTrue(getAccountInfoRes.hasComplexValue()); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.AccountInfo", @@ -158,12 +158,12 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount"); assertNotNull(boundOp); - final ODataPrimitiveValue bonusRate = client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1); - final ODataInvokeRequest<ODataProperty> getActualAmountReq = - client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataProperty.class, - Collections.<String, ODataValue> singletonMap("bonusRate", bonusRate)); + final ClientPrimitiveValue bonusRate = client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1); + final ODataInvokeRequest<ClientProperty> getActualAmountReq = + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ClientProperty.class, + Collections.<String, ClientValue> singletonMap("bonusRate", bonusRate)); getActualAmountReq.setFormat(format); - final ODataProperty getActualAmountRes = getActualAmountReq.execute().getBody(); + final ClientProperty getActualAmountRes = getActualAmountReq.execute().getBody(); assertNotNull(getActualAmountRes); assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0); } @@ -181,26 +181,26 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { @Test public void edmEnabledFunctions() throws EdmPrimitiveTypeException { // GetEmployeesCount - final ODataInvokeRequest<ODataProperty> getEmployeesCountReq = + final ODataInvokeRequest<ClientProperty> getEmployeesCountReq = edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( edmClient.newURIBuilder().appendSingletonSegment("Company").build(), new FullQualifiedName(("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount")), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"), false); - final ODataProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody(); + final ClientProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody(); assertNotNull(getEmployeesCountRes); assertTrue(getEmployeesCountRes.hasPrimitiveValue()); // GetProductDetails - final ODataPrimitiveValue count = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1); - final ODataInvokeRequest<ODataEntitySet> getProductDetailsReq = + final ClientPrimitiveValue count = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1); + final ODataInvokeRequest<ClientEntitySet> getProductDetailsReq = edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( edmClient.newURIBuilder().appendEntitySetSegment("Products").appendKeySegment(5).build(), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product"), false, - Collections.<String, ODataValue> singletonMap("count", count)); - final ODataEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody(); + Collections.<String, ClientValue> singletonMap("count", count)); + final ClientEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody(); assertNotNull(getProductDetailsRes); assertEquals(1, getProductDetailsRes.getEntities().size()); @@ -210,26 +210,26 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { keyMap.put("ProductDetailID", 1); URIBuilder builder = edmClient.newURIBuilder().appendEntitySetSegment("ProductDetails").appendKeySegment(keyMap); - final ODataInvokeRequest<ODataEntity> getRelatedProductReq = + final ODataInvokeRequest<ClientEntity> getRelatedProductReq = edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( builder.build(), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct"), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail"), false); - final ODataEntity getRelatedProductRes = getRelatedProductReq.execute().getBody(); + final ClientEntity getRelatedProductRes = getRelatedProductReq.execute().getBody(); assertNotNull(getRelatedProductRes); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Product", getRelatedProductRes.getTypeName().toString()); assertEquals(6, getRelatedProductRes.getProperty("ProductID").getPrimitiveValue().toCastValue(Integer.class), 0); // GetDefaultPI - final ODataInvokeRequest<ODataEntity> getDefaultPIReq = + final ODataInvokeRequest<ClientEntity> getDefaultPIReq = edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).build(), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI"), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Account"), false); - final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); + final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); assertNotNull(getDefaultPIRes); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", getDefaultPIRes.getTypeName().toString()); @@ -237,29 +237,29 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { getDefaultPIRes.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0); // GetAccountInfo - final ODataInvokeRequest<ODataProperty> getAccountInfoReq = + final ODataInvokeRequest<ClientProperty> getAccountInfoReq = edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).build(), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo"), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Account"), false); - final ODataProperty getAccountInfoRes = getAccountInfoReq.execute().getBody(); + final ClientProperty getAccountInfoRes = getAccountInfoReq.execute().getBody(); assertNotNull(getAccountInfoRes); assertTrue(getAccountInfoRes.hasComplexValue()); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.AccountInfo", getAccountInfoRes.getComplexValue().getTypeName()); // GetActualAmount - final ODataPrimitiveValue bonusRate = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1); - final ODataInvokeRequest<ODataProperty> getActualAmountReq = + final ClientPrimitiveValue bonusRate = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1); + final ODataInvokeRequest<ClientProperty> getActualAmountReq = edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102). appendNavigationSegment("MyGiftCard").build(), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount"), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GiftCard"), false, - Collections.<String, ODataValue> singletonMap("bonusRate", bonusRate)); - final ODataProperty getActualAmountRes = getActualAmountReq.execute().getBody(); + Collections.<String, ClientValue> singletonMap("bonusRate", bonusRate)); + final ClientProperty getActualAmountRes = getActualAmountReq.execute().getBody(); assertNotNull(getActualAmountRes); assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0); } @@ -267,22 +267,22 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { private void actions(final ODataFormat format) throws EdmPrimitiveTypeException { // IncreaseRevenue URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); - ODataEntityRequest<ODataEntity> entityReq = + ODataEntityRequest<ClientEntity> entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build()); entityReq.setFormat(format); - ODataEntity entity = entityReq.execute().getBody(); + ClientEntity entity = entityReq.execute().getBody(); assertNotNull(entity); - ODataOperation boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue"); + ClientOperation boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue"); assertNotNull(boundOp); - final ODataPrimitiveValue increaseValue = + final ClientPrimitiveValue increaseValue = client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(12L); - final ODataInvokeRequest<ODataProperty> increaseRevenueReq = - client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataProperty.class, - Collections.<String, ODataValue> singletonMap("IncreaseValue", increaseValue)); + final ODataInvokeRequest<ClientProperty> increaseRevenueReq = + client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class, + Collections.<String, ClientValue> singletonMap("IncreaseValue", increaseValue)); increaseRevenueReq.setFormat(format); - final ODataProperty increaseRevenueRes = increaseRevenueReq.execute().getBody(); + final ClientProperty increaseRevenueRes = increaseRevenueReq.execute().getBody(); assertNotNull(increaseRevenueRes); assertTrue(increaseRevenueRes.hasPrimitiveValue()); @@ -297,13 +297,13 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"); assertNotNull(boundOp); - final ODataEnumValue accessRight = client.getObjectFactory(). + final ClientEnumValue accessRight = client.getObjectFactory(). newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "Execute"); - final ODataInvokeRequest<ODataProperty> getProductDetailsReq = - client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataProperty.class, - Collections.<String, ODataValue> singletonMap("accessRight", accessRight)); + final ODataInvokeRequest<ClientProperty> getProductDetailsReq = + client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientProperty.class, + Collections.<String, ClientValue> singletonMap("accessRight", accessRight)); getProductDetailsReq.setFormat(format); - final ODataProperty getProductDetailsRes = getProductDetailsReq.execute().getBody(); + final ClientProperty getProductDetailsRes = getProductDetailsReq.execute().getBody(); assertNotNull(getProductDetailsRes); assertTrue(getProductDetailsRes.hasEnumValue()); @@ -318,10 +318,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"); assertNotNull(boundOp); - final ODataCollectionValue<org.apache.olingo.commons.api.domain.ODataValue> addresses = + final ClientCollectionValue<ClientValue> addresses = client.getObjectFactory(). newCollectionValue("Collection(Microsoft.Test.OData.Services.ODataWCFService.Address)"); - final ODataComplexValue address = client.getObjectFactory(). + final ClientComplexValue address = client.getObjectFactory(). newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address"); address.add(client.getObjectFactory().newPrimitiveProperty("Street", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Piazza La Bomba E Scappa"))); @@ -330,14 +330,14 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode", client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010"))); addresses.add(address); - final ODataPrimitiveValue index = client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(0); - final Map<String, ODataValue> params = new LinkedHashMap<String, ODataValue>(2); + final ClientPrimitiveValue index = client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(0); + final Map<String, ClientValue> params = new LinkedHashMap<String, ClientValue>(2); params.put("addresses", addresses); params.put("index", index); - final ODataInvokeRequest<ODataEntity> resetAddressReq = - client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataEntity.class, params); + final ODataInvokeRequest<ClientEntity> resetAddressReq = + client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class, params); resetAddressReq.setFormat(format); - final ODataEntity resetAddressRes = resetAddressReq.execute().getBody(); + final ClientEntity resetAddressRes = resetAddressReq.execute().getBody(); assertNotNull(resetAddressRes); assertEquals(2, resetAddressRes.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0); @@ -354,13 +354,13 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")); dateTime.set(2014, 3, 9, 0, 0, 0); - final ODataPrimitiveValue newDate = client.getObjectFactory().newPrimitiveValueBuilder(). + final ClientPrimitiveValue newDate = client.getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build(); - final ODataInvokeRequest<ODataEntity> getDefaultPIReq = - client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataEntity.class, - Collections.<String, ODataValue> singletonMap("newDate", newDate)); + final ODataInvokeRequest<ClientEntity> getDefaultPIReq = + client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ClientEntity.class, + Collections.<String, ClientValue> singletonMap("newDate", newDate)); getDefaultPIReq.setFormat(format); - final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); + final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); assertNotNull(getDefaultPIRes); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", getDefaultPIRes.getTypeName().toString()); @@ -381,37 +381,37 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { @Test public void edmEnabledActions() throws EdmPrimitiveTypeException { // IncreaseRevenue - final ODataPrimitiveValue increaseValue = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt64(12L); - final ODataInvokeRequest<ODataProperty> increaseRevenueReq = + final ClientPrimitiveValue increaseValue = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt64(12L); + final ODataInvokeRequest<ClientProperty> increaseRevenueReq = edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest( edmClient.newURIBuilder().appendSingletonSegment("Company").build(), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue"), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"), false, - Collections.<String, ODataValue> singletonMap("IncreaseValue", increaseValue)); - final ODataProperty increaseRevenueRes = increaseRevenueReq.execute().getBody(); + Collections.<String, ClientValue> singletonMap("IncreaseValue", increaseValue)); + final ClientProperty increaseRevenueRes = increaseRevenueReq.execute().getBody(); assertNotNull(increaseRevenueRes); assertTrue(increaseRevenueRes.hasPrimitiveValue()); // AddAccessRight - final ODataEnumValue accessRight = edmClient.getObjectFactory(). + final ClientEnumValue accessRight = edmClient.getObjectFactory(). newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "Execute"); - final ODataInvokeRequest<ODataProperty> getProductDetailsReq = + final ODataInvokeRequest<ClientProperty> getProductDetailsReq = edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest( edmClient.newURIBuilder().appendEntitySetSegment("Products").appendKeySegment(5).build(), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product"), false, - Collections.<String, ODataValue> singletonMap("accessRight", accessRight)); - final ODataProperty getProductDetailsRes = getProductDetailsReq.execute().getBody(); + Collections.<String, ClientValue> singletonMap("accessRight", accessRight)); + final ClientProperty getProductDetailsRes = getProductDetailsReq.execute().getBody(); assertNotNull(getProductDetailsRes); assertTrue(getProductDetailsRes.hasEnumValue()); // ResetAddress - final ODataCollectionValue<org.apache.olingo.commons.api.domain.ODataValue> addresses = + final ClientCollectionValue<ClientValue> addresses = edmClient.getObjectFactory(). newCollectionValue("Collection(Microsoft.Test.OData.Services.ODataWCFService.Address)"); - final ODataComplexValue address = edmClient.getObjectFactory(). + final ClientComplexValue address = edmClient.getObjectFactory(). newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address"); address.add(edmClient.getObjectFactory().newPrimitiveProperty("Street", edmClient.getObjectFactory().newPrimitiveValueBuilder().buildString("Piazza La Bomba E Scappa"))); @@ -420,36 +420,36 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { address.add(edmClient.getObjectFactory().newPrimitiveProperty("PostalCode", edmClient.getObjectFactory().newPrimitiveValueBuilder().buildString("66010"))); addresses.add(address); - final ODataPrimitiveValue index = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(0); - final Map<String, ODataValue> params = new LinkedHashMap<String, ODataValue>(2); + final ClientPrimitiveValue index = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(0); + final Map<String, ClientValue> params = new LinkedHashMap<String, ClientValue>(2); params.put("addresses", addresses); params.put("index", index); final Map<String, Object> keys = new HashMap<String, Object>(); keys.put("PersonID", 2); - final ODataInvokeRequest<ODataEntity> resetAddressReq = + final ODataInvokeRequest<ClientEntity> resetAddressReq = edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest( edmClient.newURIBuilder().appendEntitySetSegment("Customers").appendKeySegment(keys).build(), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Person"), false, params); - final ODataEntity resetAddressRes = resetAddressReq.execute().getBody(); + final ClientEntity resetAddressRes = resetAddressReq.execute().getBody(); assertNotNull(resetAddressRes); assertEquals(2, resetAddressRes.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0); // RefreshDefaultPI Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")); dateTime.set(2014, 3, 9, 0, 0, 0); - final ODataPrimitiveValue newDate = edmClient.getObjectFactory().newPrimitiveValueBuilder(). + final ClientPrimitiveValue newDate = edmClient.getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build(); - final ODataInvokeRequest<ODataEntity> getDefaultPIReq = + final ODataInvokeRequest<ClientEntity> getDefaultPIReq = edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest( edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).build(), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI"), new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Account"), false, - Collections.<String, ODataValue> singletonMap("newDate", newDate)); - final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); + Collections.<String, ClientValue> singletonMap("newDate", newDate)); + final ClientEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); assertNotNull(getDefaultPIRes); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", getDefaultPIRes.getTypeName().toString());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java index 93b52ca..06e3552 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/ConformanceTestITCase.java @@ -1,18 +1,18 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -46,16 +46,16 @@ import org.apache.olingo.client.api.uri.URIBuilder; import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory; import org.apache.olingo.client.core.http.DefaultHttpClientFactory; import org.apache.olingo.client.core.uri.URIUtils; -import org.apache.olingo.commons.api.domain.ODataCollectionValue; -import org.apache.olingo.commons.api.domain.ODataDelta; -import org.apache.olingo.commons.api.domain.ODataEntity; -import org.apache.olingo.commons.api.domain.ODataEntitySet; -import org.apache.olingo.commons.api.domain.ODataProperty; -import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.ClientCollectionValue; +import org.apache.olingo.commons.api.domain.ClientDelta; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientEntitySet; +import org.apache.olingo.commons.api.domain.ClientProperty; +import org.apache.olingo.commons.api.domain.ClientValue; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.format.ODataFormat; -import org.apache.olingo.commons.core.domain.ODataEntityImpl; +import org.apache.olingo.commons.core.domain.ClientEntityImpl; import org.junit.Test; /** @@ -73,7 +73,7 @@ public class ConformanceTestITCase extends AbstractTestITCase { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company"); - final ODataEntityRequest<ODataEntity> req = + final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); assertEquals("4.0", req.getHeader("OData-MaxVersion")); @@ -87,36 +87,36 @@ public class ConformanceTestITCase extends AbstractTestITCase { */ @Test public void item2() { - final ODataEntity order = - new ODataEntityImpl(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order")); + final ClientEntity order = + new ClientEntityImpl(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order")); - final ODataProperty orderId = getClient().getObjectFactory().newPrimitiveProperty("OrderID", + final ClientProperty orderId = getClient().getObjectFactory().newPrimitiveProperty("OrderID", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(2000)); order.getProperties().add(orderId); Calendar dateTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")); dateTime.set(2011, 2, 4, 16, 3, 57); - final ODataProperty orderDate = getClient().getObjectFactory().newPrimitiveProperty("OrderDate", + final ClientProperty orderDate = getClient().getObjectFactory().newPrimitiveProperty("OrderDate", getClient().getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(dateTime).build()); order.getProperties().add(orderDate); - final ODataProperty shelfLife = getClient().getObjectFactory().newPrimitiveProperty("ShelfLife", + final ClientProperty shelfLife = getClient().getObjectFactory().newPrimitiveProperty("ShelfLife", getClient().getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000001")).build()); order.getProperties().add(shelfLife); - final ODataCollectionValue<ODataValue> orderShelfLifesValue = getClient().getObjectFactory(). + final ClientCollectionValue<ClientValue> orderShelfLifesValue = getClient().getObjectFactory(). newCollectionValue("Collection(Duration)"); orderShelfLifesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000001")).build()); orderShelfLifesValue.add(getClient().getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build()); - final ODataProperty orderShelfLifes = getClient().getObjectFactory(). + final ClientProperty orderShelfLifes = getClient().getObjectFactory(). newCollectionProperty("OrderShelfLifes", orderShelfLifesValue); order.getProperties().add(orderShelfLifes); - final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest( + final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest( getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Orders").build(), order); req.setFormat(ODataFormat.JSON_FULL_METADATA); @@ -136,7 +136,7 @@ public class ConformanceTestITCase extends AbstractTestITCase { ODataFormat.JSON_FULL_METADATA.getContentType().toContentTypeString(), req.getContentType()); - final ODataEntity created = req.execute().getBody(); + final ClientEntity created = req.execute().getBody(); assertNotNull(created); final URI deleteURI = created.getEditLink() == null @@ -156,14 +156,14 @@ public class ConformanceTestITCase extends AbstractTestITCase { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("redirect"). appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company"); - final ODataEntityRequest<ODataEntity> req = + final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); assertEquals("4.0", req.getHeader("OData-MaxVersion")); assertEquals("4.0", req.getHeader(HeaderName.odataMaxVersion.toString())); - final ODataRetrieveResponse<ODataEntity> res = req.execute(); - final ODataEntity entity = res.getBody(); + final ODataRetrieveResponse<ClientEntity> res = req.execute(); + final ClientEntity entity = res.getBody(); assertNotNull(entity); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString()); @@ -178,13 +178,13 @@ public class ConformanceTestITCase extends AbstractTestITCase { public void item5() { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); - ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). + ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory(). getEntitySetRequest(uriBuilder.build()); req.setFormat(ODataFormat.JSON_FULL_METADATA); req.setPrefer(client.newPreferences().maxPageSize(5)); - ODataRetrieveResponse<ODataEntitySet> res = req.execute(); - ODataEntitySet feed = res.getBody(); + ODataRetrieveResponse<ClientEntitySet> res = req.execute(); + ClientEntitySet feed = res.getBody(); assertNotNull(feed); @@ -212,7 +212,7 @@ public class ConformanceTestITCase extends AbstractTestITCase { public void item6() { final Integer id = 2000; - ODataEntity rowIndex = getClient().getObjectFactory().newEntity( + ClientEntity rowIndex = getClient().getObjectFactory().newEntity( new FullQualifiedName("Microsoft.Test.OData.Services.OpenTypesServiceV4.RowIndex")); getClient().getBinder().add(rowIndex, getClient().getObjectFactory().newPrimitiveProperty("Id", @@ -227,11 +227,11 @@ public class ConformanceTestITCase extends AbstractTestITCase { rowIndex.addLink(client.getObjectFactory().newEntityNavigationLink( "Row", URI.create(testOpenTypeServiceRootURL + "/Row(71f7d0dc-ede4-45eb-b421-555a2aa1e58f)"))); - final ODataEntityCreateRequest<ODataEntity> createReq = getClient().getCUDRequestFactory(). + final ODataEntityCreateRequest<ClientEntity> createReq = getClient().getCUDRequestFactory(). getEntityCreateRequest(getClient().newURIBuilder(testOpenTypeServiceRootURL). appendEntitySetSegment("RowIndex").build(), rowIndex); - final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute(); + final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute(); assertEquals(201, createRes.getStatusCode()); final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL). @@ -256,7 +256,7 @@ public class ConformanceTestITCase extends AbstractTestITCase { final URI uri = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).build(); - final ODataEntity patch = client.getObjectFactory().newEntity( + final ClientEntity patch = client.getObjectFactory().newEntity( new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer")); patch.setEditLink(uri); @@ -264,13 +264,13 @@ public class ConformanceTestITCase extends AbstractTestITCase { patch.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("FirstName", getClient().getObjectFactory().newPrimitiveValueBuilder().buildString(newname))); - final ODataEntityUpdateRequest<ODataEntity> req = + final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityUpdateRequest(UpdateType.PATCH, patch); - final ODataEntityUpdateResponse<ODataEntity> res = req.execute(); + final ODataEntityUpdateResponse<ClientEntity> res = req.execute(); assertEquals(204, res.getStatusCode()); - final ODataEntity actual = read(ODataFormat.JSON, uri); + final ClientEntity actual = read(ODataFormat.JSON, uri); assertEquals(newname, actual.getProperty("FirstName").getPrimitiveValue().toString()); } @@ -287,7 +287,8 @@ public class ConformanceTestITCase extends AbstractTestITCase { final URIBuilder uriBuilder = client.newURIBuilder(testAuthServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company"); - final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); + final ODataEntityRequest<ClientEntity> req = + client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(ODataFormat.JSON_FULL_METADATA); assertNotNull(req.execute().getBody()); @@ -304,13 +305,13 @@ public class ConformanceTestITCase extends AbstractTestITCase { appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder"). appendRefSegment(); - ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); + ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(ODataFormat.JSON_FULL_METADATA); - ODataRetrieveResponse<ODataEntity> res = req.execute(); + ODataRetrieveResponse<ClientEntity> res = req.execute(); assertNotNull(res); - final ODataEntity entity = res.getBody(); + final ClientEntity entity = res.getBody(); assertNotNull(entity); assertTrue(entity.getId().toASCIIString().endsWith("/StaticService/V40/Static.svc/Customers(PersonID=1)")); @@ -330,18 +331,18 @@ public class ConformanceTestITCase extends AbstractTestITCase { */ @Test public void item10() { - final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest( + final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest( client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build()); req.setPrefer(client.newPreferences().trackChanges()); - final ODataEntitySet customers = req.execute().getBody(); + final ClientEntitySet customers = req.execute().getBody(); assertNotNull(customers); assertNotNull(customers.getDeltaLink()); final ODataDeltaRequest deltaReq = client.getRetrieveRequestFactory().getDeltaRequest(customers.getDeltaLink()); deltaReq.setFormat(ODataFormat.JSON_FULL_METADATA); - final ODataDelta delta = deltaReq.execute().getBody(); + final ClientDelta delta = deltaReq.execute().getBody(); assertNotNull(delta); assertNotNull(delta.getDeltaLink()); @@ -363,7 +364,7 @@ public class ConformanceTestITCase extends AbstractTestITCase { assertEquals("Orders", delta.getDeletedLinks().get(0).getRelationship()); assertEquals(2, delta.getEntities().size()); - ODataProperty property = delta.getEntities().get(0).getProperty("ContactName"); + ClientProperty property = delta.getEntities().get(0).getProperty("ContactName"); assertNotNull(property); assertTrue(property.hasPrimitiveValue()); property = delta.getEntities().get(1).getProperty("ShippingAddress"); @@ -379,21 +380,21 @@ public class ConformanceTestITCase extends AbstractTestITCase { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("async").appendEntitySetSegment("Orders"); - final ODataEntitySetRequest<ODataEntitySet> req = + final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()); req.setFormat(ODataFormat.JSON_FULL_METADATA); - final AsyncRequestWrapper<ODataRetrieveResponse<ODataEntitySet>> async = - client.getAsyncRequestFactory().<ODataRetrieveResponse<ODataEntitySet>> getAsyncRequestWrapper(req); + final AsyncRequestWrapper<ODataRetrieveResponse<ClientEntitySet>> async = + client.getAsyncRequestFactory().<ODataRetrieveResponse<ClientEntitySet>> getAsyncRequestWrapper(req); async.callback(URI.create("http://client.service.it/callback/endpoint")); - final AsyncResponseWrapper<ODataRetrieveResponse<ODataEntitySet>> responseWrapper = async.execute(); + final AsyncResponseWrapper<ODataRetrieveResponse<ClientEntitySet>> responseWrapper = async.execute(); assertTrue(responseWrapper.isPreferenceApplied()); assertTrue(responseWrapper.isDone()); - final ODataRetrieveResponse<ODataEntitySet> res = responseWrapper.getODataResponse(); - final ODataEntitySet entitySet = res.getBody(); + final ODataRetrieveResponse<ClientEntitySet> res = responseWrapper.getODataResponse(); + final ClientEntitySet entitySet = res.getBody(); assertFalse(entitySet.getEntities().isEmpty()); } @@ -406,7 +407,7 @@ public class ConformanceTestITCase extends AbstractTestITCase { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company"); - final ODataEntityRequest<ODataEntity> req = + final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(ODataFormat.JSON); @@ -414,7 +415,7 @@ public class ConformanceTestITCase extends AbstractTestITCase { assertEquals("application/json;odata.metadata=minimal", req.getHeader(HeaderName.accept.toString())); assertEquals("application/json;odata.metadata=minimal", req.getAccept()); - final ODataRetrieveResponse<ODataEntity> res = req.execute(); + final ODataRetrieveResponse<ClientEntity> res = req.execute(); assertTrue(res.getContentType().startsWith("application/json; odata.metadata=minimal")); assertNotNull(res.getBody()); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java index fa3b533..1a7bfe0 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java @@ -1,18 +1,18 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -20,9 +20,9 @@ package org.apache.olingo.fit.v4; import org.apache.olingo.client.api.communication.request.retrieve.ODataDeltaRequest; import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest; -import org.apache.olingo.commons.api.domain.ODataDelta; -import org.apache.olingo.commons.api.domain.ODataEntitySet; -import org.apache.olingo.commons.api.domain.ODataProperty; +import org.apache.olingo.commons.api.domain.ClientDelta; +import org.apache.olingo.commons.api.domain.ClientEntitySet; +import org.apache.olingo.commons.api.domain.ClientProperty; import org.apache.olingo.commons.api.format.ODataFormat; import org.junit.Test; @@ -33,18 +33,18 @@ import static org.junit.Assert.assertTrue; public class DeltaTestITCase extends AbstractTestITCase { private void parse(final ODataFormat format) { - final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest( + final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest( client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build()); req.setPrefer(client.newPreferences().trackChanges()); - final ODataEntitySet customers = req.execute().getBody(); + final ClientEntitySet customers = req.execute().getBody(); assertNotNull(customers); assertNotNull(customers.getDeltaLink()); final ODataDeltaRequest deltaReq = client.getRetrieveRequestFactory().getDeltaRequest(customers.getDeltaLink()); deltaReq.setFormat(format); - final ODataDelta delta = deltaReq.execute().getBody(); + final ClientDelta delta = deltaReq.execute().getBody(); assertNotNull(delta); assertNotNull(delta.getDeltaLink()); @@ -66,7 +66,7 @@ public class DeltaTestITCase extends AbstractTestITCase { assertEquals("Orders", delta.getDeletedLinks().get(0).getRelationship()); assertEquals(2, delta.getEntities().size()); - ODataProperty property = delta.getEntities().get(0).getProperty("ContactName"); + ClientProperty property = delta.getEntities().get(0).getProperty("ContactName"); assertNotNull(property); assertTrue(property.hasPrimitiveValue()); property = delta.getEntities().get(1).getProperty("ShippingAddress"); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java index fcc1f61..087ef8e 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java @@ -1,18 +1,18 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -30,10 +30,10 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest; import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse; import org.apache.olingo.client.api.uri.URIBuilder; -import org.apache.olingo.commons.api.domain.ODataComplexValue; -import org.apache.olingo.commons.api.domain.ODataEntity; -import org.apache.olingo.commons.api.domain.ODataEntitySet; -import org.apache.olingo.commons.api.domain.ODataValuable; +import org.apache.olingo.commons.api.domain.ClientComplexValue; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientEntitySet; +import org.apache.olingo.commons.api.domain.ClientValuable; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.format.ODataFormat; @@ -46,11 +46,11 @@ public class DerivedTypeTestITCase extends AbstractTestITCase { URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People"). appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.Customer"); - ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). + ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory(). getEntitySetRequest(uriBuilder.build()); req.setFormat(format); - for (ODataEntity customer : req.execute().getBody().getEntities()) { + for (ClientEntity customer : req.execute().getBody().getEntities()) { assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", customer.getTypeName().toString()); } @@ -62,7 +62,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase { req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()); req.setFormat(format); - for (ODataEntity customer : req.execute().getBody().getEntities()) { + for (ClientEntity customer : req.execute().getBody().getEntities()) { assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", customer.getTypeName().toString()); } } @@ -78,7 +78,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase { } private void createDelete(final ODataFormat format) { - final ODataEntity customer = client.getObjectFactory(). + final ClientEntity customer = client.getObjectFactory(). newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer")); customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("PersonID", @@ -88,7 +88,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase { customer.getProperties().add(client.getObjectFactory().newPrimitiveProperty("LastName", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Test"))); - final ODataComplexValue homeAddress = + final ClientComplexValue homeAddress = client.getObjectFactory().newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress"); homeAddress.add(client.getObjectFactory().newPrimitiveProperty("Street", client.getObjectFactory().newPrimitiveValueBuilder().buildString("V.le Gabriele D'Annunzio"))); @@ -115,24 +115,24 @@ public class DerivedTypeTestITCase extends AbstractTestITCase { client.getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build())); - final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory(). + final ODataEntityCreateRequest<ClientEntity> createReq = client.getCUDRequestFactory(). getEntityCreateRequest( client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People").build(), customer); createReq.setFormat(format); - final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute(); + final ODataEntityCreateResponse<ClientEntity> createRes = createReq.execute(); assertEquals(201, createRes.getStatusCode()); - final ODataEntityRequest<ODataEntity> fetchReq = client.getRetrieveRequestFactory(). + final ODataEntityRequest<ClientEntity> fetchReq = client.getRetrieveRequestFactory(). getEntityRequest(client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").appendKeySegment(976).build()); fetchReq.setFormat(format); - final ODataEntity actual = fetchReq.execute().getBody(); + final ClientEntity actual = fetchReq.execute().getBody(); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", actual.getTypeName().toString()); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress", - ((ODataValuable) actual.getProperty("HomeAddress")).getValue().getTypeName()); + ((ClientValuable) actual.getProperty("HomeAddress")).getValue().getTypeName()); final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(actual.getEditLink()); assertEquals(204, deleteReq.execute().getStatusCode()); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java index a92db26..5ad4407 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java @@ -1,18 +1,18 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -22,10 +22,10 @@ import org.apache.commons.lang3.RandomUtils; import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest; import org.apache.olingo.client.api.communication.response.ODataDeleteResponse; import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse; -import org.apache.olingo.commons.api.domain.ODataEntity; -import org.apache.olingo.commons.api.domain.ODataEntitySet; -import org.apache.olingo.commons.api.domain.ODataInlineEntitySet; -import org.apache.olingo.commons.api.domain.ODataLink; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientEntitySet; +import org.apache.olingo.commons.api.domain.ClientInlineEntitySet; +import org.apache.olingo.commons.api.domain.ClientLink; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -52,18 +52,17 @@ public class EntityCreateTestITCase extends AbstractTestITCase { createAndDeleteOrder(testStaticServiceRootURL, ODataFormat.JSON_FULL_METADATA, 1001); } - private void onContained(final ODataFormat format) { final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts"). appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build(); // 1. read contained collection before any operation - ODataEntitySet instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody(); + ClientEntitySet instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody(); assertNotNull(instruments); final int sizeBefore = instruments.getCount(); // 2. instantiate an ODataEntity of the same type as the collection above - final ODataEntity instrument = getClient().getObjectFactory(). + final ClientEntity instrument = getClient().getObjectFactory(). newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument")); int id = RandomUtils.nextInt(101999, 105000); @@ -76,11 +75,11 @@ public class EntityCreateTestITCase extends AbstractTestITCase { setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()).build())); // 3. create it as contained entity - final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory(). + final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory(). getEntityCreateRequest(uri, instrument); req.setFormat(format); - final ODataEntityCreateResponse<ODataEntity> res = req.execute(); + final ODataEntityCreateResponse<ClientEntity> res = req.execute(); assertEquals(201, res.getStatusCode()); // 4. verify that the contained collection effectively grew @@ -114,7 +113,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { private void deepInsert(final ODataFormat format, final int productId, final int productDetailId) throws EdmPrimitiveTypeException { - final ODataEntity product = getClient().getObjectFactory(). + final ClientEntity product = getClient().getObjectFactory(). newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product")); product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductID", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productId))); @@ -142,7 +141,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { product.getProperty("CoverColors").getCollectionValue().add(getClient().getObjectFactory(). newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Red")); - final ODataEntity detail = getClient().getObjectFactory(). + final ClientEntity detail = getClient().getObjectFactory(). newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail")); detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductID", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productId))); @@ -153,27 +152,27 @@ public class EntityCreateTestITCase extends AbstractTestITCase { detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Description", getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("High-Quality Milk"))); - final ODataEntitySet details = getClient().getObjectFactory().newEntitySet(); + final ClientEntitySet details = getClient().getObjectFactory().newEntitySet(); details.getEntities().add(detail); - final ODataInlineEntitySet inlineDetails = getClient().getObjectFactory(). + final ClientInlineEntitySet inlineDetails = getClient().getObjectFactory(). newDeepInsertEntitySet("Details", details); product.addLink(inlineDetails); - final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest( + final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest( getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Products").build(), product); req.setFormat(format); - final ODataEntityCreateResponse<ODataEntity> res = req.execute(); + final ODataEntityCreateResponse<ClientEntity> res = req.execute(); assertEquals(201, res.getStatusCode()); - final ODataEntity createdProduct = res.getBody(); + final ClientEntity createdProduct = res.getBody(); assertEquals(productId, createdProduct.getProperty("ProductID").getPrimitiveValue().toCastValue(Integer.class), 0); - final ODataLink createdLink = createdProduct.getNavigationLink("Details"); + final ClientLink createdLink = createdProduct.getNavigationLink("Details"); assertNotNull(createdLink); - final ODataEntitySet createdProductDetails = + final ClientEntitySet createdProductDetails = getClient().getRetrieveRequestFactory().getEntitySetRequest(createdLink.getLink()).execute().getBody(); assertNotNull(createdProductDetails); assertEquals(productDetailId, createdProductDetails.getEntities().iterator().next(). http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java index 35c638a..8b47d38 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java @@ -1,18 +1,18 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -32,13 +32,13 @@ import org.apache.olingo.client.api.communication.response.ODataRawResponse; import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse; import org.apache.olingo.client.api.uri.URIBuilder; import org.apache.olingo.commons.api.data.ResWrap; -import org.apache.olingo.commons.api.domain.ODataEntity; -import org.apache.olingo.commons.api.domain.ODataEntitySet; -import org.apache.olingo.commons.api.domain.ODataProperty; -import org.apache.olingo.commons.api.domain.ODataInlineEntity; -import org.apache.olingo.commons.api.domain.ODataInlineEntitySet; -import org.apache.olingo.commons.api.domain.ODataLink; -import org.apache.olingo.commons.api.domain.ODataLinkType; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientEntitySet; +import org.apache.olingo.commons.api.domain.ClientProperty; +import org.apache.olingo.commons.api.domain.ClientInlineEntity; +import org.apache.olingo.commons.api.domain.ClientInlineEntitySet; +import org.apache.olingo.commons.api.domain.ClientLink; +import org.apache.olingo.commons.api.domain.ClientLinkType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.format.ODataFormat; import org.junit.Test; @@ -55,14 +55,14 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { private void withInlineEntity(final ODataClient client, final ODataFormat format) { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company"); + appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company"); - final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory(). - getEntityRequest(uriBuilder.build()); + final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory(). + getEntityRequest(uriBuilder.build()); req.setFormat(format); - final ODataRetrieveResponse<ODataEntity> res = req.execute(); - final ODataEntity entity = res.getBody(); + final ODataRetrieveResponse<ClientEntity> res = req.execute(); + final ClientEntity entity = res.getBody(); assertNotNull(entity); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString()); @@ -81,24 +81,24 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { boolean found = false; - for (ODataLink link : entity.getNavigationLinks()) { - if (link instanceof ODataInlineEntity) { - final ODataEntity inline = ((ODataInlineEntity) link).getEntity(); + for (ClientLink link : entity.getNavigationLinks()) { + if (link instanceof ClientInlineEntity) { + final ClientEntity inline = ((ClientInlineEntity) link).getEntity(); assertNotNull(inline); - final List<? extends ODataProperty> properties = inline.getProperties(); + final List<? extends ClientProperty> properties = inline.getProperties(); assertEquals(5, properties.size()); assertTrue(properties.get(0).getName().equals("CompanyID") - || properties.get(1).getName().equals("CompanyID") - || properties.get(2).getName().equals("CompanyID") - || properties.get(3).getName().equals("CompanyID") - || properties.get(4).getName().equals("CompanyID")); + || properties.get(1).getName().equals("CompanyID") + || properties.get(2).getName().equals("CompanyID") + || properties.get(3).getName().equals("CompanyID") + || properties.get(4).getName().equals("CompanyID")); assertTrue(properties.get(0).getValue().toString().equals("0") - || properties.get(1).getValue().toString().equals("0") - || properties.get(2).getValue().toString().equals("0") - || properties.get(3).getValue().toString().equals("0") - || properties.get(4).getValue().toString().equals("0")); + || properties.get(1).getValue().toString().equals("0") + || properties.get(2).getValue().toString().equals("0") + || properties.get(3).getValue().toString().equals("0") + || properties.get(4).getValue().toString().equals("0")); found = true; } @@ -125,23 +125,23 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { private void withInlineEntitySet(final ODataClient client, final ODataFormat format) { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders"); + appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders"); - final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory(). - getEntityRequest(uriBuilder.build()); + final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory(). + getEntityRequest(uriBuilder.build()); req.setFormat(format); - final ODataRetrieveResponse<ODataEntity> res = req.execute(); - final ODataEntity entity = res.getBody(); + final ODataRetrieveResponse<ClientEntity> res = req.execute(); + final ClientEntity entity = res.getBody(); assertNotNull(entity); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString()); // In JSON with minimal metadata, links are not provided if (format == ODataFormat.ATOM || format == ODataFormat.JSON_FULL_METADATA) { boolean found = false; - for (ODataLink link : entity.getNavigationLinks()) { - if (link instanceof ODataInlineEntitySet) { - final ODataEntitySet inline = ((ODataInlineEntitySet) link).getEntitySet(); + for (ClientLink link : entity.getNavigationLinks()) { + if (link instanceof ClientInlineEntitySet) { + final ClientEntitySet inline = ((ClientInlineEntitySet) link).getEntitySet(); assertNotNull(inline); found = true; @@ -168,7 +168,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { private void rawRequest(final ODataFormat format) { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5); + appendEntitySetSegment("People").appendKeySegment(5); final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build()); req.setFormat(format.getContentType().toContentTypeString()); @@ -176,10 +176,10 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { final ODataRawResponse res = req.execute(); assertNotNull(res); - final ResWrap<ODataEntitySet> entitySet = res.getBodyAs(ODataEntitySet.class); + final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class); assertNull(entitySet); - final ResWrap<ODataEntity> entity = res.getBodyAs(ODataEntity.class); + final ResWrap<ClientEntity> entity = res.getBodyAs(ClientEntity.class); assertTrue(entity.getPayload().getId().toASCIIString().endsWith("/StaticService/V40/Static.svc/People(5)")); } @@ -200,16 +200,17 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { multiKey.put("ProductDetailID", 1); final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("ProductDetails").appendKeySegment(multiKey); + appendEntitySetSegment("ProductDetails").appendKeySegment(multiKey); - final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); + final ODataEntityRequest<ClientEntity> req = + client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); - final ODataRetrieveResponse<ODataEntity> res = req.execute(); - final ODataEntity entity = res.getBody(); + final ODataRetrieveResponse<ClientEntity> res = req.execute(); + final ClientEntity entity = res.getBody(); assertNotNull(entity); assertEquals(Integer.valueOf(1), - entity.getProperty("ProductDetailID").getPrimitiveValue().toCastValue(Integer.class)); + entity.getProperty("ProductDetailID").getPrimitiveValue().toCastValue(Integer.class)); } @Test @@ -224,18 +225,19 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { private void checkForETag(final ODataClient client, final ODataFormat format) { final URIBuilder uriBuilder = - client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8); + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8); - final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); + final ODataEntityRequest<ClientEntity> req = + client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); - final ODataRetrieveResponse<ODataEntity> res = req.execute(); + final ODataRetrieveResponse<ClientEntity> res = req.execute(); assertEquals(200, res.getStatusCode()); final String etag = res.getETag(); assertTrue(StringUtils.isNotBlank(etag)); - final ODataEntity order = res.getBody(); + final ClientEntity order = res.getBody(); assertEquals(etag, order.getETag()); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Order", order.getTypeName().toString()); assertEquals("Edm.Int32", order.getProperty("OrderID").getPrimitiveValue().getTypeName()); @@ -263,7 +265,8 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { public void issue99() { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); - final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); + final ODataEntityRequest<ClientEntity> req = + client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(ODataFormat.JSON); // this statement should cause an IllegalArgumentException bearing JsonParseException @@ -273,21 +276,21 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { private void reference(final ODataFormat format) { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder"). - appendRefSegment(); + appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder"). + appendRefSegment(); - ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); + ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); - ODataRetrieveResponse<ODataEntity> res = req.execute(); + ODataRetrieveResponse<ClientEntity> res = req.execute(); assertNotNull(res); - final ODataEntity entity = res.getBody(); + final ClientEntity entity = res.getBody(); assertNotNull(entity); assertTrue(entity.getId().toASCIIString().endsWith("/StaticService/V40/Static.svc/Customers(PersonID=1)")); final URI referenceURI = client.newURIBuilder(testStaticServiceRootURL). - appendEntityIdSegment(entity.getId().toASCIIString()).build(); + appendEntityIdSegment(entity.getId().toASCIIString()).build(); req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI); req.setFormat(format); @@ -309,16 +312,16 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { private void contained(final ODataClient client, final ODataFormat format) throws EdmPrimitiveTypeException { final URI uri = client.newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Accounts").appendKeySegment(101). - appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build(); - final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri); + appendEntitySetSegment("Accounts").appendKeySegment(101). + appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build(); + final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri); req.setFormat(format); - final ODataEntity contained = req.execute().getBody(); + final ClientEntity contained = req.execute().getBody(); assertNotNull(contained); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", contained.getTypeName().toString()); assertEquals(101902, - contained.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0); + contained.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0); assertEquals("Edm.DateTimeOffset", contained.getProperty("CreatedDate").getPrimitiveValue().getTypeName()); assertNotNull(contained.getProperty("CreatedDate").getPrimitiveValue().toCastValue(Timestamp.class)); } @@ -340,17 +343,17 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { private void entitySetNavigationLink(final ODataClient client, final ODataFormat format) { final URI uri = client.newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Accounts").appendKeySegment(101).build(); - final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri); + appendEntitySetSegment("Accounts").appendKeySegment(101).build(); + final ODataEntityRequest<ClientEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri); req.setFormat(format); - final ODataEntity entity = req.execute().getBody(); + final ClientEntity entity = req.execute().getBody(); assertNotNull(entity); // With JSON, entity set navigation links are only recognizable via Edm if (format == ODataFormat.ATOM || client instanceof EdmEnabledODataClient) { - assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType()); - assertEquals(ODataLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType()); + assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("MyPaymentInstruments").getType()); + assertEquals(ClientLinkType.ENTITY_SET_NAVIGATION, entity.getNavigationLink("ActiveSubscriptions").getType()); } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c37d4da5/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java index 821d7b7..65f54e5 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java @@ -1,18 +1,18 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -28,8 +28,8 @@ import org.apache.olingo.client.api.domain.ODataEntitySetIterator; import org.apache.olingo.client.api.uri.URIBuilder; import org.apache.olingo.client.core.uri.URIUtils; import org.apache.olingo.commons.api.data.ResWrap; -import org.apache.olingo.commons.api.domain.ODataEntity; -import org.apache.olingo.commons.api.domain.ODataEntitySet; +import org.apache.olingo.commons.api.domain.ClientEntity; +import org.apache.olingo.commons.api.domain.ClientEntitySet; import org.apache.olingo.commons.api.format.ODataFormat; import org.junit.Test; @@ -54,7 +54,7 @@ public class EntitySetTestITCase extends AbstractTestITCase { final ODataRawResponse res = req.execute(); assertNotNull(res); - final ResWrap<ODataEntitySet> entitySet = res.getBodyAs(ODataEntitySet.class); + final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class); assertNotNull(entitySet.getPayload()); assertTrue(entitySet.getContextURL().toASCIIString().endsWith("$metadata#People")); } @@ -79,7 +79,7 @@ public class EntitySetTestITCase extends AbstractTestITCase { final ODataRawResponse res = req.execute(); assertNotNull(res); - final ResWrap<ODataEntitySet> entitySet = res.getBodyAs(ODataEntitySet.class); + final ResWrap<ClientEntitySet> entitySet = res.getBodyAs(ClientEntitySet.class); assertEquals(5, entitySet.getPayload().getEntities().size()); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address", @@ -104,12 +104,12 @@ public class EntitySetTestITCase extends AbstractTestITCase { private void readODataEntitySetIterator(final ODataFormat format) { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); - final ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> req = + final ODataEntitySetIteratorRequest<ClientEntitySet, ClientEntity> req = client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build()); req.setFormat(format); - final ODataRetrieveResponse<ODataEntitySetIterator<ODataEntitySet, ODataEntity>> res = req.execute(); - final ODataEntitySetIterator<ODataEntitySet, ODataEntity> feedIterator = res.getBody(); + final ODataRetrieveResponse<ODataEntitySetIterator<ClientEntitySet, ClientEntity>> res = req.execute(); + final ODataEntitySetIterator<ClientEntitySet, ClientEntity> feedIterator = res.getBody(); assertNotNull(feedIterator); @@ -146,13 +146,13 @@ public class EntitySetTestITCase extends AbstractTestITCase { private void readWithNext(final ODataFormat format) { final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); - final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). + final ODataEntitySetRequest<ClientEntitySet> req = client.getRetrieveRequestFactory(). getEntitySetRequest(uriBuilder.build()); req.setFormat(format); req.setPrefer(client.newPreferences().maxPageSize(5)); - final ODataRetrieveResponse<ODataEntitySet> res = req.execute(); - final ODataEntitySet feed = res.getBody(); + final ODataRetrieveResponse<ClientEntitySet> res = req.execute(); + final ClientEntitySet feed = res.getBody(); assertNotNull(feed);
