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

asf-gitbox-commits pushed a commit to branch 
UNOMI-983-refuse-item-without-itemid
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to 
refs/heads/UNOMI-983-refuse-item-without-itemid by this push:
     new ddcf7a151 UNOMI-983: Expect a profile with no itemId to be refused
ddcf7a151 is described below

commit ddcf7a1518bd86290e3d610cfe6c708cf9cbc570
Author: Serge Huber <[email protected]>
AuthorDate: Sun Sep 27 15:09:28 2026 +0200

    UNOMI-983: Expect a profile with no itemId to be refused
    
    The integration test still waited for the old behaviour, where a save with 
no itemId was stored and then read back. saveOrMerge now returns null and 
writes nothing, so the test crashed on an empty result.
---
 .../org/apache/unomi/itests/ProfileServiceIT.java     | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/itests/src/test/java/org/apache/unomi/itests/ProfileServiceIT.java 
b/itests/src/test/java/org/apache/unomi/itests/ProfileServiceIT.java
index e256c7004..3f9473236 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileServiceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileServiceIT.java
@@ -21,7 +21,6 @@ import org.apache.unomi.api.*;
 import org.apache.unomi.api.conditions.Condition;
 import org.apache.unomi.api.query.Query;
 import org.junit.After;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -89,20 +88,14 @@ public class ProfileServiceIT extends BaseIT {
     public void testProfileWithoutItemId() throws Exception {
         Profile profile = new Profile();
         profile.setProperty("name", "testProfileWithoutItemId");
-        profileService.saveOrMerge(profile);
 
-        Profile testProfile = keepTrying("Profile not found in the required 
time", () -> profileService.findProfilesByPropertyValue("properties.name", 
"testProfileWithoutItemId", 0, 10, null), Objects::nonNull,
-                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES).get(0);
-        LOGGER.info("Ensure an itemId as been set...");
-        Assert.assertNotNull(testProfile.getItemId());
+        assertNull("saveOrMerge must refuse a profile that carries no itemId", 
profileService.saveOrMerge(profile));
 
-        LOGGER.info("Delete profile...");
-        profileService.delete(testProfile.getItemId(), false);
-
-        waitForNullValue("Profile still present after deletion", () -> 
profileService.load(testProfile.getItemId()), DEFAULT_TRYING_TIMEOUT,
-                DEFAULT_TRYING_TRIES);
-
-        LOGGER.info("Profile deleted successfully.");
+        // Stay empty for the same window a successful save would have become 
visible in.
+        shouldBeTrueUntilEnd("A profile with no itemId must not be stored",
+                () -> 
profileService.findProfilesByPropertyValue("properties.name", 
"testProfileWithoutItemId", 0, 10, null),
+                found -> found != null && found.getTotalSize() == 0 && 
found.getList() != null && found.getList().isEmpty(),
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 
     @Test

Reply via email to