You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dg...@apache.org on 2022/04/22 07:30:26 UTC

[unomi] branch master updated: first commit to fix tests (#404)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 032e74ab4 first commit to fix tests (#404)
032e74ab4 is described below

commit 032e74ab485942a3cf85f4378735fadfd66ae0c7
Author: jsinovassin <58...@users.noreply.github.com>
AuthorDate: Fri Apr 22 09:30:21 2022 +0200

    first commit to fix tests (#404)
    
    * Add and fix JSON schema event definitions
    
    * UNOMI-560 : clean and fix tests
    
    Co-authored-by: Serge Huber <sh...@jahia.com>
---
 .../test/java/org/apache/unomi/itests/BaseIT.java  |  27 ++-
 .../org/apache/unomi/itests/ContextServletIT.java  | 260 +++++++++++----------
 .../unomi/itests/CopyPropertiesActionIT.java       |  32 +--
 .../org/apache/unomi/itests/EventServiceIT.java    |  76 +++---
 .../unomi/itests/GroovyActionsServiceIT.java       |  24 +-
 .../apache/unomi/itests/IncrementInterestsIT.java  |  32 ++-
 .../apache/unomi/itests/IncrementPropertyIT.java   |  48 ++--
 .../org/apache/unomi/itests/InputValidationIT.java |   2 +-
 .../java/org/apache/unomi/itests/JSONSchemaIT.java |   4 -
 .../org/apache/unomi/itests/ModifyConsentIT.java   |  22 +-
 .../test/java/org/apache/unomi/itests/PatchIT.java |   4 +-
 .../org/apache/unomi/itests/PrivacyServiceIT.java  |  34 +--
 .../org/apache/unomi/itests/ProfileExportIT.java   |  20 +-
 .../apache/unomi/itests/ProfileImportActorsIT.java |  29 +--
 .../apache/unomi/itests/ProfileImportBasicIT.java  |   2 +-
 .../unomi/itests/ProfileImportRankingIT.java       |  34 ++-
 .../unomi/itests/ProfileImportSurfersIT.java       |  63 +++--
 .../org/apache/unomi/itests/ProfileMergeIT.java    |  38 +--
 .../org/apache/unomi/itests/ProfileServiceIT.java  |  65 +++---
 .../itests/ProfileServiceWithoutOverwriteIT.java   |  15 +-
 .../unomi/itests/PropertiesUpdateActionIT.java     |  41 ++--
 .../java/org/apache/unomi/itests/SecurityIT.java   |  12 +-
 .../java/org/apache/unomi/itests/SegmentIT.java    | 203 ++++++++--------
 .../schemas/events/float-property-type.json        |   3 +-
 .../cxs/schemas/events/anonymizeProfile.json       |  19 ++
 .../cxs/schemas/events/articleCompleted.json       |  30 +++
 .../META-INF/cxs/schemas/events/goal.json          |  30 +++
 .../META-INF/cxs/schemas/events/identify.json      |  30 +++
 .../cxs/schemas/events/incrementInterest.json      |  30 +++
 .../cxs/schemas/events/profileDeleted.json         |  19 ++
 .../cxs/schemas/events/profileUpdated.json         |  19 ++
 .../META-INF/cxs/schemas/events/ruleFired.json     |  30 +++
 .../META-INF/cxs/schemas/events/search.json        |  30 +++
 .../cxs/schemas/events/sessionCreated.json         |  30 +++
 .../cxs/schemas/events/sessionReassigned.json      |  30 +++
 .../cxs/schemas/events/updateProperties.json       |  30 +++
 36 files changed, 903 insertions(+), 514 deletions(-)

diff --git a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
index 767020ad5..5bc8d0360 100644
--- a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
@@ -106,6 +106,8 @@ public abstract class BaseIT {
     protected static final String BASIC_AUTH_USER_NAME = "karaf";
     protected static final String BASIC_AUTH_PASSWORD = "karaf";
     protected static final int REQUEST_TIMEOUT = 60000;
+    protected static final int DEFAULT_TRYING_TIMEOUT = 2000;
+    protected static final int DEFAULT_TRYING_TRIES = 30;
 
     @Inject
     @Filter(timeout = 600000)
@@ -302,6 +304,30 @@ public abstract class BaseIT {
         return value;
     }
 
+    protected <T> void waitForNullValue(String failMessage, Supplier<T> call, int timeout, int retries) throws InterruptedException {
+        int count = 0;
+        while (call.get() != null) {
+            if (count++ > retries) {
+                Assert.fail(failMessage);
+            }
+            Thread.sleep(timeout);
+        }
+    }
+
+    protected <T> T shouldBeTrueUntilEnd(String failMessage, Supplier<T> call, Predicate<T> predicate, int timeout, int retries) throws InterruptedException {
+        int count = 0;
+        T value = null;
+        while (count <= retries) {
+            count++;
+            value = call.get();
+            if (!predicate.test(value)) {
+                Assert.fail(failMessage);
+            }
+            Thread.sleep(timeout);
+        }
+        return value;
+    }
+
     protected String bundleResourceAsString(final String resourcePath) throws IOException {
         final java.net.URL url = bundleContext.getBundle().getResource(resourcePath);
         if (url != null) {
@@ -388,7 +414,6 @@ public abstract class BaseIT {
 
     public void createAndWaitForRule(Rule rule) throws InterruptedException {
         rulesService.setRule(rule);
-        refreshPersistence();
         keepTrying("Failed waiting for rule to be saved",
                 () -> rulesService.getRule(rule.getMetadata().getId()),
                 Objects::nonNull,
diff --git a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
index 60548a704..5c54efcae 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
@@ -21,11 +21,19 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
-import org.apache.unomi.api.*;
+import org.apache.unomi.api.ContextRequest;
+import org.apache.unomi.api.ContextResponse;
+import org.apache.unomi.api.Event;
+import org.apache.unomi.api.Metadata;
+import org.apache.unomi.api.Profile;
+import org.apache.unomi.api.Session;
 import org.apache.unomi.api.conditions.Condition;
 import org.apache.unomi.api.segments.Scoring;
 import org.apache.unomi.api.segments.Segment;
-import org.apache.unomi.api.services.*;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.api.services.EventService;
+import org.apache.unomi.api.services.ProfileService;
+import org.apache.unomi.api.services.SegmentService;
 import org.apache.unomi.persistence.spi.CustomObjectMapper;
 import org.apache.unomi.persistence.spi.PersistenceService;
 import org.junit.After;
@@ -36,9 +44,6 @@ import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
 import org.ops4j.pax.exam.util.Filter;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 import java.io.File;
@@ -47,11 +52,21 @@ import java.net.URI;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.ZoneOffset;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 import static org.hamcrest.core.IsCollectionContaining.hasItem;
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Created by Ron Barabash on 5/4/2020.
@@ -68,6 +83,8 @@ public class ContextServletIT extends BaseIT {
     private final static String TEST_EVENT_TYPE_SCHEMA = "test-event-type.json";
     private final static String FLOAT_PROPERTY_EVENT_TYPE = "float-property-type";
     private final static String FLOAT_PROPERTY_EVENT_TYPE_SCHEMA = "float-property-type.json";
+    private final static String TEST_PROFILE_ID = "test-profile-id";
+
     private final static String SEGMENT_ID = "test-segment-id";
     private final static int SEGMENT_NUMBER_OF_DAYS = 30;
 
@@ -76,8 +93,6 @@ public class ContextServletIT extends BaseIT {
 
     private ObjectMapper objectMapper = new ObjectMapper();
 
-    private final static Logger LOGGER = LoggerFactory.getLogger(ContextServletIT.class);
-
     @Inject
     @Filter(timeout = 600000)
     protected EventService eventService;
@@ -98,14 +113,10 @@ public class ContextServletIT extends BaseIT {
     @Filter(timeout = 600000)
     protected SegmentService segmentService;
 
-    @Inject
-    @Filter(timeout = 600000)
-    protected BundleContext bundleContext;
-
     private Profile profile;
 
     @Before
-    public void setUp() throws InterruptedException, IOException {
+    public void setUp() throws InterruptedException {
         this.registerEventType(TEST_EVENT_TYPE_SCHEMA);
         this.registerEventType(FLOAT_PROPERTY_EVENT_TYPE_SCHEMA);
 
@@ -121,14 +132,14 @@ public class ContextServletIT extends BaseIT {
         segment.setCondition(segmentCondition);
         segmentService.setSegmentDefinition(segment);
 
-        String profileId = "test-profile-id";
-        profile = new Profile(profileId);
+        profile = new Profile(TEST_PROFILE_ID);
         profileService.save(profile);
 
-        keepTrying("Couldn't find json schema endpoint",
-                () -> get(JSONSCHEMA_URL, List.class), Objects::nonNull,
-                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
-        refreshPersistence();
+        keepTrying("Profile " + TEST_PROFILE_ID + " not found in the required time", () -> profileService.load(TEST_PROFILE_ID),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+
+        keepTrying("Couldn't find json schema endpoint", () -> get(JSONSCHEMA_URL, List.class), Objects::nonNull, DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     @After
@@ -160,19 +171,24 @@ public class ContextServletIT extends BaseIT {
     public void testUpdateEventFromContextAuthorizedThirdParty_Success() throws IOException, InterruptedException {
         //Arrange
         String eventId = "test-event-id-" + System.currentTimeMillis();
-        String profileId = "test-profile-id";
         String sessionId = "test-session-id";
         String scope = "test-scope";
         String eventTypeOriginal = "test-event-type-original";
-        String eventTypeUpdated = TEST_EVENT_TYPE;
-        Profile profile = new Profile(profileId);
+        Profile profile = new Profile(TEST_PROFILE_ID);
         Session session = new Session(sessionId, profile, new Date(), scope);
         Event event = new Event(eventId, eventTypeOriginal, session, profile, scope, null, null, new Date());
         profileService.save(profile);
+
+        keepTrying("Profile " + TEST_PROFILE_ID + " not found in the required time", () -> profileService.load(TEST_PROFILE_ID),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+
         this.eventService.send(event);
-        refreshPersistence();
-        Thread.sleep(2000);
-        event.setEventType(eventTypeUpdated); //change the event so we can see the update effect
+
+        keepTrying("Event " + eventId + " not updated in the required time", () -> this.eventService.getEvent(eventId),
+                savedEvent -> Objects.nonNull(savedEvent) && eventTypeOriginal.equals(savedEvent.getEventType()), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
+
+        event.setEventType(TEST_EVENT_TYPE); //change the event so we can see the update effect
 
         //Act
         ContextRequest contextRequest = new ContextRequest();
@@ -182,31 +198,35 @@ public class ContextServletIT extends BaseIT {
         request.addHeader(THIRD_PARTY_HEADER_NAME, UNOMI_KEY);
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         TestUtils.executeContextJSONRequest(request, sessionId);
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
 
-        //Assert
-        event = this.eventService.getEvent(eventId);
+        event = keepTrying("Event " + eventId + " not updated in the required time", () -> eventService.getEvent(eventId),
+                savedEvent -> Objects.nonNull(savedEvent) && TEST_EVENT_TYPE.equals(savedEvent.getEventType()), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
         assertEquals(2, event.getVersion().longValue());
-        assertEquals(eventTypeUpdated, event.getEventType());
     }
 
     @Test
     public void testUpdateEventFromContextUnAuthorizedThirdParty_Fail() throws IOException, InterruptedException {
         //Arrange
         String eventId = "test-event-id-" + System.currentTimeMillis();
-        String profileId = "test-profile-id";
         String sessionId = "test-session-id";
         String scope = "test-scope";
         String eventTypeOriginal = "test-event-type-original";
         String eventTypeUpdated = TEST_EVENT_TYPE;
-        Profile profile = new Profile(profileId);
+        Profile profile = new Profile(TEST_PROFILE_ID);
         Session session = new Session(sessionId, profile, new Date(), scope);
         Event event = new Event(eventId, eventTypeOriginal, session, profile, scope, null, null, new Date());
         profileService.save(profile);
+
+        keepTrying("Profile " + TEST_PROFILE_ID + " not found in the required time", () -> profileService.load(TEST_PROFILE_ID),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+
         this.eventService.send(event);
-        refreshPersistence();
-        Thread.sleep(2000);
+
+        keepTrying("Event " + eventId + " not saved in the required time", () -> this.eventService.getEvent(eventId),
+                savedEvent -> Objects.nonNull(savedEvent) && eventTypeOriginal.equals(savedEvent.getEventType()), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
+
         event.setEventType(eventTypeUpdated); //change the event so we can see the update effect
 
         //Act
@@ -216,16 +236,13 @@ public class ContextServletIT extends BaseIT {
         HttpPost request = new HttpPost(URL + CONTEXT_URL);
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         TestUtils.executeContextJSONRequest(request, sessionId);
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
 
-        //Assert
-        event = this.eventService.getEvent(eventId);
+        // Check event type did not changed
+        event = shouldBeTrueUntilEnd("Event type should not have changed", () -> eventService.getEvent(eventId),
+                (savedEvent) -> eventTypeOriginal.equals(savedEvent.getEventType()), DEFAULT_TRYING_TIMEOUT, 10);
         assertEquals(1, event.getVersion().longValue());
-        assertEquals(eventTypeOriginal, event.getEventType());
     }
 
-
     @Test
     public void testUpdateEventFromContextAuthorizedThirdPartyNoItemID_Fail() throws IOException, InterruptedException {
         //Arrange
@@ -237,8 +254,11 @@ public class ContextServletIT extends BaseIT {
         Session session = new Session(sessionId, profile, new Date(), scope);
         Event event = new Event(eventId, eventTypeOriginal, session, profile, scope, null, null, new Date());
         this.eventService.send(event);
-        refreshPersistence();
-        Thread.sleep(2000);
+
+        keepTrying("Event " + eventId + " not saved in the required time", () -> this.eventService.getEvent(eventId),
+                savedEvent -> Objects.nonNull(savedEvent) && eventTypeOriginal.equals(savedEvent.getEventType()), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
+
         event.setEventType(eventTypeUpdated); //change the event so we can see the update effect
 
         //Act
@@ -248,13 +268,12 @@ public class ContextServletIT extends BaseIT {
         HttpPost request = new HttpPost(URL + CONTEXT_URL);
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         TestUtils.executeContextJSONRequest(request, sessionId);
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
 
-        //Assert
-        event = this.eventService.getEvent(eventId);
+        // Check event type did not changed
+        event = shouldBeTrueUntilEnd("Event type should not have changed", () -> eventService.getEvent(eventId),
+                (savedEvent) -> eventTypeOriginal.equals(savedEvent.getEventType()), DEFAULT_TRYING_TIMEOUT, 10);
+
         assertEquals(1, event.getVersion().longValue());
-        assertEquals(eventTypeOriginal, event.getEventType());
     }
 
     @Test
@@ -274,8 +293,8 @@ public class ContextServletIT extends BaseIT {
         HttpPost request = new HttpPost(URL + CONTEXT_URL);
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         String cookieHeaderValue = TestUtils.executeContextJSONRequest(request, sessionId).getCookieHeaderValue();
+
         refreshPersistence();
-        Thread.sleep(1000); //Making sure DB is updated
 
         //Add the context-profile-id cookie to the second event
         request.addHeader("Cookie", cookieHeaderValue);
@@ -286,6 +305,7 @@ public class ContextServletIT extends BaseIT {
         //Assert
         assertEquals(1, response.getProfileSegments().size());
         assertThat(response.getProfileSegments(), hasItem(SEGMENT_ID));
+
     }
 
     @Test
@@ -297,7 +317,8 @@ public class ContextServletIT extends BaseIT {
         event.setEventType(TEST_EVENT_TYPE);
         event.setScope(scope);
         String regularURI = URL + CONTEXT_URL;
-        long oldTimestamp = LocalDateTime.now(ZoneId.of("UTC")).minusDays(SEGMENT_NUMBER_OF_DAYS + 1).toInstant(ZoneOffset.UTC).toEpochMilli();
+        long oldTimestamp = LocalDateTime.now(ZoneId.of("UTC")).minusDays(SEGMENT_NUMBER_OF_DAYS + 1).toInstant(ZoneOffset.UTC)
+                .toEpochMilli();
         String customTimestampURI = regularURI + "?timestamp=" + oldTimestamp;
 
         //Act
@@ -309,15 +330,15 @@ public class ContextServletIT extends BaseIT {
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         //The first event is with a default timestamp (now)
         String cookieHeaderValue = TestUtils.executeContextJSONRequest(request, sessionId).getCookieHeaderValue();
-        refreshPersistence();
         //The second event is with a customized timestamp
         request.setURI(URI.create(customTimestampURI));
         request.addHeader("Cookie", cookieHeaderValue);
         ContextResponse response = (TestUtils.executeContextJSONRequest(request, sessionId)).getContextResponse(); //second event
-        refreshPersistence();
 
-        //Assert
-        assertEquals(0, response.getProfileSegments().size());
+        shouldBeTrueUntilEnd("Profile " + response.getProfileId() + " not found in the required time",
+                () -> profileService.load(response.getProfileId()),
+                (savedProfile) -> Objects.nonNull(savedProfile) && !savedProfile.getSegments().contains(SEGMENT_ID), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     @Test
@@ -340,31 +361,30 @@ public class ContextServletIT extends BaseIT {
         HttpPost request = new HttpPost(regularURI);
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         //The first event is with a default timestamp (now)
-        TestUtils.RequestResponse response = TestUtils.executeContextJSONRequest(request, sessionId);
-        String cookieHeaderValue = response.getCookieHeaderValue();
-        refreshPersistence();
+        String cookieHeaderValue = TestUtils.executeContextJSONRequest(request, sessionId).getCookieHeaderValue();
+
         //The second event is with a customized timestamp
         request.setURI(URI.create(customTimestampURI));
         request.addHeader("Cookie", cookieHeaderValue);
-        response = (TestUtils.executeContextJSONRequest(request, sessionId)); //second event
-        refreshPersistence();
+        ContextResponse response = TestUtils.executeContextJSONRequest(request, sessionId).getContextResponse(); //second event
 
-        //Assert
-        assertEquals(0, response.getContextResponse().getProfileSegments().size());
+        shouldBeTrueUntilEnd("Profile " + response.getProfileId() + " not found in the required time",
+                () -> profileService.load(response.getProfileId()),
+                (savedProfile) -> Objects.nonNull(savedProfile) && !savedProfile.getSegments().contains(SEGMENT_ID), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     @Test
     public void testCreateEventWithProfileId_Success() throws IOException, InterruptedException {
         //Arrange
         String eventId = "test-event-id-" + System.currentTimeMillis();
-        String profileId = "test-profile-id";
         String eventType = "test-event-type";
         Event event = new Event();
         event.setEventType(eventType);
         event.setItemId(eventId);
 
         ContextRequest contextRequest = new ContextRequest();
-        contextRequest.setProfileId(profileId);
+        contextRequest.setProfileId(TEST_PROFILE_ID);
         contextRequest.setEvents(Arrays.asList(event));
 
         //Act
@@ -372,12 +392,9 @@ public class ContextServletIT extends BaseIT {
         request.addHeader(THIRD_PARTY_HEADER_NAME, UNOMI_KEY);
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         TestUtils.executeContextJSONRequest(request);
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
 
-        //Assert
-        Profile profile = this.profileService.load(profileId);
-        assertEquals(profileId, profile.getItemId());
+        keepTrying("Profile " + TEST_PROFILE_ID + " not found in the required time", () -> profileService.load(TEST_PROFILE_ID),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 
     @Test
@@ -402,11 +419,10 @@ public class ContextServletIT extends BaseIT {
         request.addHeader(THIRD_PARTY_HEADER_NAME, UNOMI_KEY);
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         TestUtils.executeContextJSONRequest(request);
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
 
         //Assert
-        event = this.eventService.getEvent(eventId);
+        event = keepTrying("Event not found", () -> eventService.getEvent(eventId), Objects::nonNull, DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
         assertEquals(eventType, event.getEventType());
         assertEquals(3.14159, event.getProperty("floatProperty"));
     }
@@ -433,12 +449,10 @@ public class ContextServletIT extends BaseIT {
         request.addHeader(THIRD_PARTY_HEADER_NAME, UNOMI_KEY);
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         TestUtils.executeContextJSONRequest(request);
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
 
         //Assert
-        event = this.eventService.getEvent(eventId);
-        assertNull(event);
+        shouldBeTrueUntilEnd("Event should be null", () -> eventService.getEvent(eventId), Objects::isNull, DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     @Test
@@ -446,9 +460,8 @@ public class ContextServletIT extends BaseIT {
         //Arrange
         String eventId = "invalid-event-prop-id-" + System.currentTimeMillis();
         String profileId = "invalid-profile-id";
-        String eventType = FLOAT_PROPERTY_EVENT_TYPE;
         Event event = new Event();
-        event.setEventType(eventType);
+        event.setEventType(FLOAT_PROPERTY_EVENT_TYPE);
         event.setItemId(eventId);
         Map<String, Object> props = new HashMap<>();
         props.put("ffloatProperty", 3.14159);
@@ -463,12 +476,10 @@ public class ContextServletIT extends BaseIT {
         request.addHeader(THIRD_PARTY_HEADER_NAME, UNOMI_KEY);
         request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
         TestUtils.executeContextJSONRequest(request);
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
 
         //Assert
-        event = this.eventService.getEvent(eventId);
-        assertNull(event);
+        shouldBeTrueUntilEnd("Event should be null", () -> eventService.getEvent(eventId), Objects::isNull, DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     @Test
@@ -484,13 +495,12 @@ public class ContextServletIT extends BaseIT {
         Map<String, String> parameters = new HashMap<>();
         parameters.put("VULN_FILE_PATH", vulnFileCanonicalPath);
         HttpPost request = new HttpPost(URL + CONTEXT_URL);
-        request.setEntity(new StringEntity(getValidatedBundleJSON("security/ognl-payload-1.json", parameters), ContentType.APPLICATION_JSON));
+        request.setEntity(
+                new StringEntity(getValidatedBundleJSON("security/ognl-payload-1.json", parameters), ContentType.APPLICATION_JSON));
         TestUtils.executeContextJSONRequest(request);
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
-
-        assertFalse("Vulnerability successfully executed ! File created at " + vulnFileCanonicalPath, vulnFile.exists());
 
+        shouldBeTrueUntilEnd("Vulnerability successfully executed ! File created at " + vulnFileCanonicalPath, vulnFile::exists,
+                exists -> exists == Boolean.FALSE, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 
     @Test
@@ -506,78 +516,74 @@ public class ContextServletIT extends BaseIT {
         Map<String, String> parameters = new HashMap<>();
         parameters.put("VULN_FILE_PATH", vulnFileCanonicalPath);
         HttpPost request = new HttpPost(URL + CONTEXT_URL);
-        request.setEntity(new StringEntity(getValidatedBundleJSON("security/mvel-payload-1.json", parameters), ContentType.APPLICATION_JSON));
+        request.setEntity(
+                new StringEntity(getValidatedBundleJSON("security/mvel-payload-1.json", parameters), ContentType.APPLICATION_JSON));
         TestUtils.executeContextJSONRequest(request);
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
-
-        assertFalse("Vulnerability successfully executed ! File created at " + vulnFileCanonicalPath, vulnFile.exists());
 
+        shouldBeTrueUntilEnd("Vulnerability successfully executed ! File created at " + vulnFileCanonicalPath, vulnFile::exists,
+                exists -> exists == Boolean.FALSE, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 
-	@Test
-	public void testPersonalization() throws IOException, InterruptedException {
-
-		Map<String,String> parameters = new HashMap<>();
-		HttpPost request = new HttpPost(URL + CONTEXT_URL);
-		request.setEntity(new StringEntity(getValidatedBundleJSON("personalization.json", parameters), ContentType.APPLICATION_JSON));
-		TestUtils.RequestResponse response = TestUtils.executeContextJSONRequest(request);
-		assertEquals("Invalid response code", 200, response.getStatusCode());
-		refreshPersistence();
-		Thread.sleep(2000); //Making sure event is updated in DB
+    @Test
+    public void testPersonalization() throws IOException, InterruptedException {
 
-	}
+        Map<String, String> parameters = new HashMap<>();
+        HttpPost request = new HttpPost(URL + CONTEXT_URL);
+        request.setEntity(new StringEntity(getValidatedBundleJSON("personalization.json", parameters), ContentType.APPLICATION_JSON));
+        TestUtils.RequestResponse response = TestUtils.executeContextJSONRequest(request);
+        assertEquals("Invalid response code", 200, response.getStatusCode());
+    }
 
     @Test
     public void testPersonalizationWithControlGroup() throws IOException, InterruptedException {
 
-        Map<String,String> parameters = new HashMap<>();
+        Map<String, String> parameters = new HashMap<>();
         parameters.put("storeInSession", "false");
         HttpPost request = new HttpPost(URL + CONTEXT_URL);
-        request.setEntity(new StringEntity(getValidatedBundleJSON("personalization-controlgroup.json", parameters), ContentType.APPLICATION_JSON));
+        request.setEntity(
+                new StringEntity(getValidatedBundleJSON("personalization-controlgroup.json", parameters), ContentType.APPLICATION_JSON));
         TestUtils.RequestResponse response = TestUtils.executeContextJSONRequest(request);
         assertEquals("Invalid response code", 200, response.getStatusCode());
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
+
         ContextResponse contextResponse = response.getContextResponse();
 
-        Map<String,List<String>> personalizations = contextResponse.getPersonalizations();
+        Map<String, List<String>> personalizations = contextResponse.getPersonalizations();
 
         validatePersonalizations(personalizations);
 
         // let's check that the persisted profile has the control groups;
-        Map<String,Object> profileProperties = contextResponse.getProfileProperties();
-        List<Map<String,Object>> profileControlGroups = (List<Map<String,Object>>) profileProperties.get("unomiControlGroups");
+        Map<String, Object> profileProperties = contextResponse.getProfileProperties();
+        List<Map<String, Object>> profileControlGroups = (List<Map<String, Object>>) profileProperties.get("unomiControlGroups");
         assertControlGroups(profileControlGroups);
 
-        Profile updatedProfile = profileService.load(contextResponse.getProfileId());
-        profileControlGroups = (List<Map<String,Object>>) updatedProfile.getProperty("unomiControlGroups");
+        String profileId = contextResponse.getProfileId();
+        Profile updatedProfile = keepTrying("Profile not found", () -> profileService.load(profileId), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+        profileControlGroups = (List<Map<String, Object>>) updatedProfile.getProperty("unomiControlGroups");
         assertNotNull("Profile control groups not found in persisted profile", profileControlGroups);
         assertControlGroups(profileControlGroups);
 
         // now let's test with session storage
         parameters.put("storeInSession", "true");
         request = new HttpPost(URL + CONTEXT_URL);
-        request.setEntity(new StringEntity(getValidatedBundleJSON("personalization-controlgroup.json", parameters), ContentType.APPLICATION_JSON));
+        request.setEntity(
+                new StringEntity(getValidatedBundleJSON("personalization-controlgroup.json", parameters), ContentType.APPLICATION_JSON));
         response = TestUtils.executeContextJSONRequest(request);
         assertEquals("Invalid response code", 200, response.getStatusCode());
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
         contextResponse = response.getContextResponse();
 
         personalizations = contextResponse.getPersonalizations();
 
         validatePersonalizations(personalizations);
 
-        Map<String,Object> sessionProperties = contextResponse.getSessionProperties();
-        List<Map<String,Object>> sessionControlGroups = (List<Map<String,Object>>) sessionProperties.get("unomiControlGroups");
+        Map<String, Object> sessionProperties = contextResponse.getSessionProperties();
+        List<Map<String, Object>> sessionControlGroups = (List<Map<String, Object>>) sessionProperties.get("unomiControlGroups");
         assertControlGroups(sessionControlGroups);
 
         Session updatedSession = profileService.loadSession(contextResponse.getSessionId(), new Date());
-        sessionControlGroups = (List<Map<String,Object>>) updatedSession.getProperty("unomiControlGroups");
+        sessionControlGroups = (List<Map<String, Object>>) updatedSession.getProperty("unomiControlGroups");
         assertNotNull("Session control groups not found in persisted session", sessionControlGroups);
         assertControlGroups(sessionControlGroups);
-
     }
 
     private void validatePersonalizations(Map<String, List<String>> personalizations) {
@@ -602,22 +608,23 @@ public class ContextServletIT extends BaseIT {
     private void assertControlGroups(List<Map<String, Object>> profileControlGroups) {
         assertNotNull("Couldn't find control groups for profile", profileControlGroups);
         assertTrue("Control group size should be 1", profileControlGroups.size() == 1);
-        Map<String,Object> controlGroup = profileControlGroups.get(0);
+        Map<String, Object> controlGroup = profileControlGroups.get(0);
         assertEquals("Invalid ID for control group", "perso1", controlGroup.get("id"));
         assertEquals("Invalid path for control group", "/home/perso1.html", controlGroup.get("path"));
         assertEquals("Invalid displayName for control group", "First perso", controlGroup.get("displayName"));
         assertNotNull("Null timestamp for control group", controlGroup.get("timeStamp"));
     }
 
-
     @Test
     public void testRequireScoring() throws IOException, InterruptedException {
 
-        Map<String,String> parameters = new HashMap<>();
+        Map<String, String> parameters = new HashMap<>();
         String scoringSource = getValidatedBundleJSON("score1.json", parameters);
         Scoring scoring = CustomObjectMapper.getObjectMapper().readValue(scoringSource, Scoring.class);
         segmentService.setScoringDefinition(scoring);
-        refreshPersistence();
+
+        keepTrying("Profile does not contains scores in the required time", () -> profileService.load(TEST_PROFILE_ID), storedProfile ->
+                storedProfile.getScores() != null && storedProfile.getScores().get("score1") != null, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         // first let's make sure everything works without the requireScoring parameter
         parameters = new HashMap<>();
@@ -625,11 +632,9 @@ public class ContextServletIT extends BaseIT {
         request.setEntity(new StringEntity(getValidatedBundleJSON("withoutRequireScores.json", parameters), ContentType.APPLICATION_JSON));
         TestUtils.RequestResponse response = TestUtils.executeContextJSONRequest(request);
         assertEquals("Invalid response code", 200, response.getStatusCode());
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
 
         assertNotNull("Context response should not be null", response.getContextResponse());
-        Map<String,Integer> scores = response.getContextResponse().getProfileScores();
+        Map<String, Integer> scores = response.getContextResponse().getProfileScores();
         assertNull("Context response should not contain scores", scores);
 
         // now let's test adding it.
@@ -638,8 +643,6 @@ public class ContextServletIT extends BaseIT {
         request.setEntity(new StringEntity(getValidatedBundleJSON("withRequireScores.json", parameters), ContentType.APPLICATION_JSON));
         response = TestUtils.executeContextJSONRequest(request);
         assertEquals("Invalid response code", 200, response.getStatusCode());
-        refreshPersistence();
-        Thread.sleep(2000); //Making sure event is updated in DB
 
         assertNotNull("Context response should not be null", response.getContextResponse());
         scores = response.getContextResponse().getProfileScores();
@@ -649,5 +652,4 @@ public class ContextServletIT extends BaseIT {
 
         segmentService.removeScoringDefinition(scoring.getItemId(), false);
     }
-
 }
diff --git a/itests/src/test/java/org/apache/unomi/itests/CopyPropertiesActionIT.java b/itests/src/test/java/org/apache/unomi/itests/CopyPropertiesActionIT.java
index c51455080..f74b81223 100644
--- a/itests/src/test/java/org/apache/unomi/itests/CopyPropertiesActionIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/CopyPropertiesActionIT.java
@@ -24,7 +24,6 @@ import org.apache.unomi.api.PropertyType;
 import org.apache.unomi.api.rules.Rule;
 import org.apache.unomi.api.services.EventService;
 import org.apache.unomi.api.services.ProfileService;
-import org.apache.unomi.api.services.RulesService;
 import org.apache.unomi.persistence.spi.CustomObjectMapper;
 import org.junit.After;
 import org.junit.Assert;
@@ -47,6 +46,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Created by amidani on 12/10/2017.
@@ -64,9 +64,6 @@ public class CopyPropertiesActionIT extends BaseIT {
     public static final String PROPERTY_TO_MAP = "PropertyToMap";
     public static final String MAPPED_PROPERTY = "MappedProperty";
 
-    @Inject
-    @Filter(timeout = 600000)
-    protected RulesService rulesService;
     @Inject
     @Filter(timeout = 600000)
     protected ProfileService profileService;
@@ -75,7 +72,7 @@ public class CopyPropertiesActionIT extends BaseIT {
     protected EventService eventService;
 
     @Before
-    public void setUp() throws IOException, InterruptedException {
+    public void setUp() throws InterruptedException {
         Profile profile = new Profile();
         profile.setItemId(PROFILE_WITH_PROPERTIES);
         profile.setProperties(new HashMap<>());
@@ -83,23 +80,28 @@ public class CopyPropertiesActionIT extends BaseIT {
         profile.setProperty("singleValue", "A single value");
         profile.setProperty("existingArray", Arrays.asList("element1", "element2"));
         profileService.save(profile);
+        keepTrying("Profile " + PROFILE_WITH_PROPERTIES + " not found in the required time",
+                () -> profileService.load(PROFILE_WITH_PROPERTIES), Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
         LOGGER.info("Profile saved with ID [{}].", profile.getItemId());
 
         Profile profileTarget = new Profile();
         profileTarget.setItemId(EMPTY_PROFILE);
         profileService.save(profileTarget);
+        keepTrying("Profile " + EMPTY_PROFILE + " not found in the required time", () -> profileService.load(EMPTY_PROFILE),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
         LOGGER.info("Profile saved with ID [{}].", profileTarget.getItemId());
-
-        refreshPersistence();
     }
 
     @After
-    public void cleanUp() throws IOException, InterruptedException {
+    public void cleanUp() throws InterruptedException {
         profileService.delete(PROFILE_WITH_PROPERTIES, false);
         profileService.delete(EMPTY_PROFILE, false);
         profileService.deletePropertyType(ARRAY_PARAM_NAME);
         profileService.deletePropertyType(SINGLE_PARAM_NAME);
-        refreshPersistence();
+        waitForNullValue("Profile still present after deletion", () -> profileService.load(PROFILE_WITH_PROPERTIES), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
+        waitForNullValue("Profile still present after deletion", () -> profileService.load(EMPTY_PROFILE), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     private void initializePropertyType() {
@@ -131,7 +133,7 @@ public class CopyPropertiesActionIT extends BaseIT {
         profileService.setPropertyType(propertyType2);
     }
 
-    private void initializePropertyTypeWithMapping(){
+    private void initializePropertyTypeWithMapping() {
         Metadata metadata = new Metadata();
         metadata.setId(MAPPED_PROPERTY);
         metadata.setName("single parameter");
@@ -145,8 +147,8 @@ public class CopyPropertiesActionIT extends BaseIT {
 
         propertyType1.setAutomaticMappingsFrom(new HashSet<>(Arrays.asList(PROPERTY_TO_MAP)));
         profileService.setPropertyType(propertyType1);
-
     }
+
     private void initializePropertyTypeWithDifferentSystemTag() {
         Metadata metadata = new Metadata();
         metadata.setSystemTags(new HashSet<>(Arrays.asList("shouldBeAbsent")));
@@ -203,7 +205,7 @@ public class CopyPropertiesActionIT extends BaseIT {
 
         Event event = sendCopyPropertyEvent(properties, PROFILE_WITH_PROPERTIES);
 
-        Assert.assertTrue(((String) event.getProfile().getProperty("singleValue")).equals("A single value"));
+        Assert.assertTrue(event.getProfile().getProperty("singleValue").equals("A single value"));
     }
 
     @Test
@@ -215,7 +217,7 @@ public class CopyPropertiesActionIT extends BaseIT {
 
         Event event = sendCopyPropertyEvent(properties, PROFILE_WITH_PROPERTIES);
 
-        Assert.assertTrue(((String) event.getProfile().getProperty("singleValue")).equals("New value"));
+        Assert.assertTrue(event.getProfile().getProperty("singleValue").equals("New value"));
     }
 
     @Test
@@ -273,7 +275,7 @@ public class CopyPropertiesActionIT extends BaseIT {
 
         Event event = sendCopyPropertyEvent(properties, EMPTY_PROFILE);
 
-        Assert.assertTrue(((String) event.getProfile().getProperty(SINGLE_PARAM_NAME)).equals("New value"));
+        Assert.assertTrue(event.getProfile().getProperty(SINGLE_PARAM_NAME).equals("New value"));
     }
 
     @Test
@@ -287,7 +289,7 @@ public class CopyPropertiesActionIT extends BaseIT {
 
         Event event = sendCopyPropertyEvent(properties, EMPTY_PROFILE);
 
-        Assert.assertTrue(((String) event.getProfile().getProperty(MAPPED_PROPERTY)).equals("New value"));
+        Assert.assertTrue(event.getProfile().getProperty(MAPPED_PROPERTY).equals("New value"));
     }
 
     @Test
diff --git a/itests/src/test/java/org/apache/unomi/itests/EventServiceIT.java b/itests/src/test/java/org/apache/unomi/itests/EventServiceIT.java
index 9f3eb050f..06622f50d 100644
--- a/itests/src/test/java/org/apache/unomi/itests/EventServiceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/EventServiceIT.java
@@ -16,38 +16,29 @@
  */
 package org.apache.unomi.itests;
 
-import org.apache.unomi.api.services.EventService;
-import org.apache.unomi.api.services.ProfileService;
 import org.apache.unomi.api.Event;
+import org.apache.unomi.api.PartialList;
 import org.apache.unomi.api.Profile;
 import org.apache.unomi.api.conditions.Condition;
 import org.apache.unomi.api.query.Query;
-import org.apache.unomi.api.PartialList;
-
-
+import org.apache.unomi.api.services.EventService;
+import org.apache.unomi.api.services.ProfileService;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.junit.Assert;
-
-
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
 import org.ops4j.pax.exam.util.Filter;
 
 import javax.inject.Inject;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
-
-import java.text.SimpleDateFormat;
-import java.text.ParseException;
-
-
-import org.junit.Assert;
-
-
+import java.util.Objects;
 
 /**
  * An integration test for the event service
@@ -58,7 +49,8 @@ public class EventServiceIT extends BaseIT {
 
     private final static String TEST_PROFILE_ID = "test-profile-id";
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected EventService eventService;
 
     @Inject
@@ -73,18 +65,18 @@ public class EventServiceIT extends BaseIT {
     }
 
     @Test
-    public void test_EventExistenceWithProfileId() throws InterruptedException{
-        String eventId = "test-event-id-" + System.currentTimeMillis();;
+    public void test_EventExistenceWithProfileId() throws InterruptedException {
+        String eventId = "test-event-id-" + System.currentTimeMillis();
         String profileId = "test-profile-id";
         String eventType = "test-type";
         Profile profile = new Profile(profileId);
         Event event = new Event(eventId, eventType, null, profile, null, null, null, new Date());
         profileService.save(profile);
+        keepTrying("Profile with id profileId not found in the required time", () -> profileService.load(profileId), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
         eventService.send(event);
-        refreshPersistence();
-        Thread.sleep(2000);
-        boolean exist = eventService.hasEventAlreadyBeenRaised(event);
-        Assert.assertTrue(exist);
+        keepTrying("Event has not been raised", () -> eventService.hasEventAlreadyBeenRaised(event), raised -> raised == Boolean.TRUE,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 
     @Test
@@ -93,24 +85,26 @@ public class EventServiceIT extends BaseIT {
         String profileId = "past-event-profile-id" + System.currentTimeMillis();
         String eventType = "past-event-with-date-range-type";
         Profile profile = new Profile(profileId);
-        Date timestamp = null;
-        timestamp = new SimpleDateFormat("yyyy-MM-dd").parse("2000-06-30");
+        Date timestamp = new SimpleDateFormat("yyyy-MM-dd").parse("2000-06-30");
         Event event = new Event(eventId, eventType, null, profile, null, null, null, timestamp);
 
         profileService.save(profile);
         eventService.send(event);
-        refreshPersistence();
-        Thread.sleep(2000);
+
+        keepTrying("Profile with id profileId not found in the required time", () -> profileService.load(profileId), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+        keepTrying("Event has not been raised", () -> eventService.getEvent(eventId), Objects::nonNull, DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
 
         Condition eventTypeCondition = new Condition(definitionsService.getConditionType("eventTypeCondition"));
-        eventTypeCondition.setParameter("eventTypeId",eventType);
+        eventTypeCondition.setParameter("eventTypeId", eventType);
 
         Condition pastEventCondition = new Condition(definitionsService.getConditionType("pastEventCondition"));
         pastEventCondition.setParameter("minimumEventCount", 1);
-        pastEventCondition.setParameter("fromDate","1999-01-15T07:00:00Z");
-        pastEventCondition.setParameter("toDate","2001-01-15T07:00:00Z");
+        pastEventCondition.setParameter("fromDate", "1999-01-15T07:00:00Z");
+        pastEventCondition.setParameter("toDate", "2001-01-15T07:00:00Z");
 
-        pastEventCondition.setParameter("eventCondition",eventTypeCondition);
+        pastEventCondition.setParameter("eventCondition", eventTypeCondition);
 
         Query query = new Query();
         query.setCondition(pastEventCondition);
@@ -122,29 +116,31 @@ public class EventServiceIT extends BaseIT {
     }
 
     @Test
-    public void test_PastEventNotInRange_NoProfilesShouldReturn() throws InterruptedException, ParseException{
+    public void test_PastEventNotInRange_NoProfilesShouldReturn() throws InterruptedException, ParseException {
         String eventId = "past-event-id" + System.currentTimeMillis();
         String profileId = "past-event-profile-id" + System.currentTimeMillis();
         String eventType = "past-event-with-date-range-type";
         Profile profile = new Profile(profileId);
-        Date timestamp = null;
-        timestamp = new SimpleDateFormat("yyyy-MM-dd").parse("2000-06-30");
+        Date timestamp = new SimpleDateFormat("yyyy-MM-dd").parse("2000-06-30");
         Event event = new Event(eventId, eventType, null, profile, null, null, null, timestamp);
 
         profileService.save(profile);
         eventService.send(event);
-        refreshPersistence();
-        Thread.sleep(2000);
+
+        keepTrying("Profile with id profileId not found in the required time", () -> profileService.load(profileId), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+        keepTrying("Event has not been raised", () -> eventService.getEvent(eventId), Objects::nonNull, DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
 
         Condition eventTypeCondition = new Condition(definitionsService.getConditionType("eventTypeCondition"));
-        eventTypeCondition.setParameter("eventTypeId",eventType);
+        eventTypeCondition.setParameter("eventTypeId", eventType);
 
         Condition pastEventCondition = new Condition(definitionsService.getConditionType("pastEventCondition"));
         pastEventCondition.setParameter("minimumEventCount", 1);
-        pastEventCondition.setParameter("fromDate","2000-07-15T07:00:00Z");
-        pastEventCondition.setParameter("toDate","2001-01-15T07:00:00Z");
+        pastEventCondition.setParameter("fromDate", "2000-07-15T07:00:00Z");
+        pastEventCondition.setParameter("toDate", "2001-01-15T07:00:00Z");
 
-        pastEventCondition.setParameter("eventCondition",eventTypeCondition);
+        pastEventCondition.setParameter("eventCondition", eventTypeCondition);
 
         Query query = new Query();
         query.setCondition(pastEventCondition);
diff --git a/itests/src/test/java/org/apache/unomi/itests/GroovyActionsServiceIT.java b/itests/src/test/java/org/apache/unomi/itests/GroovyActionsServiceIT.java
index d34734a1a..9c38e7642 100644
--- a/itests/src/test/java/org/apache/unomi/itests/GroovyActionsServiceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/GroovyActionsServiceIT.java
@@ -26,7 +26,6 @@ import org.apache.unomi.api.rules.Rule;
 import org.apache.unomi.api.services.DefinitionsService;
 import org.apache.unomi.api.services.EventService;
 import org.apache.unomi.api.services.ProfileService;
-import org.apache.unomi.api.services.RulesService;
 import org.apache.unomi.groovy.actions.services.GroovyActionsService;
 import org.apache.unomi.persistence.spi.CustomObjectMapper;
 import org.junit.After;
@@ -64,10 +63,6 @@ public class GroovyActionsServiceIT extends BaseIT {
     @Filter(timeout = 600000)
     protected DefinitionsService definitionsService;
 
-    @Inject
-    @Filter(timeout = 600000)
-    protected RulesService rulesService;
-
     @Inject
     @Filter(timeout = 600000)
     protected ProfileService profileService;
@@ -85,13 +80,15 @@ public class GroovyActionsServiceIT extends BaseIT {
         profile.setProperty("firstname", "Alexandre");
         profile.setProperty("address", "Address");
         profileService.save(profile);
-        refreshPersistence();
+        keepTrying("Can not find the created profile", () -> profileService.load(PROFILE_ID), Objects::nonNull, DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     @After
     public void cleanUp() throws InterruptedException {
         profileService.delete(PROFILE_ID, false);
-        refreshPersistence();
+        waitForNullValue("The profile has not been deleted correctly", () -> profileService.load(PROFILE_ID), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     private String loadGroovyAction(String pathname) throws IOException {
@@ -161,16 +158,11 @@ public class GroovyActionsServiceIT extends BaseIT {
         Assert.assertNotNull(groovyCodeSource);
 
         groovyActionsService.remove(UPDATE_ADDRESS_ACTION);
-        refreshPersistence();
-
-        Thread.sleep(2000);
-        groovyCodeSource = groovyActionsService.getGroovyCodeSource(UPDATE_ADDRESS_ACTION);
-
-        Assert.assertNull(groovyCodeSource);
-
-        ActionType actionType = definitionsService.getActionType(UPDATE_ADDRESS_GROOVY_ACTION);
 
-        Assert.assertNull(actionType);
+        waitForNullValue("Groovy action is still present", () -> groovyActionsService.getGroovyCodeSource(UPDATE_ADDRESS_ACTION),
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
+        waitForNullValue("Action type is still present", () -> definitionsService.getActionType(UPDATE_ADDRESS_GROOVY_ACTION),
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 }
diff --git a/itests/src/test/java/org/apache/unomi/itests/IncrementInterestsIT.java b/itests/src/test/java/org/apache/unomi/itests/IncrementInterestsIT.java
index 93af871a9..3904b3609 100644
--- a/itests/src/test/java/org/apache/unomi/itests/IncrementInterestsIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/IncrementInterestsIT.java
@@ -16,10 +16,6 @@
  */
 package org.apache.unomi.itests;
 
-import java.util.*;
-
-import javax.inject.Inject;
-
 import org.apache.unomi.api.CustomItem;
 import org.apache.unomi.api.Event;
 import org.apache.unomi.api.Metadata;
@@ -43,6 +39,15 @@ import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
 import org.ops4j.pax.exam.util.Filter;
 
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
+
 import static org.apache.unomi.itests.BasicIT.ITEM_TYPE_PAGE;
 
 @RunWith(PaxExam.class)
@@ -76,14 +81,21 @@ public class IncrementInterestsIT extends BaseIT {
     public void setup() throws Exception {
         topic = createTopic("topicId");
         profile = createProfile();
-        rule = new Rule(new Metadata(null, UUID.randomUUID().toString(), "IncrementInterestRule", "Test rule for IncrementInterestIT automated tests"));
+        rule = new Rule(new Metadata(null, UUID.randomUUID().toString(), "IncrementInterestRule",
+                "Test rule for IncrementInterestIT automated tests"));
     }
 
     @After
-    public void tearDown() {
+    public void tearDown() throws InterruptedException {
         rulesService.removeRule(rule.getItemId());
+        waitForNullValue("Rule still present after deletion", () -> rulesService.getRule(rule.getItemId()), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
         topicService.delete(topic.getItemId());
+        waitForNullValue("Topic still present after deletion", () -> topicService.load(topic.getItemId()), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
         profileService.delete(profile.getItemId(), false);
+        waitForNullValue("Topic still present after deletion", () -> topicService.load(profile.getItemId()), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     @Test
@@ -139,7 +151,7 @@ public class IncrementInterestsIT extends BaseIT {
 
         Map<String, Object> properties = new HashMap<>();
 
-        Map<String,Object> pageInfo = new HashMap<>();
+        Map<String, Object> pageInfo = new HashMap<>();
         pageInfo.put("language", "en");
         pageInfo.put("destinationURL", "https://www.acme.com/test-page.html");
         pageInfo.put("referringURL", "https://unomi.apache.org");
@@ -188,8 +200,9 @@ public class IncrementInterestsIT extends BaseIT {
         topic.setScope("scope");
 
         topicService.save(topic);
-        refreshPersistence();
 
+        keepTrying("Topic not found in the required time", () -> topicService.load(topicId), Objects::nonNull, DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
         return topic;
     }
 
@@ -200,8 +213,9 @@ public class IncrementInterestsIT extends BaseIT {
         profile.setProperty("lastName", "LastName");
 
         profileService.save(profile);
-        refreshPersistence();
 
+        keepTrying("Topic not found in the required time", () -> profileService.load(profile.getItemId()), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
         return profile;
     }
 }
diff --git a/itests/src/test/java/org/apache/unomi/itests/IncrementPropertyIT.java b/itests/src/test/java/org/apache/unomi/itests/IncrementPropertyIT.java
index 3b75ce776..985aed06a 100644
--- a/itests/src/test/java/org/apache/unomi/itests/IncrementPropertyIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/IncrementPropertyIT.java
@@ -16,11 +16,10 @@
  */
 package org.apache.unomi.itests;
 
-import java.util.*;
-
-import javax.inject.Inject;
-
-import org.apache.unomi.api.*;
+import org.apache.unomi.api.CustomItem;
+import org.apache.unomi.api.Event;
+import org.apache.unomi.api.Metadata;
+import org.apache.unomi.api.Profile;
 import org.apache.unomi.api.actions.Action;
 import org.apache.unomi.api.conditions.Condition;
 import org.apache.unomi.api.rules.Rule;
@@ -38,6 +37,15 @@ import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
 import org.ops4j.pax.exam.util.Filter;
 
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
+
 import static org.apache.unomi.itests.BasicIT.ITEM_TYPE_PAGE;
 
 @RunWith(PaxExam.class)
@@ -70,9 +78,13 @@ public class IncrementPropertyIT extends BaseIT {
     }
 
     @After
-    public void tearDown() {
+    public void tearDown() throws InterruptedException {
         rulesService.removeRule(rule.getItemId());
         profileService.delete(profile.getItemId(), false);
+        waitForNullValue("Rule still present after deletion", () -> rulesService.getRule(rule.getItemId()), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
+        waitForNullValue("Profile still present after deletion", () -> profileService.load(profile.getItemId()), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
     }
 
     @Test
@@ -81,7 +93,6 @@ public class IncrementPropertyIT extends BaseIT {
 
         if (eventCode == EventService.PROFILE_UPDATED) {
             Profile updatedProfile = profileService.save(event.getProfile());
-            refreshPersistence();
 
             int value = ((Map<String, Integer>) updatedProfile.getProperty("pageView")).get("acme-space");
             Assert.assertEquals(1, value, 0.0);
@@ -254,7 +265,8 @@ public class IncrementPropertyIT extends BaseIT {
         if (eventCode == EventService.PROFILE_UPDATED) {
             Profile updatedProfile = profileService.save(event.getProfile());
 
-            Map<String, Integer> property = (Map<String, Integer>) ((Map<String, Object>) ((Map<String, Object>) updatedProfile.getProperty("continent")).get("country")).get("state");
+            Map<String, Integer> property = (Map<String, Integer>) ((Map<String, Object>) ((Map<String, Object>) updatedProfile
+                    .getProperty("continent")).get("country")).get("state");
             Assert.assertEquals(14, property.get("city"), 0.0);
         } else {
             Assert.fail("Profile was not updated");
@@ -268,7 +280,8 @@ public class IncrementPropertyIT extends BaseIT {
         if (eventCode == EventService.PROFILE_UPDATED) {
             Profile updatedProfile = profileService.save(event.getProfile());
 
-            Map<String, Integer> property = (Map<String, Integer>) ((Map<String, Object>) ((Map<String, Object>) updatedProfile.getProperty("continent")).get("country")).get("state");
+            Map<String, Integer> property = (Map<String, Integer>) ((Map<String, Object>) ((Map<String, Object>) updatedProfile
+                    .getProperty("continent")).get("country")).get("state");
             Assert.assertEquals(1, property.get("city"), 0.0);
         } else {
             Assert.fail("Profile was not updated");
@@ -298,7 +311,8 @@ public class IncrementPropertyIT extends BaseIT {
         if (eventCode == EventService.PROFILE_UPDATED) {
             Profile updatedProfile = profileService.save(event.getProfile());
 
-            Map<String, Integer> property = (Map<String, Integer>) ((Map<String, Object>) ((Map<String, Object>) updatedProfile.getProperty("continent")).get("country")).get("state");
+            Map<String, Integer> property = (Map<String, Integer>) ((Map<String, Object>) ((Map<String, Object>) updatedProfile
+                    .getProperty("continent")).get("country")).get("state");
             Assert.assertEquals(120, property.get("city"), 0.0);
         } else {
             Assert.fail("Profile was not updated");
@@ -373,14 +387,17 @@ public class IncrementPropertyIT extends BaseIT {
         createAndWaitForRule(rule);
     }
 
-    private int buildActionAndSendEvent(String propertyName, String propertyTargetName, Map<String, Object> properties, Map<String, Object> targetProperties) throws InterruptedException {
+    private int buildActionAndSendEvent(String propertyName, String propertyTargetName, Map<String, Object> properties,
+            Map<String, Object> targetProperties) throws InterruptedException {
         Action incrementPropertyAction = new Action(definitionsService.getActionType("incrementPropertyAction"));
         incrementPropertyAction.setParameter("propertyName", propertyName);
-        if (propertyTargetName != null) incrementPropertyAction.setParameter("propertyTarget", propertyTargetName);
+        if (propertyTargetName != null)
+            incrementPropertyAction.setParameter("propertyTarget", propertyTargetName);
 
         createRule(incrementPropertyAction);
 
-        if (properties != null) profile.setProperties(properties);
+        if (properties != null)
+            profile.setProperties(properties);
 
         CustomItem target = new CustomItem("ITEM_ID_PAGE", ITEM_TYPE_PAGE);
         target.setScope("acme-space");
@@ -401,7 +418,6 @@ public class IncrementPropertyIT extends BaseIT {
         event.setPersistent(false);
 
         int eventCode = eventService.send(event);
-        refreshPersistence();
 
         return eventCode;
     }
@@ -427,8 +443,8 @@ public class IncrementPropertyIT extends BaseIT {
         Profile profile = new Profile(UUID.randomUUID().toString());
 
         profileService.save(profile);
-        refreshPersistence();
 
-        return profile;
+        return keepTrying("Profile " + profile.getItemId() + " not found in the required time",
+                () -> profileService.load(profile.getItemId()), Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 }
diff --git a/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java b/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
index 4ccc60020..6199caace 100644
--- a/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java
@@ -146,7 +146,7 @@ public class InputValidationIT extends BaseIT {
     }
 
     @Test
-    public void test_cookie_profileIdPattern() throws IOException, InterruptedException {
+    public void test_cookie_profileIdPattern() throws IOException {
         Map<String, String> headers = new HashMap<>();
         headers.put("Cookie", "context-profile-id=<script>alert();</script>");
         doPOSTRequestTest(CONTEXT_JSON_URL, headers, null, 400, ERROR_MESSAGE_INVALID_DATA_RECEIVED);
diff --git a/itests/src/test/java/org/apache/unomi/itests/JSONSchemaIT.java b/itests/src/test/java/org/apache/unomi/itests/JSONSchemaIT.java
index ce4e4c8cb..086aa0493 100644
--- a/itests/src/test/java/org/apache/unomi/itests/JSONSchemaIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/JSONSchemaIT.java
@@ -78,7 +78,6 @@ public class JSONSchemaIT extends BaseIT {
 
         post(JSONSCHEMA_URL, "schemas/events/test-event-type.json", ContentType.TEXT_PLAIN);
 
-        refreshPersistence();
         jsonSchemas = keepTrying("Couldn't find json schemas", () -> get(JSONSCHEMA_URL, List.class), (list) -> !list.isEmpty(),
                 DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
         assertFalse("JSON schema list should not be empty", jsonSchemas.isEmpty());
@@ -93,7 +92,6 @@ public class JSONSchemaIT extends BaseIT {
         CloseableHttpResponse response = post(JSONSCHEMA_URL, "schemas/events/test-event-type.json", ContentType.TEXT_PLAIN);
 
         assertEquals("Invalid response code", 200, response.getStatusLine().getStatusCode());
-        refreshPersistence();
         List jsonSchemas = keepTrying("Couldn't find json schemas", () -> get(JSONSCHEMA_URL, List.class), (list) -> !list.isEmpty(),
                 DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
         assertFalse("JSON schema list should not be empty", jsonSchemas.isEmpty());
@@ -105,7 +103,6 @@ public class JSONSchemaIT extends BaseIT {
 
         post(JSONSCHEMA_URL, "schemas/events/test-event-type.json", ContentType.TEXT_PLAIN);
 
-        refreshPersistence();
         keepTrying("Couldn't find json schemas", () -> get(JSONSCHEMA_URL, List.class), (list) -> !list.isEmpty(), DEFAULT_TRYING_TIMEOUT,
                 DEFAULT_TRYING_TRIES);
 
@@ -114,7 +111,6 @@ public class JSONSchemaIT extends BaseIT {
         CloseableHttpResponse response = delete(JSONSCHEMA_URL + "/" + encodedString);
         assertEquals("Invalid response code", 204, response.getStatusLine().getStatusCode());
 
-        refreshPersistence();
         List jsonSchemas = keepTrying("wait for empty list of schemas", () -> get(JSONSCHEMA_URL, List.class), List::isEmpty,
                 DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
diff --git a/itests/src/test/java/org/apache/unomi/itests/ModifyConsentIT.java b/itests/src/test/java/org/apache/unomi/itests/ModifyConsentIT.java
index 831311535..1ef7b80e7 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ModifyConsentIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ModifyConsentIT.java
@@ -35,8 +35,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
-import java.io.IOException;
 import java.util.Date;
+import java.util.Objects;
 
 /**
  * An integration test for consent modifications using Apache Unomi @Event
@@ -48,16 +48,21 @@ public class ModifyConsentIT extends BaseIT {
 
     private final static String PROFILE_TEST_ID = "profile-consent";
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected ProfileService profileService;
-    @Inject @Filter(timeout = 600000)
+
+    @Inject
+    @Filter(timeout = 600000)
     protected EventService eventService;
 
     @Before
-    public void setUp() throws IOException {
+    public void setUp() throws InterruptedException {
         Profile profile = new Profile();
         profile.setItemId(PROFILE_TEST_ID);
         profileService.save(profile);
+        keepTrying("Profile " + PROFILE_TEST_ID + " not found in the required time", () -> profileService.load(PROFILE_TEST_ID),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
         LOGGER.info("Profile saved with ID [{}].", profile.getItemId());
     }
 
@@ -86,12 +91,7 @@ public class ModifyConsentIT extends BaseIT {
 
         Assert.assertTrue(changes > 0);
 
-        //Wait for data to be processed
-        Thread.sleep(10000);
-
-        profile = profileService.load(PROFILE_TEST_ID);
-
-        Assert.assertEquals(2, profile.getConsents().size());
-
+        keepTrying("Profile " + PROFILE_TEST_ID + " not found in the required time", () -> profileService.load(PROFILE_TEST_ID),
+                loadedProfile -> loadedProfile.getConsents().size() == 2, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 }
diff --git a/itests/src/test/java/org/apache/unomi/itests/PatchIT.java b/itests/src/test/java/org/apache/unomi/itests/PatchIT.java
index 679e87b30..c8fa08cbe 100644
--- a/itests/src/test/java/org/apache/unomi/itests/PatchIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/PatchIT.java
@@ -64,7 +64,7 @@ public class PatchIT extends BaseIT {
     protected BundleContext bundleContext;
 
     @Test
-    public void testPatch() throws IOException, InterruptedException {
+    public void testPatch() throws IOException {
         PropertyType company = profileService.getPropertyType("company");
 
         try {
@@ -83,7 +83,7 @@ public class PatchIT extends BaseIT {
     }
 
     @Test
-    public void testOverride() throws IOException, InterruptedException {
+    public void testOverride() throws IOException {
         PropertyType gender = profileService.getPropertyType("gender");
 
         try {
diff --git a/itests/src/test/java/org/apache/unomi/itests/PrivacyServiceIT.java b/itests/src/test/java/org/apache/unomi/itests/PrivacyServiceIT.java
index 0c4f8a37b..952aac421 100644
--- a/itests/src/test/java/org/apache/unomi/itests/PrivacyServiceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/PrivacyServiceIT.java
@@ -16,34 +16,16 @@
  */
 package org.apache.unomi.itests;
 
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
-import org.apache.unomi.api.PartialList;
-import org.apache.unomi.persistence.spi.CustomObjectMapper;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -57,23 +39,21 @@ public class PrivacyServiceIT extends BaseIT {
     private static final int DEFAULT_TRYING_TRIES = 30;
 
     @Before
-    public void setUp() throws InterruptedException, IOException {
-        keepTrying("Couldn't find privacy endpoint",
-                () -> get(PRIVACY_ENDPOINT + "/info", Map.class),
-                serverInfo -> serverInfo != null,
+    public void setUp() throws InterruptedException {
+        keepTrying("Couldn't find privacy endpoint", () -> get(PRIVACY_ENDPOINT + "/info", Map.class), Objects::nonNull,
                 DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 
     @Test
-    public void testServerInfo() throws IOException {
-        Map<String,Object> serverInfo = get(PRIVACY_ENDPOINT + "/info", Map.class);
+    public void testServerInfo() {
+        Map<String, Object> serverInfo = get(PRIVACY_ENDPOINT + "/info", Map.class);
         assertNotNull("Server info is null", serverInfo);
         assertEquals("Server identifier is incorrect", "Apache Unomi", serverInfo.get("serverIdentifier"));
     }
 
     @Test
-    public void testServerInfos() throws IOException {
-        List<Map<String,Object>> serverInfos = get(PRIVACY_ENDPOINT + "/infos", List.class);
+    public void testServerInfos() {
+        List<Map<String, Object>> serverInfos = get(PRIVACY_ENDPOINT + "/infos", List.class);
         assertEquals("Server info list is invalid", 1, serverInfos.size());
         assertEquals("Server identifier is incorrect", "Apache Unomi", serverInfos.get(0).get("serverIdentifier"));
     }
diff --git a/itests/src/test/java/org/apache/unomi/itests/ProfileExportIT.java b/itests/src/test/java/org/apache/unomi/itests/ProfileExportIT.java
index 8057ee018..82733531c 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileExportIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileExportIT.java
@@ -33,7 +33,13 @@ import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 import java.io.File;
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
 
 /**
  * Created by amidani on 14/08/2017.
@@ -43,9 +49,11 @@ import java.util.*;
 public class ProfileExportIT extends BaseIT {
     private Logger logger = LoggerFactory.getLogger(ProfileExportIT.class);
 
-    @Inject @Filter(value="(configDiscriminator=EXPORT)", timeout = 600000)
+    @Inject
+    @Filter(value = "(configDiscriminator=EXPORT)", timeout = 600000)
     protected ImportExportConfigurationService<ExportConfiguration> exportConfigurationService;
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected ProfileService profileService;
 
     @Test
@@ -79,7 +87,9 @@ public class ProfileExportIT extends BaseIT {
         profile3.setSegments(segments);
         profileService.save(profile3);
 
-        keepTrying("Failed waiting for the creation of the profiles for the export test", ()->  profileService.findProfilesByPropertyValue("segments", "exportItSeg", 0, 10, null), (p)->p.getTotalSize() == 3, 1000, 100);
+        keepTrying("Failed waiting for the creation of the profiles for the export test",
+                () -> profileService.findProfilesByPropertyValue("segments", "exportItSeg", 0, 10, null), (p) -> p.getTotalSize() == 3,
+                1000, 100);
 
         /*** Export Test ***/
         String itemId = "export-test";
@@ -105,7 +115,7 @@ public class ProfileExportIT extends BaseIT {
         exportConfigurationService.save(exportConfiguration, true);
 
         final File exportResult = new File("data/tmp/profiles-export.csv");
-        keepTrying("Failed waiting for export file to be created", ()-> exportResult, File::exists, 1000, 100);
+        keepTrying("Failed waiting for export file to be created", () -> exportResult, File::exists, 1000, 100);
 
         logger.info("PATH : {}", exportResult.getAbsolutePath());
         Assert.assertTrue(exportResult.exists());
diff --git a/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java b/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java
index 0d31b7f61..bfab6a3cf 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java
@@ -64,7 +64,8 @@ public class ProfileImportActorsIT extends BaseIT {
         propertyTypeTwitterId.getMetadata().setSystemTags(Collections.singleton("basicProfileProperties"));
         propertyTypeTwitterId.setTarget("profiles");
 
-        PropertyType propertyTypeActorsGenres = new PropertyType(new Metadata("integration", "movieGenres", "Movie Genres", "Movie Genres"));
+        PropertyType propertyTypeActorsGenres = new PropertyType(
+                new Metadata("integration", "movieGenres", "Movie Genres", "Movie Genres"));
         propertyTypeActorsGenres.setValueTypeId("string");
         propertyTypeActorsGenres.setMultivalued(true);
         propertyTypeActorsGenres.getMetadata().setSystemTags(Collections.singleton("basicProfileProperties"));
@@ -73,18 +74,11 @@ public class ProfileImportActorsIT extends BaseIT {
         profileService.setPropertyType(propertyTypeTwitterId);
         profileService.setPropertyType(propertyTypeActorsGenres);
 
-        PropertyType propTwitterId = keepTrying("Failed waiting for property type 'twitterId'",
-                () -> profileService.getPropertyType("twitterId"),
-                Objects::nonNull,
-                1000,
-                100);
-
-        PropertyType propActorsGenre = keepTrying("Failed waiting for property type 'movieGenres'",
-                () -> profileService.getPropertyType("movieGenres"),
-                Objects::nonNull,
-                1000,
-                100);
+        keepTrying("Failed waiting for property type 'twitterId'", () -> profileService.getPropertyType("twitterId"), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
+        keepTrying("Failed waiting for property type 'movieGenres'", () -> profileService.getPropertyType("movieGenres"), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         /*** Actors Test ***/
         String itemId = "6-actors-test";
@@ -108,17 +102,16 @@ public class ProfileImportActorsIT extends BaseIT {
 
         importConfigActors.getProperties().put("mapping", mappingActors);
         File importSurfersFile = new File("data/tmp/recurrent_import/");
-        importConfigActors.getProperties().put("source", "file://" + importSurfersFile.getAbsolutePath() + "?fileName=6-actors-test.csv&consumer.delay=10m&move=.done");
+        importConfigActors.getProperties().put("source",
+                "file://" + importSurfersFile.getAbsolutePath() + "?fileName=6-actors-test.csv&consumer.delay=10m&move=.done");
         importConfigActors.setActive(true);
 
         importConfigurationService.save(importConfigActors, true);
 
         //Wait for data to be processed
         keepTrying("Failed waiting for actors initial import to complete",
-                () -> profileService.findProfilesByPropertyValue("properties.city", "hollywood", 0, 10, null),
-                (p) -> p.getTotalSize() == 6,
-                1000,
-                200);
+                () -> profileService.findProfilesByPropertyValue("properties.city", "hollywood", 0, 10, null), (p) -> p.getTotalSize() == 6,
+                1000, 200);
 
         List<ImportConfiguration> importConfigurations = importConfigurationService.getAll();
         Assert.assertEquals(1, importConfigurations.size());
@@ -128,7 +121,7 @@ public class ProfileImportActorsIT extends BaseIT {
         Assert.assertNotNull(jeanneProfile.get(0));
         Assert.assertEquals("Jeanne; D'arc", jeanneProfile.get(0).getProperty("lastName"));
         Assert.assertEquals("jean@darc.com", jeanneProfile.get(0).getProperty("email"));
-        Assert.assertArrayEquals(new String[]{}, ((List) jeanneProfile.get(0).getProperty("movieGenres")).toArray());
+        Assert.assertArrayEquals(new String[] {}, ((List) jeanneProfile.get(0).getProperty("movieGenres")).toArray());
 
         PartialList<Profile> rockProfile = profileService.findProfilesByPropertyValue("properties.twitterId", "6", 0, 10, null);
         Assert.assertEquals(1, rockProfile.getList().size());
diff --git a/itests/src/test/java/org/apache/unomi/itests/ProfileImportBasicIT.java b/itests/src/test/java/org/apache/unomi/itests/ProfileImportBasicIT.java
index 3fec735e3..7f7c7c2a1 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportBasicIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportBasicIT.java
@@ -48,7 +48,7 @@ import java.util.Map;
 @ExamReactorStrategy(PerSuite.class)
 public class ProfileImportBasicIT extends BaseIT {
     private Logger logger = LoggerFactory.getLogger(ProfileImportBasicIT.class);
-    
+
     @Inject @Filter(value="(configDiscriminator=IMPORT)", timeout = 600000)
     protected ImportExportConfigurationService<ImportConfiguration> importConfigurationService;
     @Inject @Filter(timeout = 600000)
diff --git a/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java b/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
index 91594265a..12737e217 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
@@ -47,9 +47,11 @@ import java.util.Objects;
 @ExamReactorStrategy(PerSuite.class)
 public class ProfileImportRankingIT extends BaseIT {
 
-    @Inject @Filter(value="(configDiscriminator=IMPORT)", timeout = 600000)
+    @Inject
+    @Filter(value = "(configDiscriminator=IMPORT)", timeout = 600000)
     protected ImportExportConfigurationService<ImportConfiguration> importConfigurationService;
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected ProfileService profileService;
 
     @Test
@@ -72,18 +74,11 @@ public class ProfileImportRankingIT extends BaseIT {
 
         profileService.setPropertyType(propertyTypeRank);
 
-        PropertyType propUciId = keepTrying("Failed waiting for property type 'uciId'",
-                () -> profileService.getPropertyType("uciId"),
-                Objects::nonNull,
-                1000,
-                100);
-
-        PropertyType propRankId = keepTrying("Failed waiting for property type 'rank'",
-                () -> profileService.getPropertyType("rank"),
-                Objects::nonNull,
-                1000,
-                100);
+        PropertyType propUciId = keepTrying("Failed waiting for property type 'uciId'", () -> profileService.getPropertyType("uciId"),
+                Objects::nonNull, 1000, 100);
 
+        PropertyType propRankId = keepTrying("Failed waiting for property type 'rank'", () -> profileService.getPropertyType("rank"),
+                Objects::nonNull, 1000, 100);
 
         /*** Surfers Test ***/
         String itemId = "5-ranking-test";
@@ -106,20 +101,19 @@ public class ProfileImportRankingIT extends BaseIT {
 
         importConfigRanking.getProperties().put("mapping", mappingRanking);
         File importSurfersFile = new File("data/tmp/recurrent_import/");
-        importConfigRanking.getProperties().put("source", "file://" + importSurfersFile.getAbsolutePath() + "?fileName=5-ranking-test.csv&consumer.delay=10m&move=.done");
+        importConfigRanking.getProperties().put("source",
+                "file://" + importSurfersFile.getAbsolutePath() + "?fileName=5-ranking-test.csv&consumer.delay=10m&move=.done");
         importConfigRanking.setActive(true);
 
         importConfigurationService.save(importConfigRanking, true);
 
-
         //Wait for data to be processed
-        keepTrying("Failed waiting for ranking import to complete", ()->profileService.findProfilesByPropertyValue("properties.city", "rankingCity", 0, 50, null), (p)->p.getTotalSize() == 25, 1000, 200);
+        keepTrying("Failed waiting for ranking import to complete",
+                () -> profileService.findProfilesByPropertyValue("properties.city", "rankingCity", 0, 50, null),
+                (p) -> p.getTotalSize() == 25, 1000, 200);
 
         List<ImportConfiguration> importConfigurations = keepTrying("Failed waiting for import configurations list with 1 item",
-                () -> importConfigurationService.getAll(),
-                (list) -> Objects.nonNull(list) && list.size() == 1,
-                1000,
-                100);
+                () -> importConfigurationService.getAll(), (list) -> Objects.nonNull(list) && list.size() == 1, 1000, 100);
 
         PartialList<Profile> gregProfileList = profileService.findProfilesByPropertyValue("properties.uciId", "10004451371", 0, 10, null);
         Assert.assertEquals(1, gregProfileList.getList().size());
diff --git a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
index 01ea0fec0..4612b2058 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
@@ -37,7 +37,6 @@ import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 import java.io.File;
-import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -51,13 +50,15 @@ import java.util.Objects;
 public class ProfileImportSurfersIT extends BaseIT {
     private Logger logger = LoggerFactory.getLogger(ProfileImportSurfersIT.class);
 
-    @Inject @Filter(value="(configDiscriminator=IMPORT)", timeout = 600000)
+    @Inject
+    @Filter(value = "(configDiscriminator=IMPORT)", timeout = 600000)
     protected ImportExportConfigurationService<ImportConfiguration> importConfigurationService;
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected ProfileService profileService;
 
     @Test
-    public void testImportSurfers() throws IOException, InterruptedException {
+    public void testImportSurfers() throws InterruptedException {
 
         /*** Create Missing Properties ***/
         PropertyType propertyType = new PropertyType(new Metadata("integration", "alive", "Alive", "Is the person alive?"));
@@ -67,11 +68,7 @@ public class ProfileImportSurfersIT extends BaseIT {
 
         profileService.setPropertyType(propertyType);
 
-        keepTrying("Failed waiting for property type 'alive'",
-                () -> profileService.getPropertyType("alive"),
-                Objects::nonNull,
-                1000,
-                100);
+        keepTrying("Failed waiting for property type 'alive'", () -> profileService.getPropertyType("alive"), Objects::nonNull, 1000, 100);
 
         PropertyType propAlive = RouterUtils.getPropertyTypeById(profileService.getTargetPropertyTypes("profiles"), "alive");
 
@@ -99,7 +96,8 @@ public class ProfileImportSurfersIT extends BaseIT {
 
         importConfigSurfers.getProperties().put("mapping", mappingSurfers);
         File importSurfersFile = new File("data/tmp/recurrent_import/");
-        importConfigSurfers.getProperties().put("source", "file://" + importSurfersFile.getAbsolutePath() + "?fileName=2-surfers-test.csv&consumer.delay=10m&move=.done");
+        importConfigSurfers.getProperties().put("source",
+                "file://" + importSurfersFile.getAbsolutePath() + "?fileName=2-surfers-test.csv&consumer.delay=10m&move=.done");
         importConfigSurfers.setActive(true);
 
         importConfigurationService.save(importConfigSurfers, true);
@@ -107,13 +105,12 @@ public class ProfileImportSurfersIT extends BaseIT {
         logger.info("ProfileImportSurfersIT setup successfully.");
 
         //Wait for data to be processed
-        keepTrying("Failed waiting for surfers initial import to complete", ()->profileService.findProfilesByPropertyValue("properties.city", "surfersCity", 0, 50, null), (p)->p.getTotalSize() == 34, 1000, 100);
+        keepTrying("Failed waiting for surfers initial import to complete",
+                () -> profileService.findProfilesByPropertyValue("properties.city", "surfersCity", 0, 50, null),
+                (p) -> p.getTotalSize() == 34, 1000, 100);
 
-        keepTrying("Failed waiting for import configurations list with 1 item",
-                () -> importConfigurationService.getAll(),
-                (list) -> Objects.nonNull(list) && list.size() == 1,
-                1000,
-                100);
+        keepTrying("Failed waiting for import configurations list with 1 item", () -> importConfigurationService.getAll(),
+                (list) -> Objects.nonNull(list) && list.size() == 1, 1000, 100);
 
         //Profile not to delete
         PartialList<Profile> jordyProfile = profileService.findProfilesByPropertyValue("properties.email", "jordy@smith.com", 0, 10, null);
@@ -147,7 +144,8 @@ public class ProfileImportSurfersIT extends BaseIT {
         importConfigSurfersOverwrite.setHasDeleteColumn(true);
 
         importConfigSurfersOverwrite.getProperties().put("mapping", mappingSurfers);
-        importConfigSurfersOverwrite.getProperties().put("source", "file://" + importSurfersFile.getAbsolutePath() + "?fileName=3-surfers-overwrite-test.csv&consumer.delay=10m&move=.done");
+        importConfigSurfersOverwrite.getProperties().put("source",
+                "file://" + importSurfersFile.getAbsolutePath() + "?fileName=3-surfers-overwrite-test.csv&consumer.delay=10m&move=.done");
         importConfigSurfersOverwrite.setActive(true);
 
         importConfigurationService.save(importConfigSurfersOverwrite, true);
@@ -155,13 +153,12 @@ public class ProfileImportSurfersIT extends BaseIT {
         logger.info("ProfileImportSurfersOverwriteIT setup successfully.");
 
         //Wait for data to be processed
-        keepTrying("Failed waiting for surfers overwrite import to complete", ()->profileService.findProfilesByPropertyValue("properties.city", "surfersCity", 0, 50, null), (p)->p.getTotalSize() == 36, 1000, 100);
+        keepTrying("Failed waiting for surfers overwrite import to complete",
+                () -> profileService.findProfilesByPropertyValue("properties.city", "surfersCity", 0, 50, null),
+                (p) -> p.getTotalSize() == 36, 1000, 100);
 
-        keepTrying("Failed waiting for import configurations list with 1 item",
-                () -> importConfigurationService.getAll(),
-                (list) -> Objects.nonNull(list) && list.size() == 1,
-                1000,
-                100);
+        keepTrying("Failed waiting for import configurations list with 1 item", () -> importConfigurationService.getAll(),
+                (list) -> Objects.nonNull(list) && list.size() == 1, 1000, 100);
 
         //Profile not to delete
         PartialList<Profile> aliveProfiles = profileService.findProfilesByPropertyValue("properties.alive", "true", 0, 50, null);
@@ -171,7 +168,8 @@ public class ProfileImportSurfersIT extends BaseIT {
         Assert.assertEquals(36, deadProfiles.getList().size());
 
         //Profile to delete = false, was to delete
-        PartialList<Profile> paulineProfileOverwrite = profileService.findProfilesByPropertyValue("properties.lastName", "Pauline Ado", 0, 10, null);
+        PartialList<Profile> paulineProfileOverwrite = profileService
+                .findProfilesByPropertyValue("properties.lastName", "Pauline Ado", 0, 10, null);
         Assert.assertEquals(1, paulineProfileOverwrite.getList().size());
         importConfigurationService.delete(itemId2);
 
@@ -189,7 +187,8 @@ public class ProfileImportSurfersIT extends BaseIT {
 
         importConfigSurfersDelete.getProperties().put("mapping", mappingSurfers);
 
-        importConfigSurfersDelete.getProperties().put("source", "file://" + importSurfersFile.getAbsolutePath() + "?fileName=4-surfers-delete-test.csv&consumer.delay=10m&move=.done");
+        importConfigSurfersDelete.getProperties().put("source",
+                "file://" + importSurfersFile.getAbsolutePath() + "?fileName=4-surfers-delete-test.csv&consumer.delay=10m&move=.done");
         importConfigSurfersDelete.setActive(true);
 
         importConfigurationService.save(importConfigSurfersDelete, true);
@@ -197,15 +196,15 @@ public class ProfileImportSurfersIT extends BaseIT {
         logger.info("ProfileImportSurfersDeleteIT setup successfully.");
 
         //Wait for data to be processed
-        keepTrying("Failed waiting for surfers delete import to complete", ()->profileService.findProfilesByPropertyValue("properties.city", "surfersCity", 0, 50, null), (p)->p.getTotalSize() == 0, 1000, 100);
+        keepTrying("Failed waiting for surfers delete import to complete",
+                () -> profileService.findProfilesByPropertyValue("properties.city", "surfersCity", 0, 50, null),
+                (p) -> p.getTotalSize() == 0, 1000, 100);
 
-        keepTrying("Failed waiting for import configurations list with 1 item",
-                () -> importConfigurationService.getAll(),
-                (list) -> Objects.nonNull(list) && list.size() == 1,
-                1000,
-                100);
+        keepTrying("Failed waiting for import configurations list with 1 item", () -> importConfigurationService.getAll(),
+                (list) -> Objects.nonNull(list) && list.size() == 1, 1000, 100);
 
-        PartialList<Profile> jordyProfileDelete = profileService.findProfilesByPropertyValue("properties.email", "jordy@smith.com", 0, 10, null);
+        PartialList<Profile> jordyProfileDelete = profileService
+                .findProfilesByPropertyValue("properties.email", "jordy@smith.com", 0, 10, null);
         Assert.assertEquals(0, jordyProfileDelete.getList().size());
 
         importConfigurationService.delete(itemId3);
diff --git a/itests/src/test/java/org/apache/unomi/itests/ProfileMergeIT.java b/itests/src/test/java/org/apache/unomi/itests/ProfileMergeIT.java
index 4408510c2..ca260ed11 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileMergeIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileMergeIT.java
@@ -42,6 +42,7 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * Integration test for MergeProfilesOnPropertyAction
@@ -50,15 +51,20 @@ import java.util.List;
 @ExamReactorStrategy(PerSuite.class)
 public class ProfileMergeIT extends BaseIT {
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected EventService eventService;
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected RulesService rulesService;
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected DefinitionsService definitionsService;
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected ProfileService profileService;
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected PersistenceService persistenceService;
 
     private final static String TEST_EVENT_TYPE = "mergeProfileTestEventType";
@@ -93,7 +99,7 @@ public class ProfileMergeIT extends BaseIT {
         Condition condition = new Condition(definitionsService.getConditionType("eventTypeCondition"));
         condition.setParameter("eventTypeId", TEST_EVENT_TYPE);
 
-        final Action action = new Action( definitionsService.getActionType( "mergeProfilesOnPropertyAction"));
+        final Action action = new Action(definitionsService.getActionType("mergeProfilesOnPropertyAction"));
         action.setParameter("mergeProfilePropertyValue", "eventProperty::target.properties(email)");
         action.setParameter("mergeProfilePropertyName", "mergeIdentifier");
         action.setParameter("forceEventProfileAsMaster", false);
@@ -118,18 +124,19 @@ public class ProfileMergeIT extends BaseIT {
         eventProfile.setProperty("email", "username@domain.com");
         profileService.save(eventProfile);
 
-        refreshPersistence();
-
+        keepTrying("Profile with id masterProfileID not found in the required time", () -> profileService.load("masterProfileID"),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+        keepTrying("Profile with id eventProfileID not found in the required time", () -> profileService.load("eventProfileID"),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
         Event event = new Event(TEST_EVENT_TYPE, null, eventProfile, null, null, eventProfile, new Date());
-        eventService.send(event);
 
-        refreshPersistence();
+        eventService.send(event);
 
         Assert.assertNotNull(event.getProfile());
 
-        List<ProfileAlias> profileAliases = persistenceService.getAllItems(ProfileAlias.class);
-
-        Assert.assertFalse(profileAliases.isEmpty());
+        keepTrying("Profile with id masterProfileID not found in the required time",
+                () -> persistenceService.getAllItems(ProfileAlias.class), (profileAliases) -> !profileAliases.isEmpty(),
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         List<ProfileAlias> aliases = persistenceService.query("profileID", masterProfile.getItemId(), null, ProfileAlias.class);
 
@@ -152,13 +159,14 @@ public class ProfileMergeIT extends BaseIT {
 
     private Rule createMergeOnPropertyRule(boolean forceEventProfileAsMaster) throws InterruptedException {
         Rule mergeOnPropertyTestRule = new Rule();
-        mergeOnPropertyTestRule.setMetadata(new Metadata(null, TEST_RULE_ID, TEST_RULE_ID, "Test rule for testing MergeProfilesOnPropertyAction"));
+        mergeOnPropertyTestRule
+                .setMetadata(new Metadata(null, TEST_RULE_ID, TEST_RULE_ID, "Test rule for testing MergeProfilesOnPropertyAction"));
 
         Condition condition = new Condition(definitionsService.getConditionType("eventTypeCondition"));
         condition.setParameter("eventTypeId", TEST_EVENT_TYPE);
         mergeOnPropertyTestRule.setCondition(condition);
 
-        final Action mergeProfilesOnPropertyAction = new Action( definitionsService.getActionType( "mergeProfilesOnPropertyAction"));
+        final Action mergeProfilesOnPropertyAction = new Action(definitionsService.getActionType("mergeProfilesOnPropertyAction"));
         mergeProfilesOnPropertyAction.setParameter("mergeProfilePropertyValue", "eventProperty::target.properties(j:nodename)");
         mergeProfilesOnPropertyAction.setParameter("mergeProfilePropertyName", "mergeIdentifier");
         mergeProfilesOnPropertyAction.setParameter("forceEventProfileAsMaster", forceEventProfileAsMaster);
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 b91aec295..1340816de 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileServiceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileServiceIT.java
@@ -16,25 +16,16 @@
  */
 package org.apache.unomi.itests;
 
+import org.apache.unomi.api.PartialList;
 import org.apache.unomi.api.Profile;
 import org.apache.unomi.api.ProfileAlias;
 import org.apache.unomi.api.query.Query;
+import org.apache.unomi.api.services.DefinitionsService;
 import org.apache.unomi.api.services.ProfileService;
 import org.apache.unomi.persistence.spi.PersistenceService;
-import org.apache.unomi.api.services.DefinitionsService;
-import org.apache.unomi.api.PartialList;
-import org.apache.unomi.persistence.elasticsearch.*;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import org.junit.Ignore;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.junit.Before;
-
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
@@ -43,13 +34,17 @@ import org.osgi.service.cm.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.inject.Inject;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.UUID;
 import java.util.stream.IntStream;
 
-import javax.inject.Inject;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 /**
  * An integration test for the profile service
@@ -63,7 +58,8 @@ public class ProfileServiceIT extends BaseIT {
 
     private static final String TEST_PROFILE_ALIAS = "test-profile-alias";
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected ProfileService profileService;
 
     @Inject
@@ -85,18 +81,19 @@ public class ProfileServiceIT extends BaseIT {
         profile.setItemId(TEST_PROFILE_ID);
         profileService.save(profile);
 
-        refreshPersistence();
+        keepTrying("Profile not found in the required time", () -> profileService.load(TEST_PROFILE_ID), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         profileService.addAliasToProfile(profile.getItemId(), TEST_PROFILE_ALIAS, "defaultClientId");
 
-        refreshPersistence();
+        keepTrying("Profile alias not found in the required time", () -> profileService.load(TEST_PROFILE_ALIAS), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         LOGGER.info("Profile saved, now testing profile delete...");
         profileService.delete(TEST_PROFILE_ID, false);
 
-        refreshPersistence();
-
-        assertNull(profileService.load(TEST_PROFILE_ALIAS));
+        waitForNullValue("Profile still present after deletion", () -> profileService.load(TEST_PROFILE_ALIAS), DEFAULT_TRYING_TIMEOUT,
+                DEFAULT_TRYING_TRIES);
 
         LOGGER.info("Profile deleted successfully.");
     }
@@ -119,7 +116,12 @@ public class ProfileServiceIT extends BaseIT {
         profileService.save(profileTwo);
         profileService.save(profileThree);
 
-        Thread.sleep(4000); // Make sure Elastic is updated
+        keepTrying("Profile " + profileIdOne + " not found in the required time", () -> profileService.load(profileIdOne), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+        keepTrying("Profile " + profileIdTwo + " not found in the required time", () -> profileService.load(profileIdTwo), Objects::nonNull,
+                DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+        keepTrying("Profile " + profileIdThree + " not found in the required time", () -> profileService.load(profileIdThree),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
         Query query = new Query();
         query.setLimit(2);
@@ -142,7 +144,8 @@ public class ProfileServiceIT extends BaseIT {
 
     // Relevant only when throwExceptions system property is true
     @Test
-    public void testGetProfileWithWrongScrollerIdThrowException() throws InterruptedException, NoSuchFieldException, IllegalAccessException, IOException {
+    public void testGetProfileWithWrongScrollerIdThrowException()
+            throws InterruptedException, NoSuchFieldException, IllegalAccessException, IOException {
         boolean throwExceptionCurrent = false;
         Configuration elasticSearchConfiguration = configurationAdmin.getConfiguration("org.apache.unomi.persistence.elasticsearch");
         if (elasticSearchConfiguration != null) {
@@ -161,9 +164,9 @@ public class ProfileServiceIT extends BaseIT {
             fail("search method didn't throw when expected");
         } catch (RuntimeException ex) {
             // Should get here since this scenario should throw exception
-        }
-        finally {
-            updateConfiguration(PersistenceService.class.getName(), "org.apache.unomi.persistence.elasticsearch", "throwExceptions", throwExceptionCurrent);
+        } finally {
+            updateConfiguration(PersistenceService.class.getName(), "org.apache.unomi.persistence.elasticsearch", "throwExceptions",
+                    throwExceptionCurrent);
         }
     }
 
@@ -189,17 +192,17 @@ public class ProfileServiceIT extends BaseIT {
             profile.setItemId(profileID);
             profileService.save(profile);
 
-            refreshPersistence();
+            keepTrying("Profile " + profileID + " not found in the required time", () -> profileService.load(profileID), Objects::nonNull,
+                    DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
             IntStream.range(1, 3).forEach(index -> {
                 final String profileAlias = profileID + "_alias_" + index;
                 profileService.addAliasToProfile(profileID, profileAlias, "clientID" + index);
             });
 
-            refreshPersistence();
+            Profile storedProfile = keepTrying("Profile " + profileID + " not found in the required time",
+                    () -> profileService.load(profileID), Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
 
-            Profile storedProfile = profileService.load(profileID);
-            assertNotNull(storedProfile);
             assertEquals(profileID, storedProfile.getItemId());
 
             storedProfile = profileService.load(profileID + "_alias_1");
@@ -219,6 +222,12 @@ public class ProfileServiceIT extends BaseIT {
             });
 
             profileService.delete(profileID, false);
+            waitForNullValue("Profile still present after deletion", () -> profileService.load(profileID), DEFAULT_TRYING_TIMEOUT,
+                    DEFAULT_TRYING_TRIES);
+            waitForNullValue("Profile still present after deletion", () -> profileService.load(profileID + "_alias_1"),
+                    DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+            waitForNullValue("Profile still present after deletion", () -> profileService.load(profileID + "_alias_2"),
+                    DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
         }
     }
 
diff --git a/itests/src/test/java/org/apache/unomi/itests/ProfileServiceWithoutOverwriteIT.java b/itests/src/test/java/org/apache/unomi/itests/ProfileServiceWithoutOverwriteIT.java
index bcd427e3a..aa3a34c2d 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileServiceWithoutOverwriteIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileServiceWithoutOverwriteIT.java
@@ -29,13 +29,12 @@ import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerSuite;
 import org.ops4j.pax.exam.util.Filter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 
 import static org.junit.Assert.assertEquals;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@@ -46,7 +45,6 @@ import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerSuite.class)
 public class ProfileServiceWithoutOverwriteIT extends BaseIT {
-    private final static Logger LOGGER = LoggerFactory.getLogger(ProfileServiceWithoutOverwriteIT.class);
 
     private final static String TEST_PROFILE_ID = "test-profile-id";
 
@@ -59,7 +57,8 @@ public class ProfileServiceWithoutOverwriteIT extends BaseIT {
         return options.toArray(new Option[0]);
     }
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected ProfileService profileService;
 
     @Inject
@@ -100,12 +99,17 @@ public class ProfileServiceWithoutOverwriteIT extends BaseIT {
         profileService.refresh();
 
         Profile updatedProfile = profileService.load(profileId);
+        /*Profile updatedProfile = keepTrying("Profile " + profileId + " not found in the required time",
+                () -> profileService.load(profileId), Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);*/
         updatedProfile.setProperty("country", "test2-country");
         profileService.save(updatedProfile);
 
         profileService.refresh();
 
         Profile profileWithNewCountry = profileService.load(profileId);
+
+        /*Profile profileWithNewCountry = keepTrying("Profile " + profileId + " not found in the required time",
+                () -> profileService.load(profileId), Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);*/
         assertEquals("Country property doesn't have expected value", "test2-country", profileWithNewCountry.getProperty("country"));
     }
 
@@ -117,6 +121,9 @@ public class ProfileServiceWithoutOverwriteIT extends BaseIT {
         profileService.refresh();
 
         Profile updatedProfile = profileService.load(profileId);
+
+        /*Profile updatedProfile = keepTrying("Profile " + profileId + " not found in the required time",
+                () -> profileService.load(profileId), Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);*/
         updatedProfile.setProperty("country", "test2-country");
         updatedProfile.setSystemMetadata("seq_no", 1L);
         profileService.save(updatedProfile);
diff --git a/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java b/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
index f13007dce..8dd022a68 100644
--- a/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/PropertiesUpdateActionIT.java
@@ -37,13 +37,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
-import java.io.File;
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.TimeZone;
 
 /**
  * Created by amidani on 12/10/2017.
@@ -57,15 +61,18 @@ public class PropertiesUpdateActionIT extends BaseIT {
     private final static String PROFILE_TARGET_TEST_ID = "profile-target-event";
     private final static String PROFILE_TEST_ID = "profile-to-update-by-event";
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected ProfileService profileService;
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected EventService eventService;
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected RulesService rulesService;
 
     @Before
-    public void setUp() throws IOException, InterruptedException {
+    public void setUp() throws InterruptedException {
         Profile profile = new Profile();
         profile.setItemId(PROFILE_TEST_ID);
         profile.setProperties(new HashMap<>());
@@ -79,7 +86,10 @@ public class PropertiesUpdateActionIT extends BaseIT {
         profileService.save(profileTarget);
         LOGGER.info("Profile saved with ID [{}].", profileTarget.getItemId());
 
-        refreshPersistence();
+        keepTrying("Profile " + PROFILE_TEST_ID + " not found in the required time", () -> profileService.load(PROFILE_TEST_ID),
+                Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+        keepTrying("Profile " + PROFILE_TARGET_TEST_ID + " not found in the required time",
+                () -> profileService.load(PROFILE_TARGET_TEST_ID), Objects::nonNull, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
     }
 
     @Test
@@ -147,8 +157,9 @@ public class PropertiesUpdateActionIT extends BaseIT {
         profileService.save(profile);
         refreshPersistence();
 
-        profile = profileService.load(PROFILE_TEST_ID);
-        Assert.assertEquals("Props_to_add should set the prop if it's missing", "New property 1", profile.getProperty("prop1"));
+        profile = keepTrying("Props_to_add should set the prop if it's missing", () -> profileService.load(PROFILE_TEST_ID),
+                loadedProfile -> "New property 1".equals(loadedProfile.getProperty("prop1")), DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+
         Assert.assertEquals("Props_to_add should set the prop if it's missing", "New property 2", profile.getProperty("prop2"));
         Assert.assertEquals("Props_to_add should set the prop if it's missing", "New property 3", profile.getProperty("prop3"));
         Assert.assertEquals("Props_to_add should not override existing prop", "New property 4", profile.getProperty("prop4"));
@@ -173,7 +184,9 @@ public class PropertiesUpdateActionIT extends BaseIT {
         profileService.save(profile);
         refreshPersistence();
 
-        profile = profileService.load(PROFILE_TEST_ID);
+        profile = keepTrying("prop1 not updated", () -> profileService.load(PROFILE_TEST_ID),
+                loadedProfile -> "New property 1".equals(loadedProfile.getProperty("prop1")), DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+
         Assert.assertEquals("New property 1", profile.getProperty("prop1"));
         Assert.assertEquals("New property 2", profile.getProperty("prop2"));
         Assert.assertEquals("New property 3", profile.getProperty("prop3"));
@@ -321,7 +334,8 @@ public class PropertiesUpdateActionIT extends BaseIT {
         dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
 
         // register test rule
-        Rule rule = CustomObjectMapper.getObjectMapper().readValue(getValidatedBundleJSON("testSetPropertyActionRule.json", new HashMap<>()), Rule.class);
+        Rule rule = CustomObjectMapper.getObjectMapper()
+                .readValue(getValidatedBundleJSON("testSetPropertyActionRule.json", new HashMap<>()), Rule.class);
         createAndWaitForRule(rule);
 
         try {
@@ -335,7 +349,8 @@ public class PropertiesUpdateActionIT extends BaseIT {
             profileService.save(profile);
             refreshPersistence();
             profile = profileService.load(PROFILE_TEST_ID);
-            Assert.assertEquals("currentEventTimeStamp should be the exact date of the event timestamp", eventTimeStamp1, profile.getProperty("currentEventTimeStamp"));
+            Assert.assertEquals("currentEventTimeStamp should be the exact date of the event timestamp", eventTimeStamp1,
+                    profile.getProperty("currentEventTimeStamp"));
             Assert.assertNotEquals("currentDate should be the current system date", eventTimeStamp1, profile.getProperty("currentDate"));
             Assert.assertNotNull("currentDate should be set", profile.getProperty("currentDate"));
         } finally {
diff --git a/itests/src/test/java/org/apache/unomi/itests/SecurityIT.java b/itests/src/test/java/org/apache/unomi/itests/SecurityIT.java
index 23ad4d818..f76c61231 100644
--- a/itests/src/test/java/org/apache/unomi/itests/SecurityIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/SecurityIT.java
@@ -49,18 +49,18 @@ public class SecurityIT extends BaseIT {
     private ObjectMapper objectMapper;
 
     @Before
-    public void setUp() throws InterruptedException {
+    public void setUp() {
         objectMapper = CustomObjectMapper.getObjectMapper();
     }
 
     @Test
-    public void testOGNLInjection() throws IOException, InterruptedException {
+    public void testOGNLInjection() throws IOException {
         ContextRequest contextRequest = new ContextRequest();
         List<PersonalizationService.PersonalizationRequest> personalizations = new ArrayList<>();
         PersonalizationService.PersonalizationRequest personalizationRequest = new PersonalizationService.PersonalizationRequest();
         personalizationRequest.setId("vuln-test");
         personalizationRequest.setStrategy("matching-first");
-        Map<String,Object> strategyOptions = new HashMap<>();
+        Map<String, Object> strategyOptions = new HashMap<>();
         strategyOptions.put("fallback", "var2");
         personalizationRequest.setStrategyOptions(strategyOptions);
         List<PersonalizationService.PersonalizedContent> personalizationContents = new ArrayList<>();
@@ -76,7 +76,9 @@ public class SecurityIT extends BaseIT {
         condition.setConditionTypeId("profilePropertyCondition");
         condition.setParameter("propertyName", "@java.lang.Runtime@getRuntime().exec('touch " + vulnFile.getCanonicalPath() + "')");
         condition.setParameter("comparisonOperator", "equals");
-        condition.setParameter("propertyValue" , "script::java.io.PrintWriter writer = new java.io.PrintWriter(new java.io.BufferedWriter(new java.io.FileWriter(\"" + vulnFile.getCanonicalPath() + "\", true)));\nwriter.println(\"test\");\nwriter.close();");
+        condition.setParameter("propertyValue",
+                "script::java.io.PrintWriter writer = new java.io.PrintWriter(new java.io.BufferedWriter(new java.io.FileWriter(\""
+                        + vulnFile.getCanonicalPath() + "\", true)));\nwriter.println(\"test\");\nwriter.close();");
         filter.setCondition(condition);
         filters.add(filter);
         var1Content.setFilters(filters);
@@ -101,6 +103,4 @@ public class SecurityIT extends BaseIT {
         return TestUtils.executeContextJSONRequest(request, sessionId);
     }
 
-
-
 }
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 470a3cb57..221f975ac 100644
--- a/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
@@ -21,6 +21,7 @@ import org.apache.unomi.api.Event;
 import org.apache.unomi.api.Metadata;
 import org.apache.unomi.api.Profile;
 import org.apache.unomi.api.conditions.Condition;
+import org.apache.unomi.api.exceptions.BadSegmentConditionException;
 import org.apache.unomi.api.rules.Rule;
 import org.apache.unomi.api.segments.Scoring;
 import org.apache.unomi.api.segments.ScoringElement;
@@ -28,7 +29,6 @@ import org.apache.unomi.api.segments.Segment;
 import org.apache.unomi.api.services.EventService;
 import org.apache.unomi.api.services.ProfileService;
 import org.apache.unomi.api.services.SegmentService;
-import org.apache.unomi.api.exceptions.BadSegmentConditionException;
 import org.apache.unomi.persistence.spi.PersistenceService;
 import org.junit.After;
 import org.junit.Assert;
@@ -46,7 +46,11 @@ import javax.inject.Inject;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.ZoneId;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerSuite.class)
@@ -54,16 +58,20 @@ public class SegmentIT extends BaseIT {
     private final static Logger LOGGER = LoggerFactory.getLogger(SegmentIT.class);
     private final static String SEGMENT_ID = "test-segment-id-2";
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected SegmentService segmentService;
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected ProfileService profileService;
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected EventService eventService;
 
-    @Inject @Filter(timeout = 600000)
+    @Inject
+    @Filter(timeout = 600000)
     protected PersistenceService persistenceService;
 
     @Before
@@ -164,7 +172,8 @@ public class SegmentIT extends BaseIT {
         // send event for profile from a previous date (today -3 days)
         ZoneId defaultZoneId = ZoneId.systemDefault();
         LocalDate localDate = LocalDate.now().minusDays(3);
-        Event testEvent = new Event("test-event-type", null, profile, null, null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
+        Event testEvent = new Event("test-event-type", null, profile, null, null, profile,
+                Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
         testEvent.setPersistent(true);
         int changes = eventService.send(testEvent);
         if ((changes & EventService.PROFILE_UPDATED) == EventService.PROFILE_UPDATED) {
@@ -185,10 +194,8 @@ public class SegmentIT extends BaseIT {
         segmentService.setSegmentDefinition(segment);
 
         // 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"),
-                updatedProfile -> updatedProfile.getSegments().contains("past-event-segment-test"),
-                1000, 20);
+        keepTrying("Profile should be engaged in the segment", () -> profileService.load("test_profile_id"),
+                updatedProfile -> updatedProfile.getSegments().contains("past-event-segment-test"), 1000, 20);
     }
 
     @Test
@@ -214,8 +221,7 @@ public class SegmentIT extends BaseIT {
         // insure that profile is correctly engaged in sement since there is no events yet.
         keepTrying("Profile should be engaged in the segment, there is no event for the past condition yet",
                 () -> profileService.load("test_profile_id"),
-                updatedProfile -> updatedProfile.getSegments().contains("negative-past-event-segment-test"),
-                1000, 20);
+                updatedProfile -> updatedProfile.getSegments().contains("negative-past-event-segment-test"), 1000, 20);
 
         // we load the profile so that we are sure that it contains the segments
         profile = profileService.load("test_profile_id");
@@ -223,7 +229,8 @@ public class SegmentIT extends BaseIT {
         // send event for profile from a previous date (today -3 days)
         ZoneId defaultZoneId = ZoneId.systemDefault();
         LocalDate localDate = LocalDate.now().minusDays(3);
-        Event testEvent = new Event("negative-test-event-type", null, profile, null, null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
+        Event testEvent = new Event("negative-test-event-type", null, profile, null, null, profile,
+                Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
         testEvent.setPersistent(true);
         int changes = eventService.send(testEvent);
         if ((changes & EventService.PROFILE_UPDATED) == EventService.PROFILE_UPDATED) {
@@ -235,8 +242,7 @@ public class SegmentIT extends BaseIT {
         // now Profile should be out of the segment since one event have been done and the past event is only valid for no events occurrences
         keepTrying("Profile should not be engaged in the segment anymore, it have a least one event now",
                 () -> profileService.load("test_profile_id"),
-                updatedProfile -> !updatedProfile.getSegments().contains("negative-past-event-segment-test"),
-                1000, 20);
+                updatedProfile -> !updatedProfile.getSegments().contains("negative-past-event-segment-test"), 1000, 20);
     }
 
     @Test
@@ -263,7 +269,8 @@ public class SegmentIT extends BaseIT {
         // Persist the event (do not send it into the system so that it will not be processed by the rules)
         ZoneId defaultZoneId = ZoneId.systemDefault();
         LocalDate localDate = LocalDate.now().minusDays(3);
-        Event testEvent = new Event("test-event-type", null, profile, null, null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
+        Event testEvent = new Event("test-event-type", null, profile, null, null, profile,
+                Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
         testEvent.setPersistent(true);
         persistenceService.save(testEvent, null, true);
         persistenceService.refreshIndex(Event.class, testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
@@ -275,25 +282,22 @@ public class SegmentIT extends BaseIT {
         // now recalculate the past event conditions
         segmentService.recalculatePastEventConditions();
         persistenceService.refreshIndex(Profile.class, null);
-        keepTrying("Profile should be engaged in the segment",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> updatedProfile.getSegments().contains("past-event-segment-test"),
-                1000, 20);
+        keepTrying("Profile should be engaged in the segment", () -> profileService.load("test_profile_id"),
+                updatedProfile -> updatedProfile.getSegments().contains("past-event-segment-test"), 1000, 20);
 
         // update the event to a date out of the past event condition
         removeItems(Event.class);
         localDate = LocalDate.now().minusDays(15);
-        testEvent = new Event("test-event-type", null, profile, null, null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
+        testEvent = new Event("test-event-type", null, profile, null, null, profile,
+                Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
         persistenceService.save(testEvent);
         persistenceService.refreshIndex(Event.class, testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
 
         // now recalculate the past event conditions
         segmentService.recalculatePastEventConditions();
         persistenceService.refreshIndex(Profile.class, null);
-        keepTrying("Profile should not be engaged in the segment anymore",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> !updatedProfile.getSegments().contains("past-event-segment-test"),
-                1000, 20);
+        keepTrying("Profile should not be engaged in the segment anymore", () -> profileService.load("test_profile_id"),
+                updatedProfile -> !updatedProfile.getSegments().contains("past-event-segment-test"), 1000, 20);
     }
 
     @Test
@@ -307,7 +311,8 @@ public class SegmentIT extends BaseIT {
         // send event for profile from a previous date (today -3 days)
         ZoneId defaultZoneId = ZoneId.systemDefault();
         LocalDate localDate = LocalDate.now().minusDays(3);
-        Event testEvent = new Event("test-event-type", null, profile, null, null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
+        Event testEvent = new Event("test-event-type", null, profile, null, null, profile,
+                Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
         testEvent.setPersistent(true);
         int changes = eventService.send(testEvent);
         if ((changes & EventService.PROFILE_UPDATED) == EventService.PROFILE_UPDATED) {
@@ -335,12 +340,9 @@ public class SegmentIT extends BaseIT {
         segmentService.setScoringDefinition(scoring);
 
         // insure the profile that did the past event condition is correctly engaged in the scoring plan.
-        keepTrying("Profile should be engaged in the scoring with a score of 50",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> updatedProfile.getScores() != null &&
-                        updatedProfile.getScores().containsKey("past-event-scoring-test") &&
-                        updatedProfile.getScores().get("past-event-scoring-test") == 50,
-                1000, 20);
+        keepTrying("Profile should be engaged in the scoring with a score of 50", () -> profileService.load("test_profile_id"),
+                updatedProfile -> updatedProfile.getScores() != null && updatedProfile.getScores().containsKey("past-event-scoring-test")
+                        && updatedProfile.getScores().get("past-event-scoring-test") == 50, 1000, 20);
     }
 
     @Test
@@ -373,39 +375,37 @@ public class SegmentIT extends BaseIT {
         // Persist the event (do not send it into the system so that it will not be processed by the rules)
         ZoneId defaultZoneId = ZoneId.systemDefault();
         LocalDate localDate = LocalDate.now().minusDays(3);
-        Event testEvent = new Event("test-event-type", null, profile, null, null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
+        Event testEvent = new Event("test-event-type", null, profile, null, null, profile,
+                Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
         testEvent.setPersistent(true);
         persistenceService.save(testEvent, null, true);
         persistenceService.refreshIndex(Event.class, testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
 
         // insure the profile is not yet engaged since we directly saved the event in ES
         profile = profileService.load("test_profile_id");
-        Assert.assertTrue("Profile should not be engaged in the scoring", profile.getScores() == null || !profile.getScores().containsKey("past-event-scoring-test"));
+        Assert.assertTrue("Profile should not be engaged in the scoring",
+                profile.getScores() == null || !profile.getScores().containsKey("past-event-scoring-test"));
 
         // now recalculate the past event conditions
         segmentService.recalculatePastEventConditions();
         persistenceService.refreshIndex(Profile.class, null);
-        keepTrying("Profile should be engaged in the scoring with a score of 50",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> updatedProfile.getScores() != null &&
-                        updatedProfile.getScores().containsKey("past-event-scoring-test") &&
-                        updatedProfile.getScores().get("past-event-scoring-test") == 50,
-                1000, 20);
+        keepTrying("Profile should be engaged in the scoring with a score of 50", () -> profileService.load("test_profile_id"),
+                updatedProfile -> updatedProfile.getScores() != null && updatedProfile.getScores().containsKey("past-event-scoring-test")
+                        && updatedProfile.getScores().get("past-event-scoring-test") == 50, 1000, 20);
 
         // update the event to a date out of the past event condition
         removeItems(Event.class);
         localDate = LocalDate.now().minusDays(15);
-        testEvent = new Event("test-event-type", null, profile, null, null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
+        testEvent = new Event("test-event-type", null, profile, null, null, profile,
+                Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
         persistenceService.save(testEvent);
         persistenceService.refreshIndex(Event.class, testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
 
         // now recalculate the past event conditions
         segmentService.recalculatePastEventConditions();
         persistenceService.refreshIndex(Profile.class, null);
-        keepTrying("Profile should not be engaged in the scoring anymore",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> !updatedProfile.getScores().containsKey("past-event-scoring-test"),
-                1000, 20);
+        keepTrying("Profile should not be engaged in the scoring anymore", () -> profileService.load("test_profile_id"),
+                updatedProfile -> !updatedProfile.getScores().containsKey("past-event-scoring-test"), 1000, 20);
     }
 
     @Test
@@ -439,29 +439,30 @@ public class SegmentIT extends BaseIT {
         // Persist the event (do not send it into the system so that it will not be processed by the rules)
         ZoneId defaultZoneId = ZoneId.systemDefault();
         LocalDate localDate = LocalDate.now().minusDays(3);
-        Event testEvent = new Event("test-event-type-max", null, profile, null, null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
+        Event testEvent = new Event("test-event-type-max", null, profile, null, null, profile,
+                Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
         testEvent.setPersistent(true);
         persistenceService.save(testEvent, null, true);
         persistenceService.refreshIndex(Event.class, testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
 
         // insure the profile is not yet engaged since we directly saved the event in ES
         profile = profileService.load("test_profile_id");
-        Assert.assertTrue("Profile should not be engaged in the scoring", profile.getScores() == null || !profile.getScores().containsKey("past-event-scoring-test-max"));
+        Assert.assertTrue("Profile should not be engaged in the scoring",
+                profile.getScores() == null || !profile.getScores().containsKey("past-event-scoring-test-max"));
 
         // now recalculate the past event conditions
         segmentService.recalculatePastEventConditions();
         persistenceService.refreshIndex(Profile.class, null);
-        keepTrying("Profile should be engaged in the scoring with a score of 50",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> updatedProfile.getScores() != null &&
-                        updatedProfile.getScores().containsKey("past-event-scoring-test-max") &&
-                        updatedProfile.getScores().get("past-event-scoring-test-max") == 50,
+        keepTrying("Profile should be engaged in the scoring with a score of 50", () -> profileService.load("test_profile_id"),
+                updatedProfile -> updatedProfile.getScores() != null && updatedProfile.getScores()
+                        .containsKey("past-event-scoring-test-max") && updatedProfile.getScores().get("past-event-scoring-test-max") == 50,
                 1000, 20);
 
         // Persist the 2 event (do not send it into the system so that it will not be processed by the rules)
         defaultZoneId = ZoneId.systemDefault();
         localDate = LocalDate.now().minusDays(3);
-        testEvent = new Event("test-event-type-max", null, profile, null, null, profile, Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
+        testEvent = new Event("test-event-type-max", null, profile, null, null, profile,
+                Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
         testEvent.setPersistent(true);
         persistenceService.save(testEvent, null, true);
         persistenceService.refreshIndex(Event.class, testEvent.getTimeStamp()); // wait for event to be fully persisted and indexed
@@ -469,10 +470,8 @@ public class SegmentIT extends BaseIT {
         // now recalculate the past event conditions
         segmentService.recalculatePastEventConditions();
         persistenceService.refreshIndex(Profile.class, null);
-        keepTrying("Profile should not be engaged in the scoring anymore",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> !updatedProfile.getScores().containsKey("past-event-scoring-test-max"),
-                1000, 20);
+        keepTrying("Profile should not be engaged in the scoring anymore", () -> profileService.load("test_profile_id"),
+                updatedProfile -> !updatedProfile.getScores().containsKey("past-event-scoring-test-max"), 1000, 20);
     }
 
     @Test
@@ -489,8 +488,9 @@ public class SegmentIT extends BaseIT {
         pastEventCondition.setParameter("minimumEventCount", 1);
         pastEventCondition.setParameter("maximumEventCount", 2);
 
-        pastEventCondition.setParameter("fromDate","2000-07-15T07:00:00Z");
-        pastEventCondition.setParameter("toDate","2001-01-15T07:00:00Z");;
+        pastEventCondition.setParameter("fromDate", "2000-07-15T07:00:00Z");
+        pastEventCondition.setParameter("toDate", "2001-01-15T07:00:00Z");
+        ;
         Condition pastEventEventCondition = new Condition(definitionsService.getConditionType("eventTypeCondition"));
         pastEventEventCondition.setParameter("eventTypeId", "test-event-type");
         pastEventCondition.setParameter("eventCondition", pastEventEventCondition);
@@ -520,8 +520,11 @@ public class SegmentIT extends BaseIT {
 
         // insure the profile is engaged;
         try {
-            Assert.assertTrue("Profile should have 2 events in the scoring",  (Long) ((Map) testEvent.getProfile().getSystemProperties().get("pastEvents")).get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2);
-            Assert.assertTrue("Profile is engaged",  testEvent.getProfile().getScores().containsKey("past-event-scoring-test") && testEvent.getProfile().getScores().get("past-event-scoring-test") == 50);
+            Assert.assertTrue("Profile should have 2 events in the scoring",
+                    (Long) ((Map) testEvent.getProfile().getSystemProperties().get("pastEvents"))
+                            .get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2);
+            Assert.assertTrue("Profile is engaged", testEvent.getProfile().getScores().containsKey("past-event-scoring-test")
+                    && testEvent.getProfile().getScores().get("past-event-scoring-test") == 50);
         } catch (Exception e) {
             Assert.fail("Unable to read past event because " + e.getMessage());
         }
@@ -530,20 +533,19 @@ public class SegmentIT extends BaseIT {
         // recalculate event conditions
         segmentService.recalculatePastEventConditions();
         // insure the profile is still engaged after recalculate;
-        keepTrying("Profile should have 2 events in the scoring",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> {
-                    try {
-                        boolean eventCounted = (Integer) ((Map) updatedProfile.getSystemProperties().get("pastEvents")).get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2;
-                        boolean profileEngaged = updatedProfile.getScores().containsKey("past-event-scoring-test") && updatedProfile.getScores().get("past-event-scoring-test") == 50;
-                        return eventCounted && profileEngaged;
-                    } catch (Exception e) {
-                        // Do nothing, unable to read value
-                    };
-                    return false;
-                },
-                1000, 20);
-
+        keepTrying("Profile should have 2 events in the scoring", () -> profileService.load("test_profile_id"), updatedProfile -> {
+            try {
+                boolean eventCounted = (Integer) ((Map) updatedProfile.getSystemProperties().get("pastEvents"))
+                        .get(pastEventCondition.getParameterValues().get("generatedPropertyKey")) == 2;
+                boolean profileEngaged = updatedProfile.getScores().containsKey("past-event-scoring-test")
+                        && updatedProfile.getScores().get("past-event-scoring-test") == 50;
+                return eventCounted && profileEngaged;
+            } catch (Exception e) {
+                // Do nothing, unable to read value
+            }
+            ;
+            return false;
+        }, 1000, 20);
 
         // Add one more event
         testEvent = new Event("test-event-type", null, testEvent.getProfile(), null, null, testEvent.getProfile(), timestampEventInRange);
@@ -561,17 +563,15 @@ public class SegmentIT extends BaseIT {
         segmentService.recalculatePastEventConditions();
         persistenceService.refreshIndex(Profile.class, null);
         // As 3 events have match, the profile should not be part of the scoring plan.
-        keepTrying("Profile should not be part of the scoring anymore",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> {
-                    try {
-                        return updatedProfile.getScores().get("past-event-scoring-test") == 0;
-                    } catch (Exception e) {
-                        // Do nothing, unable to read value
-                    };
-                    return false;
-                },
-                1000, 20);
+        keepTrying("Profile should not be part of the scoring anymore", () -> profileService.load("test_profile_id"), updatedProfile -> {
+            try {
+                return updatedProfile.getScores().get("past-event-scoring-test") == 0;
+            } catch (Exception e) {
+                // Do nothing, unable to read value
+            }
+            ;
+            return false;
+        }, 1000, 20);
     }
 
     @Test
@@ -602,7 +602,8 @@ public class SegmentIT extends BaseIT {
         refreshPersistence();
         // Check linkedItems
         List<Rule> rules = persistenceService.getAllItems(Rule.class);
-        Rule scoringRule = rules.stream().filter(rule -> rule.getItemId().equals(pastEventCondition.getParameter("generatedPropertyKey"))).findFirst().get();
+        Rule scoringRule = rules.stream().filter(rule -> rule.getItemId().equals(pastEventCondition.getParameter("generatedPropertyKey")))
+                .findFirst().get();
         Assert.assertEquals("Scoring linked Item should be one", 1, scoringRule.getLinkedItems().size());
 
         // save the scoring once again
@@ -610,7 +611,8 @@ public class SegmentIT extends BaseIT {
         refreshPersistence();
         // Check linkedItems
         rules = persistenceService.getAllItems(Rule.class);
-        scoringRule = rules.stream().filter(rule -> rule.getItemId().equals(pastEventCondition.getParameter("generatedPropertyKey"))).findFirst().get();
+        scoringRule = rules.stream().filter(rule -> rule.getItemId().equals(pastEventCondition.getParameter("generatedPropertyKey")))
+                .findFirst().get();
         Assert.assertEquals("Scoring linked Item should be one", 1, scoringRule.getLinkedItems().size());
 
         // Remove scoring
@@ -663,7 +665,8 @@ public class SegmentIT extends BaseIT {
         // insure the profile is not yet engaged since we directly saved the profile in ES
         profile = profileService.load("test_profile_id");
         Assert.assertFalse("Profile should not be engaged in the segment", profile.getSegments().contains("relative-date-segment-test"));
-        Assert.assertTrue("Profile should not be engaged in the scoring", profile.getScores() == null || !profile.getScores().containsKey("relative-date-scoring-test"));
+        Assert.assertTrue("Profile should not be engaged in the scoring",
+                profile.getScores() == null || !profile.getScores().containsKey("relative-date-scoring-test"));
 
         // Update the profile last visit to match the segment ans the scoring
         ZoneId defaultZoneId = ZoneId.systemDefault();
@@ -675,15 +678,15 @@ public class SegmentIT extends BaseIT {
         // insure the profile is not yet engaged since we directly saved the profile in ES
         profile = profileService.load("test_profile_id");
         Assert.assertFalse("Profile should not be engaged in the segment", profile.getSegments().contains("relative-date-segment-test"));
-        Assert.assertTrue("Profile should not be engaged in the scoring", profile.getScores() == null || profile.getScores().containsKey("relative-date-scoring-test"));
+        Assert.assertTrue("Profile should not be engaged in the scoring",
+                profile.getScores() == null || profile.getScores().containsKey("relative-date-scoring-test"));
 
         // now force the recalculation of the date relative segments/scorings
         segmentService.recalculatePastEventConditions();
         persistenceService.refreshIndex(Profile.class, null);
-        keepTrying("Profile should be engaged in the segment and scoring",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> updatedProfile.getSegments().contains("relative-date-segment-test") && updatedProfile.getScores() != null && updatedProfile.getScores().get("relative-date-scoring-test") == 5,
-                1000, 20);
+        keepTrying("Profile should be engaged in the segment and scoring", () -> profileService.load("test_profile_id"),
+                updatedProfile -> updatedProfile.getSegments().contains("relative-date-segment-test") && updatedProfile.getScores() != null
+                        && updatedProfile.getScores().get("relative-date-scoring-test") == 5, 1000, 20);
 
         // update the profile to a date out of date expression
         localDate = LocalDate.now().minusDays(15);
@@ -694,9 +697,9 @@ public class SegmentIT extends BaseIT {
         // now force the recalculation of the date relative segments/scorings
         segmentService.recalculatePastEventConditions();
         persistenceService.refreshIndex(Profile.class, null);
-        keepTrying("Profile should not be engaged in the segment and scoring anymore",
-                () -> profileService.load("test_profile_id"),
-                updatedProfile -> !updatedProfile.getSegments().contains("relative-date-segment-test") && (updatedProfile.getScores() == null || !updatedProfile.getScores().containsKey("relative-date-scoring-test")),
-                1000, 20);
+        keepTrying("Profile should not be engaged in the segment and scoring anymore", () -> profileService.load("test_profile_id"),
+                updatedProfile -> !updatedProfile.getSegments().contains("relative-date-segment-test") && (
+                        updatedProfile.getScores() == null || !updatedProfile.getScores().containsKey("relative-date-scoring-test")), 1000,
+                20);
     }
-}
\ No newline at end of file
+}
diff --git a/itests/src/test/resources/schemas/events/float-property-type.json b/itests/src/test/resources/schemas/events/float-property-type.json
index ca09db1da..92374e5a4 100644
--- a/itests/src/test/resources/schemas/events/float-property-type.json
+++ b/itests/src/test/resources/schemas/events/float-property-type.json
@@ -3,7 +3,8 @@
   "$schema": "https://json-schema.org/draft/2019-09/schema",
   "self":{
     "vendor":"org.apache.unomi",
-    "name":"events/float-property-type",
+    "target" : "events",
+    "name":"float-property-type",
     "format":"jsonschema",
     "version":"1-0-0"
   },
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/anonymizeProfile.json b/services/src/main/resources/META-INF/cxs/schemas/events/anonymizeProfile.json
new file mode 100644
index 000000000..bdfabc0fa
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/anonymizeProfile.json
@@ -0,0 +1,19 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/anonymizeProfile/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "anonymizeProfile",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "AnonymizeProfileEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/profile/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/articleCompleted.json b/services/src/main/resources/META-INF/cxs/schemas/events/articleCompleted.json
new file mode 100644
index 000000000..d493adf5e
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/articleCompleted.json
@@ -0,0 +1,30 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/articleCompleted/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "articleCompleted",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "AnonimyzeProfileEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "properties" : {
+      "type" : "object",
+      "properties" : {
+        "consent" : {
+          "$ref" : "https://unomi.apache.org/schemas/json/consent/1-0-0"
+        }
+      }
+    },
+    "source" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitems/page/1-0-0"
+    },
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitem/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/goal.json b/services/src/main/resources/META-INF/cxs/schemas/events/goal.json
new file mode 100644
index 000000000..3c5a289ff
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/goal.json
@@ -0,0 +1,30 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/goal/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "goal",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "GoalEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "properties" : {
+      "type" : "object",
+      "properties" : {
+        "consent" : {
+          "$ref" : "https://unomi.apache.org/schemas/json/consent/1-0-0"
+        }
+      }
+    },
+    "source" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitems/page/1-0-0"
+    },
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitem/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/identify.json b/services/src/main/resources/META-INF/cxs/schemas/events/identify.json
new file mode 100644
index 000000000..657235b43
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/identify.json
@@ -0,0 +1,30 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/identify/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "identify",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "IdentifyEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "properties" : {
+      "type" : "object",
+      "properties" : {
+        "consent" : {
+          "$ref" : "https://unomi.apache.org/schemas/json/consent/1-0-0"
+        }
+      }
+    },
+    "source" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitems/page/1-0-0"
+    },
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitem/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/incrementInterest.json b/services/src/main/resources/META-INF/cxs/schemas/events/incrementInterest.json
new file mode 100644
index 000000000..8ae788cc9
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/incrementInterest.json
@@ -0,0 +1,30 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/incrementInterest/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "incrementInterest",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "IncrementInterestEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "properties" : {
+      "type" : "object",
+      "properties" : {
+        "consent" : {
+          "$ref" : "https://unomi.apache.org/schemas/json/consent/1-0-0"
+        }
+      }
+    },
+    "source" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitems/page/1-0-0"
+    },
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitem/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/profileDeleted.json b/services/src/main/resources/META-INF/cxs/schemas/events/profileDeleted.json
new file mode 100644
index 000000000..d6534d381
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/profileDeleted.json
@@ -0,0 +1,19 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/profileDeleted/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "profileDeleted",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "ProfileDeletedEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/profile/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/profileUpdated.json b/services/src/main/resources/META-INF/cxs/schemas/events/profileUpdated.json
new file mode 100644
index 000000000..b936cddfe
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/profileUpdated.json
@@ -0,0 +1,19 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/profileUpdated/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "profileUpdated",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "ProfileUpdatedEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/profile/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/ruleFired.json b/services/src/main/resources/META-INF/cxs/schemas/events/ruleFired.json
new file mode 100644
index 000000000..615eb8149
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/ruleFired.json
@@ -0,0 +1,30 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/ruleFired/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "ruleFired",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "RuleFiredEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "properties" : {
+      "type" : "object",
+      "properties" : {
+        "consent" : {
+          "$ref" : "https://unomi.apache.org/schemas/json/consent/1-0-0"
+        }
+      }
+    },
+    "source" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitems/page/1-0-0"
+    },
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitem/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/search.json b/services/src/main/resources/META-INF/cxs/schemas/events/search.json
new file mode 100644
index 000000000..4804547f4
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/search.json
@@ -0,0 +1,30 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/search/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "search",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "SearchEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "properties" : {
+      "type" : "object",
+      "properties" : {
+        "consent" : {
+          "$ref" : "https://unomi.apache.org/schemas/json/consent/1-0-0"
+        }
+      }
+    },
+    "source" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitems/page/1-0-0"
+    },
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitem/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/sessionCreated.json b/services/src/main/resources/META-INF/cxs/schemas/events/sessionCreated.json
new file mode 100644
index 000000000..514967471
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/sessionCreated.json
@@ -0,0 +1,30 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/sessionCreated/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "sessionCreated",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "SessionCreatedEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "properties" : {
+      "type" : "object",
+      "properties" : {
+        "consent" : {
+          "$ref" : "https://unomi.apache.org/schemas/json/consent/1-0-0"
+        }
+      }
+    },
+    "source" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitems/page/1-0-0"
+    },
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitem/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/sessionReassigned.json b/services/src/main/resources/META-INF/cxs/schemas/events/sessionReassigned.json
new file mode 100644
index 000000000..7a7f338c0
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/sessionReassigned.json
@@ -0,0 +1,30 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/sessionReassigned/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "sessionReassigned",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "SessionReassignedEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "properties" : {
+      "type" : "object",
+      "properties" : {
+        "consent" : {
+          "$ref" : "https://unomi.apache.org/schemas/json/consent/1-0-0"
+        }
+      }
+    },
+    "source" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitems/page/1-0-0"
+    },
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitem/1-0-0"
+    }
+  }
+}
\ No newline at end of file
diff --git a/services/src/main/resources/META-INF/cxs/schemas/events/updateProperties.json b/services/src/main/resources/META-INF/cxs/schemas/events/updateProperties.json
new file mode 100644
index 000000000..4cd408ed4
--- /dev/null
+++ b/services/src/main/resources/META-INF/cxs/schemas/events/updateProperties.json
@@ -0,0 +1,30 @@
+{
+  "$id": "https://unomi.apache.org/schemas/json/events/updateProperties/1-0-0",
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "self":{
+    "vendor":"org.apache.unomi",
+    "target" : "events",
+    "name": "updateProperties",
+    "format":"jsonschema",
+    "version":"1-0-0"
+  },
+  "title": "UpdatePropertiesEvent",
+  "type": "object",
+  "allOf": [{ "$ref": "https://unomi.apache.org/schemas/json/event/1-0-0" }],
+  "properties" : {
+    "properties" : {
+      "type" : "object",
+      "properties" : {
+        "consent" : {
+          "$ref" : "https://unomi.apache.org/schemas/json/consent/1-0-0"
+        }
+      }
+    },
+    "source" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitems/page/1-0-0"
+    },
+    "target" : {
+      "$ref" : "https://unomi.apache.org/schemas/json/customitem/1-0-0"
+    }
+  }
+}
\ No newline at end of file