olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [3/5] olingo-odata2 git commit: [OLINGO-476] Added test for Java enum
Date Mon, 19 Jan 2015 20:44:01 GMT
[OLINGO-476] Added test for Java enum


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/86576ce5
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/86576ce5
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/86576ce5

Branch: refs/heads/master
Commit: 86576ce591a44d442f3a4818a45b0491cb10304a
Parents: bfb3c18
Author: mibo <mibo@mirb.de>
Authored: Fri Jan 9 23:56:43 2015 +0100
Committer: mibo <mibo@mirb.de>
Committed: Fri Jan 9 23:56:43 2015 +0100

----------------------------------------------------------------------
 .../jpa/processor/core/access/data/JPAEntityTest.java   |  3 +++
 .../jpa/processor/core/mock/data/EdmMockUtilV2.java     |  8 ++++++++
 .../jpa/processor/core/mock/data/JPATypeMock.java       | 12 ++++++++++++
 .../processor/core/mock/data/ODataEntryMockUtil.java    |  2 ++
 4 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/86576ce5/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java
b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java
index e601bd8..74edb70 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java
@@ -86,6 +86,7 @@ public class JPAEntityTest {
       jpaEntity = new JPAEntity(edmEntityType, edmEntitySet, mockODataJPAContext());
       jpaEntity.create(ODataEntryMockUtil.mockODataEntry(JPATypeMock.ENTITY_NAME));
     } catch (ODataJPARuntimeException e) {
+      e.printStackTrace();
       fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
           + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
     } catch (EdmException e) {
@@ -101,6 +102,7 @@ public class JPAEntityTest {
     assertEquals(ODataEntryMockUtil.VALUE_C.charAt(0), jpaTypeMock.getMC());
     assertEquals(ODataEntryMockUtil.VALUE_CARRAY, new String(jpaTypeMock.getMCArray()));
     assertEquals(ODataEntryMockUtil.VALUE_CHAR, jpaTypeMock.getMChar().toString());
+    assertEquals(ODataEntryMockUtil.VALUE_ENUM, jpaTypeMock.getMSomeEnum());
     assertEquals(ODataEntryMockUtil.VALUE_CHARARRAY, JPAEntityParser.toString(jpaTypeMock.getMCharArray()));
     assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
   }
@@ -229,6 +231,7 @@ public class JPAEntityTest {
     JPATypeMock jpaTypeMock = (JPATypeMock) jpaEntity.getJPAEntity();
     assertEquals(jpaTypeMock.getMInt(), 0);// Key should not be changed
     assertEquals(jpaTypeMock.getMString(), ODataEntryMockUtil.VALUE_MSTRING);
+    assertEquals(ODataEntryMockUtil.VALUE_ENUM, jpaTypeMock.getMSomeEnum());
     assertTrue(jpaTypeMock.getMDateTime().equals(ODataEntryMockUtil.VALUE_DATE_TIME));
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/86576ce5/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/EdmMockUtilV2.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/EdmMockUtilV2.java
b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/EdmMockUtilV2.java
index dc8fe8b..23208ac 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/EdmMockUtilV2.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/EdmMockUtilV2.java
@@ -85,6 +85,8 @@ public class EdmMockUtilV2 {
     if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
       EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MINT)).andReturn(
           mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MINT)).anyTimes();
+      EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_ENUM)).andReturn(
+          mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_ENUM)).anyTimes();
       EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MSTRING)).andReturn(
           mockEdmProperty(entityName, JPATypeMock.PROPERTY_NAME_MSTRING)).anyTimes();
       EasyMock.expect(entityType.getProperty(JPATypeMock.PROPERTY_NAME_MDATETIME)).andReturn(
@@ -157,6 +159,7 @@ public class EdmMockUtilV2 {
       propertyNames.add(JPATypeMock.PROPERTY_NAME_MCARRAY);
       propertyNames.add(JPATypeMock.PROPERTY_NAME_MCHAR);
       propertyNames.add(JPATypeMock.PROPERTY_NAME_MCHARARRAY);
+      propertyNames.add(JPATypeMock.PROPERTY_NAME_ENUM);
     } else if (entityName.equals(JPARelatedTypeMock.ENTITY_NAME)) {
       propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MLONG);
       propertyNames.add(JPARelatedTypeMock.PROPERTY_NAME_MBYTE);
@@ -246,6 +249,7 @@ public class EdmMockUtilV2 {
     EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
 
     if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MINT) ||
+        propertyName.equals(JPATypeMock.PROPERTY_NAME_ENUM) ||
         propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING) ||
         propertyName.equals(JPATypeMock.PROPERTY_NAME_MDATETIME) ||
         propertyName.equals(JPATypeMock.PROPERTY_NAME_MBLOB) ||
