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

jkevan pushed a commit to branch optimizeProfileQueryDuringSegmentRemove
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to 
refs/heads/optimizeProfileQueryDuringSegmentRemove by this push:
     new c8a87ea5e UNOMI-557: Optimize the profile update during segment 
deletion
c8a87ea5e is described below

commit c8a87ea5e81a72c61da6d689e822d86e3e946032
Author: Kevan <[email protected]>
AuthorDate: Wed Jun 1 22:16:42 2022 +0200

    UNOMI-557: Optimize the profile update during segment deletion
---
 .../test/java/org/apache/unomi/itests/SegmentIT.java | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java 
b/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
index 038e45431..1eb03718a 100644
--- a/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
@@ -163,6 +163,12 @@ public class SegmentIT extends BaseIT {
 
     @Test
     public void testProfileEngagedSegmentAddedRemoved() throws 
InterruptedException {
+        Condition segmentSearchCondition = new Condition();
+        
segmentSearchCondition.setConditionType(definitionsService.getConditionType("profilePropertyCondition"));
+        segmentSearchCondition.setParameter("propertyName", "segments");
+        segmentSearchCondition.setParameter("comparisonOperator", "equals");
+        segmentSearchCondition.setParameter("propertyValue", 
"add-delete-segment-test");
+
         // create Profile
         Profile profile = new Profile();
         profile.setItemId("test_profile_id");
@@ -170,8 +176,8 @@ public class SegmentIT extends BaseIT {
         profileService.save(profile);
         persistenceService.refreshIndex(Profile.class, null);
 
-        keepTrying("Profile should not be engaged in the segment yet", () -> 
profileService.load("test_profile_id"),
-                loadedProfile -> loadedProfile != null && 
(loadedProfile.getSegments() == null || 
!loadedProfile.getSegments().contains("add-delete-segment-test")), 1000, 20);
+        keepTrying("Profile should not be engaged in the segment yet", () -> 
persistenceService.query(segmentSearchCondition, null, Profile.class),
+                profiles -> profiles.size() == 0, 1000, 20);
 
         // create the segment
         Metadata segmentMetadata = new Metadata("add-delete-segment-test");
@@ -181,19 +187,17 @@ public class SegmentIT extends BaseIT {
         segmentCondition.setParameter("comparisonOperator", "exists");
         segment.setCondition(segmentCondition);
         segmentService.setSegmentDefinition(segment);
-        persistenceService.refreshIndex(Profile.class, null);
 
         // insure the profile that did the past event condition is correctly 
engaged in the segment.
-        keepTrying("Profile should be engaged in the segment", () -> 
profileService.load("test_profile_id"),
-                loadedProfile -> loadedProfile != null && 
loadedProfile.getSegments() != null && 
loadedProfile.getSegments().contains("add-delete-segment-test"), 1000, 20);
+        keepTrying("Profile should be engaged in the segment", () -> 
persistenceService.query(segmentSearchCondition, null, Profile.class),
+                profiles -> profiles.size() == 1, 1000, 20);
 
         // delete the segment
         segmentService.removeSegmentDefinition("add-delete-segment-test", 
false);
-        persistenceService.refreshIndex(Profile.class, null);
 
         // insure the profile is not engaged anymore after segment deleted
-        keepTrying("Profile should not be engaged in the segment anymore after 
the segment have been deleted", () -> profileService.load("test_profile_id"),
-                loadedProfile -> loadedProfile != null && 
(loadedProfile.getSegments() == null || 
!loadedProfile.getSegments().contains("add-delete-segment-test")), 1000, 20);
+        keepTrying("Profile should not be engaged in the segment anymore after 
the segment have been deleted", () -> 
persistenceService.query(segmentSearchCondition, null, Profile.class),
+                profiles -> profiles.size() == 0, 1000, 20);
     }
 
     @Test

Reply via email to