You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2018/12/21 07:54:53 UTC

[syncope] branch 2_0_X updated: [SYNCOPE-1419] Adding integration test, also verified with Elasticsearch

This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 2_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/2_0_X by this push:
     new a2d7279  [SYNCOPE-1419] Adding integration test, also verified with Elasticsearch
a2d7279 is described below

commit a2d7279bbb9595b35e1a0234ea656f8c471fecc0
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Dec 21 08:54:41 2018 +0100

    [SYNCOPE-1419] Adding integration test, also verified with Elasticsearch
---
 .../core/persistence/jpa/dao/JPAAnySearchDAO.java    |  8 ++++----
 .../core/persistence/jpa/inner/AnySearchTest.java    |  6 +++---
 .../org/apache/syncope/fit/core/SearchITCase.java    | 20 ++++++++++++++++++++
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
index 6a1cd9c..7762937 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
@@ -757,10 +757,10 @@ public class JPAAnySearchDAO extends AbstractAnySearchDAO {
             final List<Object> parameters,
             final SearchSupport svs) {
         // This first branch is required for handling with not conditions given on multivalue fields (SYNCOPE-1419)
-        if (not && !(cond instanceof AnyCond)
-                && schema.isMultivalue()
-                && cond.getType() != AttributeCond.Type.ISNULL
-                && cond.getType() != AttributeCond.Type.ISNOTNULL) {
+        if (not && schema.isMultivalue()
+                && !(cond instanceof AnyCond)
+                && cond.getType() != AttributeCond.Type.ISNULL && cond.getType() != AttributeCond.Type.ISNOTNULL) {
+
             query.append("any_id NOT IN (SELECT DISTINCT any_id FROM ");
             if (schema.isUniqueConstraint()) {
                 query.append(svs.uniqueAttr().name);
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
index 585486d..bb37273 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
@@ -781,15 +781,15 @@ public class AnySearchTest extends AbstractTest {
                 AnyTypeKind.USER);
         assertFalse(users.isEmpty());
     }
-    
+
     @Test
     public void issueSYNCOPE1416() {
         AttributeCond idLeftCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
         idLeftCond.setSchema("surname");
-        
+
         AttributeCond idRightCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
         idRightCond.setSchema("firstname");
-        
+
         SearchCond searchCondition = SearchCond.getAndCond(
                 SearchCond.getLeafCond(idLeftCond), SearchCond.getLeafCond(idRightCond));
 
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
index 65003df..49b1723 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
@@ -643,4 +643,24 @@ public class SearchITCase extends AbstractITCase {
             assertEquals(ClientExceptionType.InvalidSearchExpression, e.getType());
         }
     }
+
+    @Test
+    public void issueSYNCOPE1419() {
+        PagedResult<UserTO> total = userService.search(
+                new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).page(1).size(1).build());
+
+        PagedResult<UserTO> matching = userService.search(
+                new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
+                        fiql(SyncopeClient.getUserSearchConditionBuilder().
+                                is("loginDate").equalTo("2009-05-26").query()).page(1).size(1).build());
+        assertTrue(matching.getSize() > 0);
+
+        PagedResult<UserTO> unmatching = userService.search(
+                new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
+                        fiql(SyncopeClient.getUserSearchConditionBuilder().
+                                is("loginDate").notEqualTo("2009-05-26").query()).page(1).size(1).build());
+        assertTrue(unmatching.getSize() > 0);
+
+        assertEquals(total.getTotalCount(), matching.getTotalCount() + unmatching.getTotalCount());;
+    }
 }