You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/09/08 18:39:48 UTC
[31/55] [abbrv] olingo-odata4 git commit: [OLINGO-659] Removed v4
from package and class names
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityCreateTestITCase.java
deleted file mode 100644
index c6b9a67..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityCreateTestITCase.java
+++ /dev/null
@@ -1,52 +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.proxy.v4;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.fit.proxy.v4.staticservice.Service;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-
-public class AuthEntityCreateTestITCase extends EntityCreateTestITCase {
-
- private Service<EdmEnabledODataClient> ecf;
-
- private InMemoryEntities ime;
-
- @Override
- protected Service<EdmEnabledODataClient> getService() {
- if (ecf == null) {
- ecf = Service.getV4(testAuthServiceRootURL);
- ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- ecf.getClient().getConfiguration().
- setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
- }
- return ecf;
- }
-
- @Override
- protected InMemoryEntities getContainer() {
- if (ime == null) {
- ime = getService().getEntityContainer(InMemoryEntities.class);
- }
- return ime;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java
deleted file mode 100644
index 1a359bb..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java
+++ /dev/null
@@ -1,37 +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.proxy.v4;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.fit.proxy.v4.staticservice.Service;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-
-public class AuthEntityRetrieveTestITCase extends EntityRetrieveTestITCase {
-
- @Override
- protected InMemoryEntities getContainer() {
- final Service<EdmEnabledODataClient> ecf = Service.getV4(testAuthServiceRootURL);
- ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- ecf.getClient().getConfiguration().
- setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
- return ecf.getEntityContainer(InMemoryEntities.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java
deleted file mode 100644
index 6829d38..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/BoundOperationInvokeTestITCase.java
+++ /dev/null
@@ -1,119 +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.proxy.v4;
-
-// CHECKSTYLE:OFF (Maven checkstyle)
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.sql.Timestamp;
-import java.util.Calendar;
-
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfoComposableInvoker;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AddressCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductComposableInvoker;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollectionComposableInvoker;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailKey;
-import org.junit.Test;
-// CHECKSTYLE:ON (Maven checkstyle)
-
-public class BoundOperationInvokeTestITCase extends AbstractTestITCase {
-
- @Test
- public void getEmployeesCount() {
- assertNotNull(container.getCompany().load().operations().getEmployeesCount());
- }
-
- @Test
- public void getProductDetails() {
- final ProductDetailCollectionComposableInvoker result =
- container.getProducts().getByKey(5).operations().getProductDetails(1);
- assertEquals(1, result.execute().size());
- }
-
- @Test
- public void getRelatedProduct() {
- final ProductDetailKey key = new ProductDetailKey();
- key.setProductID(6);
- key.setProductDetailID(1);
-
- final ProductComposableInvoker product =
- container.getProductDetails().getByKey(key).operations().getRelatedProduct();
- assertEquals(6, product.execute().getProductID(), 0);
- }
-
- @Test
- public void getDefaultPI() {
- final PaymentInstrument pi = container.getAccounts().getByKey(101).operations().getDefaultPI().execute();
- assertEquals(101901, pi.getPaymentInstrumentID(), 0);
- }
-
- @Test
- public void getAccountInfo() {
- final AccountInfoComposableInvoker accountInfo =
- container.getAccounts().getByKey(101).operations().getAccountInfo();
- assertNotNull(accountInfo.execute());
- }
-
- @Test
- public void getActualAmount() {
- final Double amount =
- container.getAccounts().getByKey(101).getMyGiftCard().operations().getActualAmount(1.1).execute();
- assertEquals(41.79, amount, 0);
- }
-
- @Test
- public void increaseRevenue() {
- final Long result = container.getCompany().load().operations().increaseRevenue(12L).execute();
- assertNotNull(result);
- }
-
- @Test
- public void addAccessRight() {
- final AccessLevel accessLevel =
- container.getProducts().getByKey(5).operations().addAccessRight(AccessLevel.Execute).execute();
- assertNotNull(accessLevel);
- }
-
- @Test
- public void resetAddress() {
- final Address address = container.newComplexInstance(HomeAddress.class);
- address.setStreet("Via Le Mani Dal Naso, 123");
- address.setPostalCode("Tollo");
- address.setCity("66010");
-
- final AddressCollection ac = container.newComplexCollection(AddressCollection.class);
- ac.add(address);
-
- final Person person = container.getCustomers().getByKey(2).operations().resetAddress(ac, 0).execute();
- assertEquals(2, person.getPersonID(), 0);
- }
-
- @Test
- public void refreshDefaultPI() {
- final PaymentInstrument pi = container.getAccounts().getByKey(101).operations().
- refreshDefaultPI(new Timestamp(Calendar.getInstance().getTimeInMillis())).execute();
- assertEquals(101901, pi.getPaymentInstrumentID(), 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/ContextTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/ContextTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/ContextTestITCase.java
deleted file mode 100644
index 344492e..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/ContextTestITCase.java
+++ /dev/null
@@ -1,101 +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.proxy.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.TimeZone;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.ext.proxy.api.ODataFlushException;
-import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.Service;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
-import org.junit.Test;
-
-public class ContextTestITCase extends AbstractTestITCase {
-
- private void continueOnError(final Service<EdmEnabledODataClient> service, final InMemoryEntities container) {
- final Person person = container.newEntityInstance(Person.class);
- container.getPeople().add(person);
-
- final Employee employee = container.newEntityInstance(Employee.class);
- employee.setPersonID(199);
- employee.setFirstName("Fabio");
- employee.setLastName("Martelli");
-
- final PrimitiveCollection<String> emails = container.newPrimitiveCollection(String.class);
- emails.add("fabio.martelli@tirasa.net");
-
- employee.setEmails(emails);
- final Calendar date = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- date.clear();
- date.set(2011, 3, 4, 9, 0, 0);
- employee.setDateHired(new Timestamp(date.getTimeInMillis()));
- final Address homeAddress = container.newComplexInstance(Address.class);
- homeAddress.setCity("Pescara");
- homeAddress.setPostalCode("65100");
- homeAddress.setStreet("viale Gabriele D'Annunzio 256");
- employee.setHomeAddress(homeAddress);
-
- final PrimitiveCollection<String> numbers = container.newPrimitiveCollection(String.class);
- numbers.add("3204725072");
- numbers.add("08569930");
- employee.setNumbers(numbers);
-
- container.getPeople().add(employee);
-
- try {
- container.flush();
- fail();
- } catch (ODataFlushException e) {
- assertEquals(1, e.getErrors().size());
- assertEquals(0, e.getErrors().get(0).getIndex());
- assertNotNull(e.getErrors().get(0).getRequest());
- }
-
- service.getContext().detachAll();
- }
-
- @Test
- public void transactionalContinueOnError() {
- service.getClient().getConfiguration().setContinueOnError(true);
- continueOnError(service, container);
- service.getClient().getConfiguration().setContinueOnError(false);
- }
-
- @Test
- public void nonTransactionalContinueOnError() {
- final Service<EdmEnabledODataClient> _service = Service.getV4(testStaticServiceRootURL, false);
- _service.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- _service.getClient().getConfiguration().setContinueOnError(true);
-
- final InMemoryEntities _container = _service.getEntityContainer(InMemoryEntities.class);
-
- continueOnError(_service, _container);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/DerivedTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/DerivedTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/DerivedTypeTestITCase.java
deleted file mode 100644
index 2cccc68..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/DerivedTypeTestITCase.java
+++ /dev/null
@@ -1,94 +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.proxy.v4;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Calendar;
-
-// CHECKSTYLE:OFF (Maven checkstyle)
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyAddress;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CreditCardPI;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CreditCardPICollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CustomerCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
-
-// CHECKSTYLE:ON (Maven checkstyle)
-import org.junit.Test;
-
-public class DerivedTypeTestITCase extends AbstractTestITCase {
-
- @Test
- public void read() {
- final CustomerCollection customers = container.getPeople().execute(CustomerCollection.class);
- assertNotNull(customers);
-
- for (Object customer : customers) {
- assertTrue(customer instanceof Customer);
- }
-
- final CreditCardPICollection creditCards = container.getAccounts().getByKey(101).
- getMyPaymentInstruments().execute(CreditCardPICollection.class);
- assertNotNull(creditCards);
- for (Object creditCard : creditCards) {
- assertTrue(creditCard instanceof CreditCardPI);
- }
- }
-
- @Test
- public void createDelete() {
- final Customer customer = container.newEntityInstance(Customer.class);
- customer.setPersonID(976);
- customer.setFirstName("Test");
- customer.setLastName("Test");
-
- final Address homeAddress = container.newComplexInstance(CompanyAddress.class);
- homeAddress.setStreet("V.le Gabriele D'Annunzio");
- homeAddress.setCity("Pescara");
- homeAddress.setPostalCode("65127");
- customer.setHomeAddress(homeAddress);
-
- customer.setNumbers(container.newPrimitiveCollection(String.class)); // empty
- customer.setEmails(container.newPrimitiveCollection(String.class)); // empty
- customer.setCity("Pescara");
-
- final Calendar birthday = Calendar.getInstance();
- birthday.clear();
- birthday.set(1977, 8, 8);
- customer.setBirthday(new Timestamp(birthday.getTimeInMillis()));
-
- customer.setTimeBetweenLastTwoOrders(BigDecimal.valueOf(0.0000002));
-
- container.getPeople().add(customer);
- container.flush();
-
- final Person actual = container.getPeople().getByKey(976, Customer.class).load();
- assertTrue(actual instanceof Customer);
- assertTrue(actual.getHomeAddress() instanceof CompanyAddress);
-
- container.getPeople().delete(976);
-
- container.flush();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityCreateTestITCase.java
deleted file mode 100644
index d6149fa..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityCreateTestITCase.java
+++ /dev/null
@@ -1,380 +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.proxy.v4;
-
-// CHECKSTYLE:OFF (Maven checkstyle)
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.TimeZone;
-
-import org.apache.commons.lang3.RandomUtils;
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.ext.proxy.AbstractService;
-import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Color;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Order;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetail;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetailKey;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrumentCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Product;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetail;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductDetailCollection;
-import org.junit.Test;
-// CHECKSTYLE:ON (Maven checkstyle)
-
-/**
- * This is the unit test class to check entity create operations.
- */
-public class EntityCreateTestITCase extends AbstractTestITCase {
-
- protected AbstractService<EdmEnabledODataClient> getService() {
- return service;
- }
-
- protected InMemoryEntities getContainer() {
- return container;
- }
-
- @Test
- public void createAndDelete() {
- createPatchAndDeleteOrder(getContainer(), getService());
- }
-
- @Test
- public void createEmployee() {
- final Integer id = 101;
-
- final Employee employee = getContainer().newEntityInstance(Employee.class);
- employee.setPersonID(id);
- employee.setFirstName("Fabio");
- employee.setLastName("Martelli");
-
- PrimitiveCollection<String> value = getContainer().newPrimitiveCollection(String.class);
- value.add("fabio.martelli@tirasa.net");
- employee.setEmails(value);
-
- final Calendar date = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- date.clear();
- date.set(2011, 3, 4, 9, 0, 0);
- employee.setDateHired(new Timestamp(date.getTimeInMillis()));
- final Address homeAddress = getContainer().newComplexInstance(HomeAddress.class);
- homeAddress.setCity("Pescara");
- homeAddress.setPostalCode("65100");
- homeAddress.setStreet("viale Gabriele D'Annunzio 256");
- employee.setHomeAddress(homeAddress);
-
- value = getContainer().newPrimitiveCollection(String.class);
- value.add("3204725072");
- value.add("08569930");
- employee.setNumbers(value);
-
- getContainer().getPeople().add(employee);
-
- getContainer().flush();
-
- Employee actual = getContainer().getPeople().getByKey(id, Employee.class).load();
- assertNotNull(actual);
- assertEquals(id, actual.getPersonID());
- assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity());
-
- getService().getContext().detachAll();
- actual = getContainer().getPeople().getByKey(id, Employee.class).load();
- assertNotNull(actual);
- assertEquals(id, actual.getPersonID());
- assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity());
-
- getContainer().getPeople().delete(actual.getPersonID());
- getContainer().flush();
-
- try {
- getContainer().getPeople().getByKey(id, Employee.class).load();
- fail();
- } catch (IllegalArgumentException e) {
- // Expected
- }
-
- getService().getContext().detachAll();
- try {
- getContainer().getPeople().getByKey(id, Employee.class).load();
- fail();
- } catch (IllegalArgumentException e) {
- // Expected
- }
- }
-
- @Test
- public void createWithNavigation() {
- final Integer id = 101;
-
- final Customer customer = getContainer().newEntityInstance(Customer.class);
- customer.setPersonID(id);
- customer.setPersonID(id);
- customer.setFirstName("Fabio");
- customer.setLastName("Martelli");
- customer.setCity("Pescara");
-
- PrimitiveCollection<String> value = getContainer().newPrimitiveCollection(String.class);
- value.add("fabio.martelli@tirasa.net");
- customer.setEmails(value);
-
- Address homeAddress = getContainer().newComplexInstance(HomeAddress.class);
- homeAddress.setCity("Pescara");
- homeAddress.setPostalCode("65100");
- homeAddress.setStreet("viale Gabriele D'Annunzio 256");
- customer.setHomeAddress(homeAddress);
-
- value = getContainer().newPrimitiveCollection(String.class);
- value.add("3204725072");
- value.add("08569930");
- customer.setNumbers(value);
-
- final OrderCollection orders = getContainer().newEntityCollection(OrderCollection.class);
- orders.add(getContainer().getOrders().getByKey(8));
- customer.setOrders(orders);
-
- getContainer().getCustomers().add(customer);
- getContainer().flush();
-
- Customer actual = readCustomer(getContainer(), id);
- assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity());
- assertEquals(1, actual.getOrders().execute().size());
- assertEquals(8, actual.getOrders().iterator().next().getOrderID(), 0);
-
- getContainer().getCustomers().delete(actual.getPersonID());
- getContainer().flush();
-
- try {
- getContainer().getCustomers().getByKey(id).load();
- fail();
- } catch (IllegalArgumentException e) {
- // Expected
- }
- }
-
- @Test
- public void createWithBackNavigation() {
- final Integer id = 102;
-
- // -------------------------------
- // Create a new order
- // -------------------------------
- Order order = getContainer().newEntityInstance(Order.class);
- order.setOrderID(id);
-
- final Calendar orderDate = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- orderDate.clear();
- orderDate.set(2011, 3, 4, 16, 3, 57);
- order.setOrderDate(new Timestamp(orderDate.getTimeInMillis()));
-
- order.setShelfLife(BigDecimal.TEN);
-
- PrimitiveCollection<BigDecimal> osl = getContainer().newPrimitiveCollection(BigDecimal.class);
- osl.add(BigDecimal.TEN.negate());
- osl.add(BigDecimal.TEN);
- order.setOrderShelfLifes(osl);
- // -------------------------------
-
- // -------------------------------
- // Create a new customer
- // -------------------------------
- final Customer customer = getContainer().newEntityInstance(Customer.class);
- customer.setPersonID(id);
- customer.setPersonID(id);
- customer.setFirstName("Fabio");
- customer.setLastName("Martelli");
- customer.setCity("Pescara");
-
- PrimitiveCollection<String> value = getContainer().newPrimitiveCollection(String.class);
- value.add("fabio.martelli@tirasa.net");
- customer.setEmails(value);
-
- final Address homeAddress = getContainer().newComplexInstance(HomeAddress.class);
- homeAddress.setCity("Pescara");
- homeAddress.setPostalCode("65100");
- homeAddress.setStreet("viale Gabriele D'Annunzio 256");
- customer.setHomeAddress(homeAddress);
-
- value = getContainer().newPrimitiveCollection(String.class);
- value.add("3204725072");
- value.add("08569930");
- customer.setNumbers(value);
-
- final OrderCollection orders = getContainer().newEntityCollection(OrderCollection.class);
- orders.add(order);
- customer.setOrders(orders);
- // -------------------------------
-
- // -------------------------------
- // Link customer to order
- // -------------------------------
- order.setCustomerForOrder(customer);
- // -------------------------------
-
- getContainer().getOrders().add(order);
- getContainer().flush();
-
- assertEquals(id, order.getOrderID());
- assertEquals(id, customer.getPersonID());
-
- Customer actual = readCustomer(getContainer(), id);
- assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity());
- assertEquals(1, actual.getOrders().execute().size());
- assertEquals(id, actual.getOrders().iterator().next().getOrderID());
-
- order = getContainer().getOrders().getByKey(id);
- assertNotNull(order);
- assertEquals(id, order.getCustomerForOrder().load().getPersonID());
-
- getContainer().getOrders().delete(actual.getOrders());
- getContainer().flush();
-
- try {
- getContainer().getOrders().getByKey(id).load();
- fail();
- } catch (IllegalArgumentException e) {
- // Expected
- }
-
- actual = readCustomer(getContainer(), id);
- assertTrue(actual.getOrders().isEmpty());
-
- getContainer().getCustomers().delete(actual.getPersonID());
- getContainer().flush();
-
- try {
- getContainer().getCustomers().getByKey(id).load();
- fail();
- } catch (IllegalArgumentException e) {
- // Expected
- }
- }
-
- @Test
- public void multiKey() {
- OrderDetail details = getContainer().newEntityInstance(OrderDetail.class);
- details.setOrderID(8);
- details.setProductID(1);
- details.setQuantity(100);
- details.setUnitPrice(5f);
-
- getContainer().getOrderDetails().add(details);
- getContainer().flush();
-
- OrderDetailKey key = new OrderDetailKey();
- key.setOrderID(8);
- key.setProductID(1);
-
- details = getContainer().getOrderDetails().getByKey(key).load();
- assertNotNull(details);
- assertEquals(Integer.valueOf(100), details.getQuantity());
- assertEquals(8, details.getOrderID(), 0);
- assertEquals(1, details.getProductID(), 0);
- assertEquals(5f, details.getUnitPrice(), 0);
-
- getContainer().getOrderDetails().delete(key);
- getContainer().flush();
-
- try {
- getContainer().getOrderDetails().getByKey(key).load();
- fail();
- } catch (IllegalArgumentException e) {
- // Expected
- }
- }
-
- @Test
- public void deepInsert() {
- Product product = getContainer().newEntityInstance(Product.class);
- product.setProductID(12);
- product.setName("Latte");
- product.setQuantityPerUnit("100g Bag");
- product.setUnitPrice(3.24f);
- product.setQuantityInStock(100);
- product.setDiscontinued(false);
- product.setUserAccess(AccessLevel.Execute);
- product.setSkinColor(Color.Blue);
-
- PrimitiveCollection<Color> value = getContainer().newPrimitiveCollection(Color.class);
- value.add(Color.Red);
- value.add(Color.Green);
- product.setCoverColors(value);
-
- final ProductDetail detail = getContainer().newEntityInstance(ProductDetail.class);
- detail.setProductID(product.getProductID());
- detail.setProductDetailID(12);
- detail.setProductName("LatteHQ");
- detail.setDescription("High-Quality Milk");
-
- final ProductDetailCollection detailCollection = getContainer().newEntityCollection(ProductDetailCollection.class);
- detailCollection.add(detail);
-
- product.setDetails(detailCollection);
-
- getContainer().getProducts().add(product);
- getContainer().flush();
-
- product = getContainer().getProducts().getByKey(12).load();
- assertEquals("Latte", product.getName());
- assertEquals(12, product.getDetails().execute().iterator().next().getProductDetailID(), 0);
- }
-
- @Test
- public void contained() {
- PaymentInstrumentCollection instruments =
- getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().execute();
- final int sizeBefore = instruments.size();
-
- final PaymentInstrument instrument = getContainer().newEntityInstance(PaymentInstrument.class);
- instruments.add(instrument);
-
- final int id = RandomUtils.nextInt(101999, 105000);
- instrument.setPaymentInstrumentID(id);
- instrument.setFriendlyName("New one");
- instrument.setCreatedDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));
-
- getContainer().flush();
-
- instruments = getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().execute();
- final int sizeAfter = instruments.size();
- assertEquals(sizeBefore + 1, sizeAfter);
-
- getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().delete(id);
-
- getContainer().flush();
-
- instruments = getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().execute();
- final int sizeEnd = instruments.size();
- assertEquals(sizeBefore, sizeEnd);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityRetrieveTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityRetrieveTestITCase.java
deleted file mode 100644
index 7ee31b8..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityRetrieveTestITCase.java
+++ /dev/null
@@ -1,173 +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.proxy.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Proxy;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.TimeZone;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
-// CHECKSTYLE:OFF (Maven checkstyle)
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CustomerCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.EmployeeCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Order;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetail;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetailKey;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Product;
-
-// CHECKSTYLE:ON (Maven checkstyle)
-import org.junit.Test;
-
-/**
- * This is the unit test class to check entity retrieve operations.
- */
-public class EntityRetrieveTestITCase extends AbstractTestITCase {
-
- protected InMemoryEntities getContainer() {
- return container;
- }
-
- @Test
- public void exists() {
- assertTrue(getContainer().getCustomers().exists(1));
- assertFalse(getContainer().getOrders().exists(1));
- }
-
- @Test
- public void get() {
- readCustomer(getContainer(), 1);
- }
-
- @Test
- public void getAll() {
- final PersonCollection all = getContainer().getPeople().execute();
- assertNotNull(all);
- assertFalse(all.isEmpty());
- for (Person person : all) {
- assertNotNull(person);
- }
-
- final EmployeeCollection employees = getContainer().getPeople().execute(EmployeeCollection.class);
- assertNotNull(employees);
- assertFalse(employees.isEmpty());
- for (Employee employee : employees) {
- assertNotNull(employee);
- }
-
- final CustomerCollection customers = getContainer().getPeople().execute(CustomerCollection.class);
- assertNotNull(customers);
- assertFalse(customers.isEmpty());
- for (Customer customer : customers) {
- assertNotNull(customer);
- }
-
- assertTrue(all.size() > employees.size() + customers.size());
- }
-
- @Test
- public void navigate() {
- final Order order = getContainer().getOrders().getByKey(8).load();
- assertEquals(8, order.getOrderID(), 0);
-
- final Timestamp date = order.getOrderDate();
- assertNotNull(date);
- final Calendar actual = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- actual.clear();
- actual.set(2011, 2, 4, 16, 3, 57);
- assertEquals(actual.getTimeInMillis(), date.getTime());
-
- final Customer customer = getContainer().getCustomers().getByKey(1).load();
- assertNotNull(customer);
- assertEquals(1, customer.getPersonID(), 0);
- final Address address = customer.getHomeAddress();
- assertNotNull(address);
- assertEquals("98052", address.getPostalCode());
- }
-
- @Test
- public void withInlineEntry() {
- final Customer customer = readCustomer(getContainer(), 1);
- final Company company = customer.getCompany();
- assertEquals(0, company.load().getCompanyID(), 0);
- }
-
- @Test
- public void withInlineFeed() {
- final Customer customer = readCustomer(getContainer(), 1);
- final OrderCollection orders = customer.getOrders();
- assertEquals(1, orders.execute().size());
- assertEquals(8, orders.iterator().next().getOrderID(), 0);
- }
-
- @Test
- public void withActions() {
- final Product product = getContainer().getProducts().getByKey(5).load();
- assertEquals(5, product.getProductID(), 0);
-
- try {
- assertNotNull(product.operations().getClass().getMethod("addAccessRight", AccessLevel.class));
- } catch (Exception e) {
- fail();
- }
- }
-
- @Test
- public void multiKey() {
- final OrderDetailKey orderDetailKey = new OrderDetailKey();
- orderDetailKey.setOrderID(7);
- orderDetailKey.setProductID(5);
-
- final OrderDetail orderDetail = getContainer().getOrderDetails().getByKey(orderDetailKey).load();
- assertNotNull(orderDetail);
- assertEquals(7, orderDetail.getOrderID(), 0);
- assertEquals(5, orderDetail.getProductID(), 0);
- }
-
- @Test
- public void checkForETag() {
- final Order order = getContainer().getOrders().getByKey(8).load();
- assertTrue(StringUtils.isNotBlank(((EntityInvocationHandler) Proxy.getInvocationHandler(order)).getETag()));
- }
-
- @Test
- public void contained() {
- final PaymentInstrument instrument =
- getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().getByKey(101901).load();
- assertEquals(101901, instrument.getPaymentInstrumentID(), 0);
- assertNotNull(instrument.getCreatedDate());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntitySetTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntitySetTestITCase.java
deleted file mode 100644
index 37c2d0c..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntitySetTestITCase.java
+++ /dev/null
@@ -1,75 +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.proxy.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
-import org.junit.Test;
-
-/**
- * This is the unit test class to check basic feed operations.
- */
-public class EntitySetTestITCase extends AbstractTestITCase {
-
- @Test
- public void count() {
- assertNotNull(container.getOrders());
- assertEquals(2, container.getOrders().count().longValue());
- }
-
- @Test
- public void getAll() {
- int count = 0;
- for (Customer customer : container.getCustomers().execute()) {
- assertNotNull(customer);
- count++;
- }
- assertEquals(2, count);
- }
-
- @Test
- public void iterator() {
- int count = 0;
- for (Customer customer : container.getCustomers()) {
- assertNotNull(customer);
- count++;
- }
- assertEquals(2, count);
- }
-
- @Test
- public void readEntitySetWithNextLink() {
- int count = 0;
- for (Person people : container.getPeople().execute()) {
- assertNotNull(people);
- count++;
- }
- assertEquals(5, count);
-
- int iterating = 0;
- for (Person person : container.getPeople()) {
- assertNotNull(person);
- iterating++;
- }
- assertEquals(count + 1, iterating);
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityUpdateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityUpdateTestITCase.java
deleted file mode 100644
index ab3f075..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityUpdateTestITCase.java
+++ /dev/null
@@ -1,193 +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.proxy.v4;
-
-// CHECKSTYLE:OFF (Maven checkstyle)
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-
-import java.lang.reflect.Proxy;
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.UUID;
-
-import org.apache.commons.lang3.RandomUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.ext.proxy.AbstractService;
-import org.apache.olingo.ext.proxy.commons.EntityInvocationHandler;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyAddress;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Order;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetail;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.OrderDetailKey;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
-import org.junit.Test;
-
-// CHECKSTYLE:ON (Maven checkstyle)
-/**
- * This is the unit test class to check entity update operations.
- */
-public class EntityUpdateTestITCase extends AbstractTestITCase {
-
- protected AbstractService<EdmEnabledODataClient> getService() {
- return service;
- }
-
- protected InMemoryEntities getContainer() {
- return container;
- }
-
- @Test
- public void update() {
- Person person = getContainer().getPeople().getByKey(1);
-
- final Address address = person.getHomeAddress();
- address.setCity("XXX");
-
- getContainer().flush();
-
- person = getContainer().getPeople().getByKey(1).load();
- assertEquals("XXX", person.getHomeAddress().getCity());
- }
-
- @Test
- public void multiKey() {
- final OrderDetailKey orderDetailKey = new OrderDetailKey();
- orderDetailKey.setOrderID(7);
- orderDetailKey.setProductID(5);
-
- OrderDetail orderDetail = getContainer().getOrderDetails().getByKey(orderDetailKey).load();
- assertNotNull(orderDetail);
- assertEquals(7, orderDetail.getOrderID(), 0);
- assertEquals(5, orderDetail.getProductID(), 0);
-
- orderDetail.setQuantity(5);
-
- getContainer().flush();
-
- orderDetail = getContainer().getOrderDetails().getByKey(orderDetailKey).load();
- assertEquals(5, orderDetail.getQuantity(), 0);
- }
-
- @Test
- public void patchLink() {
- // 1. create customer
- Customer customer = getContainer().newEntityInstance(Customer.class);
- customer.setPersonID(977);
- customer.setFirstName("Test");
- customer.setLastName("Test");
-
- final Address homeAddress = getContainer().newComplexInstance(CompanyAddress.class);
- homeAddress.setStreet("V.le Gabriele D'Annunzio");
- homeAddress.setCity("Pescara");
- homeAddress.setPostalCode("65127");
- customer.setHomeAddress(homeAddress);
-
- customer.setNumbers(getContainer().newPrimitiveCollection(String.class)); // empty
- customer.setEmails(getContainer().newPrimitiveCollection(String.class)); // empty
- customer.setCity("Pescara");
-
- final Calendar birthday = Calendar.getInstance();
- birthday.clear();
- birthday.set(1977, 8, 8);
- customer.setBirthday(new Timestamp(birthday.getTimeInMillis()));
-
- customer.setTimeBetweenLastTwoOrders(BigDecimal.valueOf(0.0000002));
-
- // 2. create order and set it to customer
- final int orderId = RandomUtils.nextInt(400, 410);
-
- Order order = getContainer().newEntityInstance(Order.class);
- order.setOrderID(orderId);
-
- final OrderCollection orders = getContainer().newEntityCollection(OrderCollection.class);
- orders.add(order);
-
- customer.setOrders(orders);
- order.setCustomerForOrder(customer);
-
- getContainer().getCustomers().add(customer);
- getContainer().flush();
-
- assertEquals(977, order.getCustomerForOrder().load().getPersonID(), 0);
- // order.getCustomerForOrder().load() caches Customer ... test server doesn't support something like the following
- // <service>/Orders(400)/CustomerForOrder/Orders
- // detach all and check for stored data ..
- getService().getContext().detachAll();
-
- // 3. check everything after flush
- order = getContainer().getOrders().getByKey(orderId).load();
- assertEquals(orderId, order.getOrderID(), 0);
-
- customer = getContainer().getCustomers().getByKey(977);
-
- // assertEquals(1, customer.getOrders().size());
-
- int count = 0;
- for (Order inside : customer.getOrders().execute()) {
- if (inside.getOrderID() == orderId) {
- count++;
- }
- }
- assertEquals(1, count);
- assertEquals(977, order.getCustomerForOrder().load().getPersonID(), 0);
-
- // 4. delete customer and order
- getContainer().getCustomers().delete(977);
- getContainer().getOrders().delete(orderId);
-
- getContainer().flush();
- }
-
- @Test
- public void concurrentModification() {
- Order order = getContainer().getOrders().getByKey(8).load();
- final String etag = ((EntityInvocationHandler) Proxy.getInvocationHandler(order)).getETag();
- assertTrue(StringUtils.isNotBlank(etag));
-
- order.setShelfLife(BigDecimal.TEN);
-
- getContainer().flush();
-
- order = getContainer().getOrders().getByKey(8).load();
- assertEquals(BigDecimal.TEN, order.getShelfLife());
- }
-
- @Test
- public void contained() {
- PaymentInstrument instrument =
- getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().getByKey(101901);
-
- final String newName = UUID.randomUUID().toString();
- instrument.setFriendlyName(newName);
-
- getContainer().flush();
-
- instrument = getContainer().getAccounts().getByKey(101).getMyPaymentInstruments().getByKey(101901).load();
- assertEquals(newName, instrument.getFriendlyName());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java
deleted file mode 100644
index 72e3643..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/FilterTestITCase.java
+++ /dev/null
@@ -1,101 +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.proxy.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.olingo.ext.proxy.api.Search;
-import org.apache.olingo.ext.proxy.api.Sort;
-// CHECKSTYLE:OFF (Maven checkstyle)
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.People;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Employee;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.EmployeeCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonCollection;
-import org.junit.Test;
-
-// CHECKSTYLE:ON (Maven checkstyle)
-
-public class FilterTestITCase extends AbstractTestITCase {
-
- @Test
- public void testFilterWithEntityType() {
- final People people = container.getPeople();
- final EmployeeCollection response = people.filter(service.getClient().getFilterFactory().lt("PersonID", 4))
- .execute(EmployeeCollection.class);
-
- assertEquals(1, response.size());
-
- for (final Employee employee : response) {
- assertEquals(Integer.valueOf(3), employee.getPersonID());
- }
- }
-
- @Test
- public void filterOrderby() {
- final People people = container.getPeople();
-
- PersonCollection result =
- people.filter(service.getClient().getFilterFactory().lt("PersonID", 3)).execute();
-
- // 1. check that result looks as expected
- assertEquals(2, result.size());
-
- // 2. extract PersonID values - sorted ASC by default
- final List<Integer> former = new ArrayList<Integer>(2);
- for (Person person : result) {
- final Integer personID = person.getPersonID();
- assertTrue(personID < 3);
- former.add(personID);
- }
-
- // 3. add orderby clause to filter above
- result = people.orderBy(new Sort("PersonID", Sort.Direction.DESC)).execute();
- assertEquals(2, result.size());
-
- // 4. extract again VIN value - now they were required to be sorted DESC
- final List<Integer> latter = new ArrayList<Integer>(2);
- for (Person person : result) {
- final Integer personID = person.getPersonID();
- assertTrue(personID < 3);
- latter.add(personID);
- }
-
- // 5. reverse latter and expect to be equal to former
- Collections.reverse(latter);
- assertEquals(former, latter);
- }
-
- @Test
- public void search() {
- final Search<Person, PersonCollection> search = container.getPeople().createSearch().setSearch(
- service.getClient().getSearchFactory().or(
- service.getClient().getSearchFactory().literal("Bob"),
- service.getClient().getSearchFactory().literal("Jill")));
-
- final PersonCollection result = search.getResult();
- assertFalse(result.isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/KeyAsSegmentTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/KeyAsSegmentTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/KeyAsSegmentTestITCase.java
deleted file mode 100644
index ac450de..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/KeyAsSegmentTestITCase.java
+++ /dev/null
@@ -1,73 +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.proxy.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.fit.proxy.v4.staticservice.Service;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person;
-import org.junit.Test;
-
-public class KeyAsSegmentTestITCase extends AbstractTestITCase {
-
- private Service<EdmEnabledODataClient> ecf;
-
- private InMemoryEntities ime;
-
- protected Service<EdmEnabledODataClient> getService() {
- if (ecf == null) {
- ecf = Service.getV4(testKeyAsSegmentServiceRootURL);
- ecf.getClient().getConfiguration().setKeyAsSegment(true);
- ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- }
- return ecf;
- }
-
- protected InMemoryEntities getContainer() {
- if (ime == null) {
- ime = getService().getEntityContainer(InMemoryEntities.class);
- }
- return ime;
- }
-
- @Test
- public void read() {
- assertNotNull(getContainer().getAccounts().getByKey(101));
- }
-
- @Test
- public void createAndDelete() {
- createPatchAndDeleteOrder(getContainer(), getService());
- }
-
- @Test
- public void update() {
- Person person = getContainer().getPeople().getByKey(5);
- person.setMiddleName("middleN");
-
- container.flush();
-
- person = getContainer().getPeople().getByKey(5);
- assertEquals("middleN", person.getMiddleName());
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/MediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/MediaEntityTestITCase.java
deleted file mode 100644
index 752fba5..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/MediaEntityTestITCase.java
+++ /dev/null
@@ -1,121 +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.proxy.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.UUID;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.ext.proxy.api.EdmStreamValue;
-import org.apache.olingo.fit.proxy.v4.demo.Service;
-import org.apache.olingo.fit.proxy.v4.demo.odatademo.DemoService;
-import org.apache.olingo.fit.proxy.v4.demo.odatademo.types.Advertisement;
-import org.junit.Test;
-
-/**
- * This is the unit test class to check media entity retrieve operations.
- */
-public class MediaEntityTestITCase extends AbstractTestITCase {
-
- private Service<EdmEnabledODataClient> ecf;
-
- private DemoService ime;
-
- protected Service<EdmEnabledODataClient> getService() {
- if (ecf == null) {
- ecf = Service.getV4(testDemoServiceRootURL);
- ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- }
- return ecf;
- }
-
- protected DemoService getContainer() {
- if (ime == null) {
- ime = getService().getEntityContainer(DemoService.class);
- }
- return ime;
- }
-
- @Test
- public void read() throws IOException {
- final UUID uuid = UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7");
-
- final Advertisement adv = getContainer().getAdvertisements().getByKey(uuid);
- assertNull(adv.getAirDate()); // No HTTP request --> property null
-
- final EdmStreamValue res = adv.loadStream();
- assertEquals("application/octet-stream", res.getContentType());
- assertNotNull(res.getStream());
- IOUtils.closeQuietly(res.getStream());
-
- getService().getContext().detachAll();
- }
-
- @Test
- public void update() throws IOException {
- final UUID uuid = UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7");
- final Advertisement adv = getContainer().getAdvertisements().getByKey(uuid);
- final String random = RandomStringUtils.random(124, "abcdefghijklmnopqrstuvwxyz");
- adv.uploadStream(getContainer().newEdmStreamValue("application/octet-stream", IOUtils.toInputStream(random)));
- getContainer().flush();
- assertEquals(random,
- IOUtils.toString(getContainer().getAdvertisements().getByKey(uuid).loadStream().getStream()));
- getService().getContext().detachAll();
- }
-
- @Test
- public void create() throws IOException {
- final String random = RandomStringUtils.random(124, "abcdefghijklmnopqrstuvwxyz");
-
- final Advertisement adv = getContainer().newEntityInstance(Advertisement.class);
- adv.uploadStream(getContainer().newEdmStreamValue("application/octet-stream", IOUtils.toInputStream(random)));
- adv.setAirDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));
-
- getContainer().getAdvertisements().add(adv);
- getContainer().flush();
-
- final UUID uuid = adv.getID();
- getService().getContext().detachAll();
-
- assertEquals(random, IOUtils.toString(getContainer().getAdvertisements().getByKey(uuid).loadStream().getStream()));
-
- getService().getContext().detachAll();
-
- getContainer().getAdvertisements().delete(uuid);
- getContainer().flush();
-
- try {
- getContainer().getAdvertisements().getByKey(uuid).load();
- fail();
- } catch (IllegalArgumentException e) {
- // expected
- }
- getService().getContext().detachAll();
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalAuthEntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalAuthEntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalAuthEntityCreateTestITCase.java
deleted file mode 100644
index c96df84..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalAuthEntityCreateTestITCase.java
+++ /dev/null
@@ -1,51 +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.proxy.v4;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.fit.proxy.v4.staticservice.Service;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-
-public class NonTransactionalAuthEntityCreateTestITCase extends EntityCreateTestITCase {
-
- private Service<EdmEnabledODataClient> ecf;
-
- private InMemoryEntities ime;
-
- @Override
- protected Service<EdmEnabledODataClient> getService() {
- if (ecf == null) {
- ecf = Service.getV4(testAuthServiceRootURL, false);
- ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- ecf.getClient().getConfiguration().
- setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
- }
- return ecf;
- }
-
- @Override
- protected InMemoryEntities getContainer() {
- if (ime == null) {
- ime = getService().getEntityContainer(InMemoryEntities.class);
- }
- return ime;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalEntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalEntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalEntityCreateTestITCase.java
deleted file mode 100644
index 3a91b4c..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalEntityCreateTestITCase.java
+++ /dev/null
@@ -1,49 +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.proxy.v4;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.fit.proxy.v4.staticservice.Service;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-
-public class NonTransactionalEntityCreateTestITCase extends EntityCreateTestITCase {
-
- private Service<EdmEnabledODataClient> ecf;
-
- private InMemoryEntities ime;
-
- @Override
- protected Service<EdmEnabledODataClient> getService() {
- if (ecf == null) {
- ecf = Service.getV4(testStaticServiceRootURL, false);
- ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- }
- return ecf;
- }
-
- @Override
- protected InMemoryEntities getContainer() {
- if (ime == null) {
- ime = getService().getEntityContainer(InMemoryEntities.class);
- }
- return ime;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalEntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalEntityUpdateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalEntityUpdateTestITCase.java
deleted file mode 100644
index cee126b..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalEntityUpdateTestITCase.java
+++ /dev/null
@@ -1,48 +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.proxy.v4;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.fit.proxy.v4.staticservice.Service;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities;
-
-public class NonTransactionalEntityUpdateTestITCase extends EntityUpdateTestITCase {
-
- private Service<EdmEnabledODataClient> ecf;
-
- private InMemoryEntities ime;
-
- @Override
- protected Service<EdmEnabledODataClient> getService() {
- if (ecf == null) {
- ecf = Service.getV4(testStaticServiceRootURL, false);
- ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- }
- return ecf;
- }
-
- @Override
- protected InMemoryEntities getContainer() {
- if (ime == null) {
- ime = getService().getEntityContainer(InMemoryEntities.class);
- }
- return ime;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalMediaEntityTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalMediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalMediaEntityTestITCase.java
deleted file mode 100644
index df7fee8..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/NonTransactionalMediaEntityTestITCase.java
+++ /dev/null
@@ -1,49 +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.proxy.v4;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.fit.proxy.v4.demo.Service;
-import org.apache.olingo.fit.proxy.v4.demo.odatademo.DemoService;
-
-public class NonTransactionalMediaEntityTestITCase extends MediaEntityTestITCase {
-
- private Service<EdmEnabledODataClient> ecf;
-
- private DemoService ime;
-
- @Override
- protected Service<EdmEnabledODataClient> getService() {
- if (ecf == null) {
- ecf = Service.getV4(testDemoServiceRootURL, false);
- ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- }
- return ecf;
- }
-
- @Override
- protected DemoService getContainer() {
- if (ime == null) {
- ime = getService().getEntityContainer(DemoService.class);
- }
- return ime;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java
deleted file mode 100644
index 0defe4d..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java
+++ /dev/null
@@ -1,156 +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.proxy.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.UUID;
-
-import org.apache.olingo.client.api.EdmEnabledODataClient;
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.ext.proxy.api.annotations.EntityType;
-import org.apache.olingo.fit.proxy.v4.opentype.Service;
-import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.DefaultContainer;
-import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.AccountInfo;
-import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Color;
-import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.ContactDetails;
-import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.IndexedRow;
-import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row;
-import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.RowIndex;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class OpenTypeTestITCase extends AbstractTestITCase {
-
- private static Service<EdmEnabledODataClient> otservice;
-
- private static DefaultContainer otcontainer;
-
- @BeforeClass
- public static void initContainer() {
- otservice = Service.getV4(testOpenTypeServiceRootURL);
- otservice.getClient().getConfiguration().
- setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
- otcontainer = otservice.getEntityContainer(DefaultContainer.class);
- assertNotNull(otcontainer);
- }
-
- @Test
- public void checkOpenTypeEntityTypesExist() {
- assertTrue(otcontainer.newEntityInstance(Row.class).getClass().getInterfaces()[0].
- getAnnotation(EntityType.class).openType());
- assertTrue(otcontainer.newEntityInstance(RowIndex.class).getClass().getInterfaces()[0].
- getAnnotation(EntityType.class).openType());
- assertTrue(otcontainer.newEntityInstance(IndexedRow.class).getClass().getInterfaces()[0].
- getAnnotation(EntityType.class).openType());
- otservice.getContext().detachAll();
- }
-
- @Test
- public void read() {
- Row row = otcontainer.getRow().getByKey(UUID.fromString("71f7d0dc-ede4-45eb-b421-555a2aa1e58f")).load();
- assertEquals(Double.class, row.readAdditionalProperty("Double").getClass());
- assertEquals("71f7d0dc-ede4-45eb-b421-555a2aa1e58f", row.getId().toString());
-
- row = otcontainer.getRow().getByKey(UUID.fromString("672b8250-1e6e-4785-80cf-b94b572e42b3")).load();
- assertEquals(BigDecimal.class, row.readAdditionalProperty("Decimal").getClass());
- }
-
- @Test
- public void cud() throws ParseException {
- final Integer id = 1426;
-
- RowIndex rowIndex = otcontainer.newEntityInstance(RowIndex.class);
- rowIndex.setId(id);
- rowIndex.addAdditionalProperty("aString", "string");
- rowIndex.addAdditionalProperty("aBoolean", true);
- rowIndex.addAdditionalProperty("aDouble", 1.5D);
- rowIndex.addAdditionalProperty("aByte", Byte.MAX_VALUE);
- rowIndex.addAdditionalProperty("aDate", Calendar.getInstance());
-
- final ContactDetails contact = otcontainer.newComplexInstance(ContactDetails.class);
- contact.setFirstContacted("text".getBytes());
-
- Calendar cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2001-04-05T05:05:05.001"));
-
- contact.setLastContacted(new Timestamp(cal.getTimeInMillis()));
-
- cal = Calendar.getInstance();
- cal.clear();
- cal.setTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2001-04-05T05:05:04.001"));
- contact.setContacted(cal);
-
- contact.setGUID(UUID.randomUUID());
- contact.setPreferedContactTime(cal);
- contact.setByte(Short.valueOf("24"));
- contact.setSignedByte(Byte.MAX_VALUE);
- contact.setDouble(Double.valueOf(Double.MAX_VALUE));
- contact.setSingle(Float.MAX_VALUE);
- contact.setShort(Short.MAX_VALUE);
- contact.setInt(Integer.MAX_VALUE);
- rowIndex.addAdditionalProperty("aContact", contact);
- rowIndex.addAdditionalProperty("aColor", Color.Green);
-
- final AccountInfo ai = otcontainer.newComplexInstance(AccountInfo.class);
- ai.setFirstName("Fabio");
- ai.setLastName("Martelli");
- ai.addAdditionalProperty("email", "fabio.martelli@tirasa.net");
- rowIndex.addAdditionalProperty("info", ai);
-
- otcontainer.getRowIndex().add(rowIndex);
- otcontainer.flush();
-
- rowIndex = otcontainer.getRowIndex().getByKey(id).load();
- assertEquals(String.class, rowIndex.readAdditionalProperty("aString").getClass());
- assertEquals(Boolean.class, rowIndex.readAdditionalProperty("aBoolean").getClass());
- assertEquals(Double.class, rowIndex.readAdditionalProperty("aDouble").getClass());
- assertEquals(Byte.class, rowIndex.readAdditionalProperty("aByte").getClass());
- assertEquals(Byte.MAX_VALUE, rowIndex.readAdditionalProperty("aByte"));
- assertTrue(Calendar.class.isAssignableFrom(rowIndex.readAdditionalProperty("aDate").getClass()));
- assertEquals(ContactDetails.class, rowIndex.readAdditionalProperty("aContact").getClass().getInterfaces()[0]);
- assertEquals(Color.class, rowIndex.readAdditionalProperty("aColor").getClass());
- assertEquals(Color.Green, rowIndex.readAdditionalProperty("aColor"));
- assertEquals("Fabio", AccountInfo.class.cast(rowIndex.readAdditionalProperty("info")).getFirstName());
- assertEquals("Martelli", AccountInfo.class.cast(rowIndex.readAdditionalProperty("info")).getLastName());
- assertEquals("fabio.martelli@tirasa.net", AccountInfo.class.cast(rowIndex.readAdditionalProperty("info")).
- readAdditionalProperty("email"));
-
- otservice.getContext().detachAll();
-
- otcontainer.getRowIndex().delete(id);
- otcontainer.flush();
-
- try {
- otcontainer.getRowIndex().getByKey(id).load();
- fail();
- } catch (IllegalArgumentException e) {
- // Expected
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/78a9539e/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OperationImportInvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OperationImportInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OperationImportInvokeTestITCase.java
deleted file mode 100644
index 723d31c..0000000
--- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OperationImportInvokeTestITCase.java
+++ /dev/null
@@ -1,104 +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.proxy.v4;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Color;
-// CHECKSTYLE:OFF (Maven checkstyle)
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.HomeAddress;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PersonComposableInvoker;
-import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.ProductCollectionComposableInvoker;
-// CHECKSTYLE:ON (Maven checkstyle)
-import org.junit.Test;
-
-public class OperationImportInvokeTestITCase extends AbstractTestITCase {
-
- @Test
- public void getDefaultColor() {
- final Color color = container.operations().getDefaultColor().execute();
- assertEquals(Color.Red, color);
- }
-
- @Test
- public void getPerson2() {
- final PersonComposableInvoker person = container.operations().getPerson2("London");
- assertEquals(1, person.execute().getPersonID(), 0);
- }
-
- @Test
- public void getPerson() {
- final Address address = container.newComplexInstance(HomeAddress.class);
- address.setStreet("1 Microsoft Way");
- address.setPostalCode("98052");
- address.setCity("London");
-
- final PersonComposableInvoker person = container.operations().getPerson(address);
- assertEquals(1, person.execute().getPersonID(), 0);
- }
-
- @Test
- public void getAllProducts() {
- final ProductCollectionComposableInvoker products = container.operations().getAllProducts();
- assertEquals(5, products.execute().size());
- }
-
- @Test
- public void getProductsByAccessLevel() {
- final PrimitiveCollection<String> products =
- container.operations().getProductsByAccessLevel(AccessLevel.None).execute();
- assertEquals(5, products.size());
- assertTrue(products.contains("Car"));
- }
-
- @Test
- public void discount() {
- container.operations().discount(22).execute();
- }
-
- @Test
- public void resetBossAddress() {
- final Address address = container.newComplexInstance(HomeAddress.class);
- address.setStreet("Via Le Mani Dal Naso, 123");
- address.setPostalCode("Tollo");
- address.setCity("66010");
-
- final Address actual = container.operations().resetBossAddress(address).execute();
- assertEquals(address.getStreet(), actual.getStreet());
- assertEquals(address.getPostalCode(), actual.getPostalCode());
- assertEquals(address.getCity(), actual.getCity());
- }
-
- @Test
- public void bossEmails() {
- PrimitiveCollection<String> be = container.newPrimitiveCollection(String.class);
- be.add("first@olingo.apache.org");
- be.add("second@olingo.apache.org");
-
- final PrimitiveCollection<String> result = container.operations().resetBossEmail(be).execute();
- assertEquals(2, result.size());
-
- final PrimitiveCollection<String> result2 = container.operations().getBossEmails(0, 100).execute();
- assertEquals(result, result2);
- }
-}