olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chri...@apache.org
Subject [4/5] olingo-odata4 git commit: [OLINGO-1004] Deleted Entity Create Test
Date Fri, 12 Aug 2016 10:03:19 GMT
[OLINGO-1004] Deleted Entity Create Test

Duplicated in BasicITCase


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/507e4deb
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/507e4deb
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/507e4deb

Branch: refs/heads/master
Commit: 507e4deb5a588ede0cc3bce05d8a2537a59c1966
Parents: bed8b4d
Author: Christian Amend <christian.amend@sap.com>
Authored: Fri Aug 12 11:55:42 2016 +0200
Committer: Christian Amend <christian.amend@sap.com>
Committed: Fri Aug 12 11:55:42 2016 +0200

----------------------------------------------------------------------
 .../olingo/fit/base/EntityCreateTestITCase.java | 104 +------------------
 1 file changed, 5 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/507e4deb/fit/src/test/java/org/apache/olingo/fit/base/EntityCreateTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/base/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/base/EntityCreateTestITCase.java
index 868c154..2993029 100644
--- a/fit/src/test/java/org/apache/olingo/fit/base/EntityCreateTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/base/EntityCreateTestITCase.java
@@ -30,9 +30,6 @@ import org.apache.olingo.client.api.communication.response.ODataDeleteResponse;
 import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
 import org.apache.olingo.client.api.domain.ClientEntity;
 import org.apache.olingo.client.api.domain.ClientEntitySet;
-import org.apache.olingo.client.api.domain.ClientInlineEntitySet;
-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;
@@ -41,17 +38,15 @@ import org.junit.Test;
 public class EntityCreateTestITCase extends AbstractTestITCase {
 
   @Test
-  public void atomCreateAndDelete() {
-    createAndDeleteOrder(testStaticServiceRootURL, ContentType.APPLICATION_ATOM_XML, 1000);
+  public void atomOnContained() {
+    onContained(ContentType.APPLICATION_ATOM_XML);
   }
 
   @Test
-  public void jsonCreateAndDelete() {
-    createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON, 1001);
-    createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON_NO_METADATA, 1001);
-    createAndDeleteOrder(testStaticServiceRootURL, ContentType.JSON_FULL_METADATA, 1001);
+  public void jsonOnContained() {
+    onContained(ContentType.JSON);
   }
-
+  
   private void onContained(final ContentType contentType) {
     final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts").
         appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build();
@@ -99,93 +94,4 @@ public class EntityCreateTestITCase extends AbstractTestITCase {
     final int sizeEnd = instruments.getCount();
     assertEquals(sizeBefore, sizeEnd);
   }
-
-  @Test
-  public void atomOnContained() {
-    onContained(ContentType.APPLICATION_ATOM_XML);
-  }
-
-  @Test
-  public void jsonOnContained() {
-    onContained(ContentType.JSON);
-  }
-
-  private void deepInsert(final ContentType contentType, final int productId, final int productDetailId)
-      throws EdmPrimitiveTypeException {
-
-    final ClientEntity product = getClient().getObjectFactory().
-        newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product"));
-    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductID",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productId)));
-    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Name",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("Latte")));
-    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("QuantityPerUnit",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("100g Bag")));
-    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("UnitPrice",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildSingle(3.24f)));
-    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("QuantityInStock",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(100)));
-    product.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Discontinued",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildBoolean(false)));
-    product.getProperties().add(getClient().getObjectFactory().newEnumProperty("UserAccess",
-        getClient().getObjectFactory().
-        newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "Execute")));
-    product.getProperties().add(getClient().getObjectFactory().newEnumProperty("SkinColor",
-        getClient().getObjectFactory().
-        newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Blue")));
-    product.getProperties().add(getClient().getObjectFactory().newCollectionProperty("CoverColors",
-        getClient().getObjectFactory().
-        newCollectionValue("Microsoft.Test.OData.Services.ODataWCFService.Color")));
-    product.getProperty("CoverColors").getCollectionValue().add(getClient().getObjectFactory().
-        newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Green"));
-    product.getProperty("CoverColors").getCollectionValue().add(getClient().getObjectFactory().
-        newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.Color", "Red"));
-
-    final ClientEntity detail = getClient().getObjectFactory().
-        newEntity(new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail"));
-    detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductID",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productId)));
-    detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductDetailID",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(productDetailId)));
-    detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("ProductName",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("LatteHQ")));
-    detail.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Description",
-        getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("High-Quality
Milk")));
-
-    final ClientEntitySet details = getClient().getObjectFactory().newEntitySet();
-    details.getEntities().add(detail);
-
-    final ClientInlineEntitySet inlineDetails = getClient().getObjectFactory().
-        newDeepInsertEntitySet("Details", details);
-    product.addLink(inlineDetails);
-
-    final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest(
-        getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Products").build(),
product);
-    req.setFormat(contentType);
-    final ODataEntityCreateResponse<ClientEntity> res = req.execute();
-    assertEquals(201, res.getStatusCode());
-
-    final ClientEntity createdProduct = res.getBody();
-    assertEquals(productId,
-        createdProduct.getProperty("ProductID").getPrimitiveValue().toCastValue(Integer.class),
0);
-
-    final ClientLink createdLink = createdProduct.getNavigationLink("Details");
-    assertNotNull(createdLink);
-
-    final ClientEntitySet createdProductDetails =
-        getClient().getRetrieveRequestFactory().getEntitySetRequest(createdLink.getLink()).execute().getBody();
-    assertNotNull(createdProductDetails);
-    assertEquals(productDetailId, createdProductDetails.getEntities().iterator().next().
-        getProperty("ProductDetailID").getPrimitiveValue().toCastValue(Integer.class), 0);
-  }
-
-  @Test
-  public void atomDeepInsert() throws EdmPrimitiveTypeException {
-    deepInsert(ContentType.APPLICATION_ATOM_XML, 10, 10);
-  }
-
-  @Test
-  public void jsonDeepInsert() throws EdmPrimitiveTypeException {
-    deepInsert(ContentType.JSON_FULL_METADATA, 11, 11);
-  }
 }


Mime
View raw message