@@ -266,6 +270,7 @@ public class EdmMockUtilV2 {
       EasyMock.expect(edmProperty.getType()).andReturn(edmType).anyTimes();
       EasyMock.expect(edmType.getKind()).andReturn(EdmTypeKind.SIMPLE).anyTimes();
       if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING) ||
+          propertyName.equals(JPATypeMock.PROPERTY_NAME_ENUM) ||
           propertyName.equals(JPATypeMock.PROPERTY_NAME_MCARRAY) ||
           propertyName.equals(JPATypeMock.PROPERTY_NAME_MC) ||
           propertyName.equals(JPATypeMock.PROPERTY_NAME_MCHAR) ||
@@ -351,6 +356,9 @@ public class EdmMockUtilV2 {
     } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MSTRING)) {
       mapping.setJPAType(String.class);
       ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MSTRING);
+    } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_ENUM)) {
+      mapping.setJPAType(JPATypeMock.JPATypeMockEnum.class);
+      ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_ENUM);
     } else if (propertyName.equals(JPATypeMock.PROPERTY_NAME_MBLOB)) {
       mapping.setJPAType(Blob.class);
       ((Mapping) mapping).setInternalName(JPATypeMock.PROPERTY_NAME_MBLOB);

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/86576ce5/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/JPATypeMock.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/JPATypeMock.java
b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/JPATypeMock.java
index 59701fb..3d7ddcc 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/JPATypeMock.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/JPATypeMock.java
@@ -28,6 +28,8 @@ import java.util.UUID;
 /* ========================================================================= */
 public class JPATypeMock {
 
+  enum JPATypeMockEnum {VALUE, MORE_VALUE}
+
   public static final String ENTITY_NAME = "JPATypeMock";
   public static final String PROPERTY_NAME_MINT = "mInt";
   public static final String PROPERTY_NAME_MSTRING = "mString";
@@ -40,6 +42,7 @@ public class JPATypeMock {
   public static final String PROPERTY_NAME_MCARRAY = "mCArray";
   public static final String PROPERTY_NAME_MKEY = "key";
   public static final String PROPERTY_NAME_MCOMPLEXTYPE = "complexType";
+  public static final String PROPERTY_NAME_ENUM = "mSomeEnum";
 
   public static final String NAVIGATION_PROPERTY_X = "mRelatedEntity";
   public static final String NAVIGATION_PROPERTY_XS = "mRelatedEntities";
@@ -55,6 +58,7 @@ public class JPATypeMock {
   private char[] mCArray;
   private Character mChar;
   private Character[] mCharArray;
+  private JPATypeMockEnum mSomeEnum;
 
   public Clob getMClob() {
     return mClob;
@@ -163,6 +167,14 @@ public class JPATypeMock {
     this.mBlob = mBlob;
   }
 
+  public JPATypeMockEnum getMSomeEnum() {
+    return mSomeEnum;
+  }
+
+  public void setMSomeEnum(JPATypeMockEnum mSomeEnum) {
+    this.mSomeEnum = mSomeEnum;
+  }
+
   /* ========================================================================= */
   public static class JPATypeEmbeddableMock {
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/86576ce5/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/ODataEntryMockUtil.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/ODataEntryMockUtil.java
b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/ODataEntryMockUtil.java
index 4f95a0e..e5a081c 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/ODataEntryMockUtil.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/mock/data/ODataEntryMockUtil.java
@@ -52,6 +52,7 @@ public class ODataEntryMockUtil {
   public static final float VALUE_MFLOAT = 2.00F;
   public static final UUID VALUE_UUID = UUID.fromString("38400000-8cf0-11bd-b23e-10b96e4ef00d");
   public static final short VALUE_SHORT = 2;
+  public static final JPATypeMock.JPATypeMockEnum VALUE_ENUM = JPATypeMock.JPATypeMockEnum.VALUE;
 
   public static ODataEntry mockODataEntry(final String entityName) {
     ODataEntry oDataEntry = EasyMock.createMock(ODataEntry.class);
@@ -77,6 +78,7 @@ public class ODataEntryMockUtil {
 
     if (entityName.equals(JPATypeMock.ENTITY_NAME)) {
       propertyMap.put(JPATypeMock.PROPERTY_NAME_MINT, VALUE_MINT);
+      propertyMap.put(JPATypeMock.PROPERTY_NAME_ENUM, "VALUE");
 
       VALUE_DATE_TIME = Calendar.getInstance(TimeZone.getDefault());
       VALUE_DATE_TIME.set(2013, 1, 1, 1, 1, 1);


Mime
View raw message