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:55 UTC
[syncope] branch 2_1_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_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/2_1_X by this push:
new 695664b [SYNCOPE-1419] Adding integration test, also verified with Elasticsearch
695664b is described below
commit 695664bf8dd651ac9af0a71ea0bf124686b01407
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Dec 21 08:53:16 2018 +0100
[SYNCOPE-1419] Adding integration test, also verified with Elasticsearch
---
.../persistence/jpa/dao/PGJPAJSONAnySearchDAO.java | 10 +++++-----
.../core/persistence/jpa/dao/JPAAnySearchDAO.java | 9 +++++----
.../core/persistence/jpa/inner/AnySearchTest.java | 6 +++---
.../org/apache/syncope/fit/core/SearchITCase.java | 23 ++++++++++++++++++++--
4 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnySearchDAO.java b/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnySearchDAO.java
index 884a40b..dd34269 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnySearchDAO.java
+++ b/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/PGJPAJSONAnySearchDAO.java
@@ -158,10 +158,10 @@ public class PGJPAJSONAnySearchDAO extends JPAAnySearchDAO {
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("id NOT IN (SELECT DISTINCT any_id FROM ");
query.append(svs.field().name).append(" WHERE ");
fillAttrQuery(anyUtils, query, attrValue, schema, cond, false, parameters, svs);
@@ -280,7 +280,7 @@ public class PGJPAJSONAnySearchDAO extends JPAAnySearchDAO {
}
}
- StringBuilder query =
+ StringBuilder query =
new StringBuilder("SELECT DISTINCT any_id FROM ").append(svs.field().name).append(" WHERE ");
switch (cond.getType()) {
case ISNOTNULL:
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 81c0376..def529c 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
@@ -834,11 +834,12 @@ public class JPAAnySearchDAO extends AbstractAnySearchDAO {
final boolean not,
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.asSearchViewSupport().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 8d8ea69..1dae5c1 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
@@ -747,15 +747,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 6151871..b93463f 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
@@ -34,7 +34,6 @@ import org.apache.syncope.common.lib.patch.AnyObjectPatch;
import org.apache.syncope.common.lib.patch.AttrPatch;
import org.apache.syncope.common.lib.patch.MembershipPatch;
import org.apache.syncope.common.lib.patch.UserPatch;
-import org.apache.syncope.common.lib.search.SpecialAttr;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.AnyTypeTO;
import org.apache.syncope.common.lib.to.PagedResult;
@@ -288,7 +287,7 @@ public class SearchITCase extends AbstractITCase {
and("username").equalTo("bellini").query()).
build());
assertEquals(users, issueSYNCOPE1321);
-
+
// SYNCOPE-1416 (check the search for attributes of type different from stringvalue)
PagedResult<UserTO> issueSYNCOPE1416 = userService.search(new AnyQuery.Builder().
realm(SyncopeConstants.ROOT_REALM).
@@ -572,4 +571,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());;
+ }
}