[OLINGO-1004] Delete duplicate Entity Tests Duplicated in BasicITCase and BindingITCase
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/19717f09 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/19717f09 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/19717f09 Branch: refs/heads/master Commit: 19717f09921098f50e35274573a688cda4dd5d30 Parents: 0e5b2ef Author: Christian Amend <[email protected]> Authored: Fri Aug 12 13:04:51 2016 +0200 Committer: Christian Amend <[email protected]> Committed: Fri Aug 12 13:04:51 2016 +0200 ---------------------------------------------------------------------- .../olingo/fit/base/EntityUpdateTestITCase.java | 117 ------------------- 1 file changed, 117 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/19717f09/fit/src/test/java/org/apache/olingo/fit/base/EntityUpdateTestITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/base/EntityUpdateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/EntityUpdateTestITCase.java index d1abb08..4872b27 100644 --- a/fit/src/test/java/org/apache/olingo/fit/base/EntityUpdateTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/base/EntityUpdateTestITCase.java @@ -21,98 +21,19 @@ package org.apache.olingo.fit.base; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import java.math.BigDecimal; import java.net.URI; -import java.util.Calendar; -import java.util.TimeZone; import java.util.UUID; import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest; -import org.apache.olingo.client.api.communication.request.cud.ODataReferenceAddingRequest; import org.apache.olingo.client.api.communication.request.cud.UpdateType; import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse; -import org.apache.olingo.client.api.communication.response.ODataReferenceAddingResponse; import org.apache.olingo.client.api.domain.ClientEntity; -import org.apache.olingo.client.api.domain.ClientLink; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.format.ContentType; -import org.junit.Ignore; import org.junit.Test; public class EntityUpdateTestITCase extends AbstractTestITCase { - private void upsert(final UpdateType updateType, final ContentType contentType) { - final ClientEntity order = getClient().getObjectFactory(). - newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Order")); - - order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("OrderID", - getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(9))); - order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("OrderDate", - getClient().getObjectFactory().newPrimitiveValueBuilder() - .setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue( - Calendar.getInstance(TimeZone.getTimeZone("GMT"))).build())); - order.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ShelfLife", - getClient().getObjectFactory().newPrimitiveValueBuilder(). - setType(EdmPrimitiveTypeKind.Duration).setValue(new BigDecimal("0.0000002")).build())); - - final URI upsertURI = getClient().newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Orders").appendKeySegment(9).build(); - final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory(). - getEntityUpdateRequest(upsertURI, updateType, order); - req.setFormat(contentType); - - req.execute(); - try { - final ClientEntity read = read(contentType, upsertURI); - assertNotNull(read); - assertEquals(order.getProperty("OrderID"), read.getProperty("OrderID")); - assertEquals(order.getProperty("OrderDate").getPrimitiveValue().toString(), - read.getProperty("OrderDate").getPrimitiveValue().toString()); - assertEquals(order.getProperty("ShelfLife").getPrimitiveValue().toString(), - read.getProperty("ShelfLife").getPrimitiveValue().toString()); - } finally { - getClient().getCUDRequestFactory().getDeleteRequest(upsertURI).execute(); - } - } - - @Test - @Ignore - public void updateSingleValuedNavigationReference() throws Exception { - URI targetURI = - getClient().newURIBuilder(testStaticServiceRootURL) - .appendEntitySetSegment("People") - .appendKeySegment(1) - .appendNavigationSegment("Parent") - .build(); - - URI reference = getClient().newURIBuilder(testStaticServiceRootURL) - .appendEntitySetSegment("People") - .appendKeySegment(0) - .build(); - - final ODataReferenceAddingRequest request = - getClient().getCUDRequestFactory().getReferenceSingleChangeRequest(new URI(testStaticServiceRootURL), - targetURI, reference); - - final ODataReferenceAddingResponse response = request.execute(); - - assertEquals(204, response.getStatusCode()); - } - - @Test - public void atomUpsert() { - upsert(UpdateType.PATCH, ContentType.APPLICATION_ATOM_XML); - upsert(UpdateType.REPLACE, ContentType.APPLICATION_ATOM_XML); - } - - @Test - public void jsonUpsert() { - upsert(UpdateType.PATCH, ContentType.JSON); - upsert(UpdateType.REPLACE, ContentType.JSON); - } - private void onContained(final ContentType contentType) { final String newName = UUID.randomUUID().toString(); final ClientEntity changes = getClient().getObjectFactory().newEntity( @@ -144,42 +65,4 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { public void jsonOnContained() { onContained(ContentType.JSON); } - - private void bindOperation(final ContentType contentType) throws EdmPrimitiveTypeException { - final ClientEntity changes = getClient().getObjectFactory().newEntity( - new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer")); - final ClientLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent", - getClient().newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(1).build()); - changes.getNavigationLinks().add(parent); - - final URI uri = getClient().newURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).build(); - final ODataEntityUpdateRequest<ClientEntity> req = getClient().getCUDRequestFactory(). - getEntityUpdateRequest(uri, UpdateType.PATCH, changes); - req.setFormat(contentType); - - final ODataEntityUpdateResponse<ClientEntity> res = req.execute(); - assertEquals(204, res.getStatusCode()); - - final ClientEntity updated = getClient().getRetrieveRequestFactory().getEntityRequest(uri).execute().getBody(); - assertNotNull(updated); - final ClientLink updatedLink = updated.getNavigationLink("Parent"); - assertNotNull(updatedLink); - - final ClientEntity updatedEntity = getClient().getRetrieveRequestFactory().getEntityRequest(updatedLink.getLink()). - execute().getBody(); - assertNotNull(updatedEntity); - assertEquals(1, updatedEntity.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0); - } - - @Test - public void atomBindOperation() throws EdmPrimitiveTypeException { - bindOperation(ContentType.APPLICATION_ATOM_XML); - } - - @Test - public void jsonBindOperation() throws EdmPrimitiveTypeException { - bindOperation(ContentType.JSON); - } }
