deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daniels...@apache.org
Subject deltaspike git commit: DELTASPIKE-1100 Support remove expressions
Date Sat, 26 Mar 2016 01:47:54 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 2b630819a -> 2b16d7abc


DELTASPIKE-1100 Support remove expressions


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/2b16d7ab
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/2b16d7ab
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/2b16d7ab

Branch: refs/heads/master
Commit: 2b16d7abcd452f545892c27fc4d1a32c92ceaea9
Parents: 2b63081
Author: Daniel Cunha <danielsoro@apache.org>
Authored: Fri Mar 25 18:45:38 2016 -0700
Committer: Daniel Cunha <danielsoro@apache.org>
Committed: Fri Mar 25 18:45:38 2016 -0700

----------------------------------------------------------------------
 .../deltaspike/data/impl/meta/MethodPrefix.java | 11 ++++++-
 .../data/impl/handler/QueryHandlerTest.java     | 32 ++++++++++++++++++++
 .../data/test/service/SimpleRepository.java     |  4 +++
 3 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2b16d7ab/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodPrefix.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodPrefix.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodPrefix.java
index 4bfb914..ba3d12a 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodPrefix.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/meta/MethodPrefix.java
@@ -26,6 +26,7 @@ public class MethodPrefix
     public static final String DEFAULT_OPT_PREFIX = "findOptionalBy";
     public static final String DEFAULT_ANY_PREFIX = "findAnyBy";
     public static final String DEFAULT_DELETE_PREFIX = "deleteBy";
+    public static final String DEFAULT_REMOVE_PREFIX = "removeBy";
 
     private final String customPrefix;
     private final String methodName;
@@ -86,7 +87,7 @@ public class MethodPrefix
 
     public boolean isDelete()
     {
-        return this.getPrefix().equalsIgnoreCase(DEFAULT_DELETE_PREFIX);
+        return this.getPrefix().equalsIgnoreCase(DEFAULT_DELETE_PREFIX) || this.getPrefix().equalsIgnoreCase(DEFAULT_REMOVE_PREFIX);
     }
 
     private static enum KnownQueryPrefix
@@ -122,6 +123,14 @@ public class MethodPrefix
             {
                 return SingleResultType.ANY;
             }
+        },
+        REMOVE_DEFAULT(DEFAULT_REMOVE_PREFIX)
+        {
+            @Override
+            public SingleResultType getStyle()
+            {
+                return SingleResultType.ANY;
+            }
         };
 
         private final String prefix;

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2b16d7ab/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
index 934f892..89b9397 100644
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/handler/QueryHandlerTest.java
@@ -160,6 +160,38 @@ public class QueryHandlerTest extends TransactionalTestCase
     }
 
     @Test
+    public void should_create_query_remove_by_method_name()
+    {
+        // given
+        final String name = "testCreateQueryByMethodName";
+        builder.createSimple(name);
+
+        // when
+        repo.removeByName(name);
+        repo.flush();
+        Simple result = repo.findAnyByName(name);
+
+        // then
+        assertNull(result);
+    }
+
+    @Test
+    public void should_create_query_remove_by_method_name_with_multiply_params()
+    {
+        // given
+        final String name = "testCreateQueryByMethodName";
+        builder.createSimple(name);
+
+        // when
+        repo.removeByNameAndEnabled(name, Boolean.TRUE);
+        repo.flush();
+        Simple result = repo.findAnyByName(name);
+
+        // then
+        assertNull(result);
+    }
+
+    @Test
     public void should_create_query_delete_by_method_name_with_multiply_params()
     {
         // given

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2b16d7ab/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
index 2b1a8d5..ebadd20 100755
--- a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
@@ -107,8 +107,12 @@ public abstract class SimpleRepository extends AbstractEntityRepository<Simple,
 
     public abstract void deleteByName(String name);
 
+    public abstract void removeByName(String name);
+
     public abstract void deleteByNameAndEnabled(String name, boolean enable);
 
+    public abstract void removeByNameAndEnabled(String name, Boolean aTrue);
+
     @Override
     protected abstract EntityManager entityManager();
 }


Mime
View raw message