[OLINGO-1004] Delete OperationImport Tests Duplicated in ActionImportITCase and FunctionImportITCase
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/ee895e69 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/ee895e69 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/ee895e69 Branch: refs/heads/master Commit: ee895e6937214849badb441597b8d3e06b9d5082 Parents: 6e79644 Author: Christian Amend <[email protected]> Authored: Fri Aug 12 13:11:02 2016 +0200 Committer: Christian Amend <[email protected]> Committed: Fri Aug 12 13:11:02 2016 +0200 ---------------------------------------------------------------------- .../base/OperationImportInvokeTestITCase.java | 294 ------------------- 1 file changed, 294 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/ee895e69/fit/src/test/java/org/apache/olingo/fit/base/OperationImportInvokeTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/base/OperationImportInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/OperationImportInvokeTestITCase.java deleted file mode 100644 index f083365..0000000 --- a/fit/src/test/java/org/apache/olingo/fit/base/OperationImportInvokeTestITCase.java +++ /dev/null @@ -1,294 +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.fit.base; - -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.ClientNoContent; -import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; -import org.apache.olingo.client.api.domain.ClientCollectionValue; -import org.apache.olingo.client.api.domain.ClientComplexValue; -import org.apache.olingo.client.api.domain.ClientEntity; -import org.apache.olingo.client.api.domain.ClientEntitySet; -import org.apache.olingo.client.api.domain.ClientEnumValue; -import org.apache.olingo.client.api.domain.ClientPrimitiveValue; -import org.apache.olingo.client.api.domain.ClientProperty; -import org.apache.olingo.client.api.domain.ClientValue; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; -import org.apache.olingo.commons.api.format.ContentType; -import org.junit.Test; - -public class OperationImportInvokeTestITCase extends AbstractTestITCase { - - private void functionImports(final ContentType contentType) throws EdmPrimitiveTypeException { - // GetDefaultColor - final ODataInvokeRequest<ClientProperty> defaultColorReq = getClient().getInvokeRequestFactory(). - getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("GetDefaultColor").build(), ClientProperty.class); - defaultColorReq.setFormat(contentType); - final ClientProperty defaultColor = defaultColorReq.execute().getBody(); - assertNotNull(defaultColor); - assertTrue(defaultColor.hasEnumValue()); - assertEquals("Red", defaultColor.getEnumValue().getValue()); - assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", defaultColor.getEnumValue().getTypeName()); - - // GetPerson2 - final ClientPrimitiveValue city = getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London"); - - final ODataInvokeRequest<ClientEntity> person2Req = getClient().getInvokeRequestFactory(). - getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("GetPerson2").build(), ClientEntity.class, - Collections.<String, ClientValue> singletonMap("city", city)); - person2Req.setFormat(contentType); - final ClientEntity person2 = person2Req.execute().getBody(); - assertNotNull(person2); - assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString()); - assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0); - - // GetPerson - final ClientComplexValue address = getClient().getObjectFactory(). - newComplexValue("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<ClientEntity> personReq = getClient().getInvokeRequestFactory(). - getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("GetPerson").build(), ClientEntity.class, - Collections.<String, ClientValue> singletonMap("address", address)); - personReq.setFormat(contentType); - final ClientEntity person = personReq.execute().getBody(); - assertNotNull(person); - assertEquals(person2, person); - - // GetAllProducts - final ODataInvokeRequest<ClientEntitySet> productsReq = getClient().getInvokeRequestFactory() - .getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("GetAllProducts").build(), ClientEntitySet.class); - productsReq.setFormat(contentType); - final ClientEntitySet products = productsReq.execute().getBody(); - assertNotNull(products); - assertEquals(5, products.getEntities().size()); - - // GetProductsByAccessLevel - final ClientEnumValue accessLevel = getClient().getObjectFactory(). - newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "None"); - - final ODataInvokeRequest<ClientProperty> prodByALReq = getClient().getInvokeRequestFactory(). - getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("GetProductsByAccessLevel").build(), ClientProperty.class, - Collections.<String, ClientValue> singletonMap("accessLevel", accessLevel)); - prodByALReq.setFormat(contentType); - final ClientProperty 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(ContentType.APPLICATION_ATOM_XML); - } - - @Test - public void jsonFunctionImports() throws EdmPrimitiveTypeException { - functionImports(ContentType.JSON_FULL_METADATA); - } - - @Test - public void edmEnabledFunctionImports() throws EdmPrimitiveTypeException { - // GetDefaultColor - final ODataInvokeRequest<ClientProperty> defaultColorReq = edmClient.getInvokeRequestFactory(). - getFunctionImportInvokeRequest("GetDefaultColor"); - final ClientProperty defaultColor = defaultColorReq.execute().getBody(); - assertNotNull(defaultColor); - assertTrue(defaultColor.hasEnumValue()); - assertEquals("Red", defaultColor.getEnumValue().getValue()); - assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", defaultColor.getEnumValue().getTypeName()); - - // GetPerson2 - final ClientPrimitiveValue city = - getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London"); - final ODataInvokeRequest<ClientEntity> person2Req = edmClient.getInvokeRequestFactory(). - getFunctionImportInvokeRequest( - "GetPerson2", Collections.<String, ClientValue> singletonMap("city", city)); - final ClientEntity person2 = person2Req.execute().getBody(); - assertNotNull(person2); - assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", person2.getTypeName().toString()); - assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0); - - // GetPerson - final ClientComplexValue address = getClient().getObjectFactory(). - newComplexValue("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<ClientEntity> personReq = edmClient.getInvokeRequestFactory(). - getFunctionImportInvokeRequest( - "GetPerson", Collections.<String, ClientValue> singletonMap("address", address)); - final ClientEntity person = personReq.execute().getBody(); - assertNotNull(person); - assertEquals(person2, person); - - // GetAllProducts - final ODataInvokeRequest<ClientEntitySet> productsReq = edmClient.getInvokeRequestFactory(). - getFunctionImportInvokeRequest("GetAllProducts"); - final ClientEntitySet products = productsReq.execute().getBody(); - assertNotNull(products); - assertEquals(5, products.getEntities().size()); - - // GetProductsByAccessLevel - final ClientEnumValue accessLevel = getClient().getObjectFactory(). - newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "None"); - - final ODataInvokeRequest<ClientProperty> prodByALReq = edmClient.getInvokeRequestFactory(). - getFunctionImportInvokeRequest( - "GetProductsByAccessLevel", - Collections.<String, ClientValue> singletonMap("accessLevel", accessLevel)); - final ClientProperty prodByAL = prodByALReq.execute().getBody(); - assertNotNull(prodByAL); - assertTrue(prodByAL.hasCollectionValue()); - assertEquals(5, prodByAL.getCollectionValue().size()); - assertTrue(prodByAL.getCollectionValue().asJavaCollection().contains("Car")); - } - - private void actionImports(final ContentType contentType) { - // Discount - final ClientPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22); - final ODataInvokeRequest<ClientNoContent> discountReq = getClient().getInvokeRequestFactory(). - getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("Discount").build(), ClientNoContent.class, - Collections.<String, ClientValue> singletonMap("percentage", percentage)); - discountReq.setFormat(contentType); - final ClientNoContent discount = discountReq.execute().getBody(); - assertNotNull(discount); - - // ResetBossAddress - final ClientComplexValue address = getClient().getObjectFactory(). - newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address"); - address.add(client.getObjectFactory().newPrimitiveProperty("Street", - client.getObjectFactory().newPrimitiveValueBuilder().buildString("Via Le Mani Dal Naso, 123"))); - address.add(client.getObjectFactory().newPrimitiveProperty("City", - client.getObjectFactory().newPrimitiveValueBuilder().buildString("Tollo"))); - address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode", - client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010"))); - - final ODataInvokeRequest<ClientProperty> resetBossAddressReq = getClient().getInvokeRequestFactory(). - getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("ResetBossAddress").build(), ClientProperty.class, - Collections.<String, ClientValue> singletonMap("address", address)); - resetBossAddressReq.setFormat(contentType); - final ClientProperty resetBossAddress = resetBossAddressReq.execute().getBody(); - assertNotNull(resetBossAddress); - assertEquals(address, resetBossAddress.getComplexValue()); - } - - @Test - public void atomActionImports() { - actionImports(ContentType.APPLICATION_ATOM_XML); - } - - @Test - public void jsonActionImports() { - actionImports(ContentType.JSON_FULL_METADATA); - } - - @Test - public void edmEnabledActionImports() { - // Discount - final ClientPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22); - final ODataInvokeRequest<ClientNoContent> discountReq = edmClient.getInvokeRequestFactory(). - getActionImportInvokeRequest( - "Discount", Collections.<String, ClientValue> singletonMap("percentage", percentage)); - final ClientNoContent discount = discountReq.execute().getBody(); - assertNotNull(discount); - - // ResetBossAddress - final ClientComplexValue address = getClient().getObjectFactory(). - newComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address"); - address.add(client.getObjectFactory().newPrimitiveProperty("Street", - client.getObjectFactory().newPrimitiveValueBuilder().buildString("Via Le Mani Dal Naso, 123"))); - address.add(client.getObjectFactory().newPrimitiveProperty("City", - client.getObjectFactory().newPrimitiveValueBuilder().buildString("Tollo"))); - address.add(client.getObjectFactory().newPrimitiveProperty("PostalCode", - client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010"))); - - final ODataInvokeRequest<ClientProperty> resetBossAddressReq = edmClient.getInvokeRequestFactory(). - getActionImportInvokeRequest( - "ResetBossAddress", Collections.<String, ClientValue> singletonMap("address", address)); - final ClientProperty resetBossAddress = resetBossAddressReq.execute().getBody(); - assertNotNull(resetBossAddress); - assertEquals(address.getTypeName(), resetBossAddress.getComplexValue().getTypeName()); - } - - private void bossEmails(final ContentType contentType) { - // ResetBossEmail - final ClientCollectionValue<ClientValue> emails = - getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)"); - emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]")); - emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("[email protected]")); - ODataInvokeRequest<ClientProperty> bossEmailsReq = getClient().getInvokeRequestFactory(). - getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("ResetBossEmail").build(), ClientProperty.class, - Collections.<String, ClientValue> singletonMap("emails", emails)); - bossEmailsReq.setFormat(contentType); - final ClientProperty bossEmails = bossEmailsReq.execute().getBody(); - assertNotNull(bossEmails); - assertTrue(bossEmails.hasCollectionValue()); - assertEquals(2, bossEmails.getCollectionValue().size()); - - final Map<String, ClientValue> params = new LinkedHashMap<String, ClientValue>(2); - params.put("start", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(0)); - params.put("count", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(100)); - bossEmailsReq = getClient().getInvokeRequestFactory().getFunctionInvokeRequest( - getClient().newURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment("GetBossEmails").build(), ClientProperty.class, params); - bossEmailsReq.setFormat(contentType); - final ClientProperty 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(ContentType.APPLICATION_ATOM_XML); - } - - @Test - public void jsonBossEmails() throws EdmPrimitiveTypeException { - bossEmails(ContentType.JSON_FULL_METADATA); - } -}
