You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2020/07/27 08:04:32 UTC
[unomi] branch unomi-1.5.x updated (26504d0 -> 456091c)
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a change to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git.
from 26504d0 Fix cases where property is in Date format.
new deb906f Porting ITest fixes
new e4cdce0 fix(SetEventOccurenceCountAction) - fix future timestamp check
new 6d87742 feat(org.apache.unomi.services.cfg) - add an environment variable for a configuration property
new 29f603a refresh profile index
new 1bad997 Add profileId to the ContextRequest, and create profile with this id if provided
new 9e18dd4 Fix compilation issue in Windows
new fe4f09c Add itests for sending a new event with profile id
new d7ab62e UNOMI-363 add consent mapping
new f70ec42 UNOMI-363 add consent mapping in the profile.json
new d2b905f UNOMI-363 Fix mappings
new 456091c Fix unit test by not re-using event IDs
The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../java/org/apache/unomi/api/ContextRequest.java | 18 ++++++
.../test/java/org/apache/unomi/itests/BaseIT.java | 43 ++++++++++----
.../org/apache/unomi/itests/ContextServletIT.java | 69 +++++++++++++++++++---
.../apache/unomi/itests/ProfileImportActorsIT.java | 33 ++++++++---
.../unomi/itests/ProfileImportRankingIT.java | 22 +++++--
.../unomi/itests/ProfileImportSurfersIT.java | 33 +++++++----
.../java/org/apache/unomi/itests/TestUtils.java | 23 ++++++--
.../main/resources/etc/custom.system.properties | 2 +
.../ElasticSearchPersistenceServiceImpl.java | 17 +++++-
.../resources/META-INF/cxs/mappings/profile.json | 16 ++++-
.../unomi/persistence/spi/PersistenceService.java | 9 +++
.../actions/SetEventOccurenceCountAction.java | 4 +-
.../conditions/PropertyConditionEvaluatorTest.java | 26 ++++----
.../services/impl/profiles/ProfileServiceImpl.java | 6 +-
.../main/resources/org.apache.unomi.services.cfg | 3 +
.../java/org/apache/unomi/web/ContextServlet.java | 26 +++++---
16 files changed, 271 insertions(+), 79 deletions(-)
[unomi] 11/11: Fix unit test by not re-using event IDs
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit 456091cb9f851addae205e0d09af99b64c0690af
Author: Serge Huber <sh...@apache.org>
AuthorDate: Tue Jul 21 16:12:01 2020 +0200
Fix unit test by not re-using event IDs
(cherry picked from commit 7c8144a589df75487512b1c920ad3ba145ff9b18)
---
itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 0587a21..d4cfd63 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
@@ -323,7 +323,7 @@ public class ContextServletIT extends BaseIT {
@Test
public void testCreateEventWithProfileId_Success() throws IOException, InterruptedException {
//Arrange
- String eventId = "test-event-id1";
+ String eventId = "test-event-id4";
String profileId = "test-profile-id";
String eventType = "test-event-type";
Event event = new Event();
[unomi] 05/11: Add profileId to the ContextRequest,
and create profile with this id if provided
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit 1bad997aae5c7e39b3f04e48feb16c263f701b81
Author: Shir <sb...@yotpo.com>
AuthorDate: Tue Jul 7 16:59:37 2020 +0300
Add profileId to the ContextRequest, and create profile with this id if provided
(cherry picked from commit 749a52ff9345bb21ece54a1cc6efb44984387c77)
---
.../java/org/apache/unomi/api/ContextRequest.java | 18 ++++++++++++++++++
.../java/org/apache/unomi/web/ContextServlet.java | 20 ++++++++++++--------
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/api/src/main/java/org/apache/unomi/api/ContextRequest.java b/api/src/main/java/org/apache/unomi/api/ContextRequest.java
index 6a6c79a..1a59dde 100644
--- a/api/src/main/java/org/apache/unomi/api/ContextRequest.java
+++ b/api/src/main/java/org/apache/unomi/api/ContextRequest.java
@@ -64,6 +64,7 @@ public class ContextRequest {
private Profile profileOverrides;
private Map<String, Object> sessionPropertiesOverrides;
private String sessionId;
+ private String profileId;
/**
* Retrieves the source of the context request.
@@ -242,4 +243,21 @@ public class ContextRequest {
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
+
+ /**
+ * Retrieve the profileId passed along with the request. All events will be processed with this profileId as a
+ * default
+ * @return the identifier for the profile
+ */
+ public String getProfileId() {
+ return profileId;
+ }
+
+ /**
+ * Sets the profileId in the request.
+ * @param profileId an unique identifier for the profile
+ */
+ public void setProfileId(String profileId) {
+ this.profileId = profileId;
+ }
}
diff --git a/wab/src/main/java/org/apache/unomi/web/ContextServlet.java b/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
index 3604162..1557f5a 100644
--- a/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
+++ b/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
@@ -107,6 +107,7 @@ public class ContextServlet extends HttpServlet {
ContextRequest contextRequest = null;
String scope = null;
String sessionId = null;
+ String profileId = null;
String stringPayload = HttpUtils.getPayload(request);
if (stringPayload != null) {
ObjectMapper mapper = CustomObjectMapper.getObjectMapper();
@@ -122,18 +123,21 @@ public class ContextServlet extends HttpServlet {
scope = contextRequest.getSource().getScope();
}
sessionId = contextRequest.getSessionId();
+ profileId = contextRequest.getProfileId();
}
if (sessionId == null) {
sessionId = request.getParameter("sessionId");
}
- // Get profile id from the cookie
- String cookieProfileId = ServletCommon.getProfileIdCookieValue(request, profileIdCookieName);
+ if (profileId == null) {
+ // Get profile id from the cookie
+ profileId = ServletCommon.getProfileIdCookieValue(request, profileIdCookieName);
+ }
- if (cookieProfileId == null && sessionId == null && personaId == null) {
+ if (profileId == null && sessionId == null && personaId == null) {
((HttpServletResponse)response).sendError(HttpServletResponse.SC_BAD_REQUEST, "Check logs for more details");
- logger.error("Couldn't find cookieProfileId, sessionId or personaId in incoming request! Stopped processing request. See debug level for more information");
+ logger.error("Couldn't find profileId, sessionId or personaId in incoming request! Stopped processing request. See debug level for more information");
if (logger.isDebugEnabled()) {
logger.debug("Request dump: {}", HttpUtils.dumpRequestInfo(request));
}
@@ -147,16 +151,16 @@ public class ContextServlet extends HttpServlet {
boolean invalidateProfile = request.getParameter("invalidateProfile") != null ?
new Boolean(request.getParameter("invalidateProfile")) : false;
- if (cookieProfileId == null || invalidateProfile) {
+ if (profileId == null || invalidateProfile) {
// no profileId cookie was found or the profile has to be invalidated, we generate a new one and create the profile in the profile service
profile = createNewProfile(null, response, timestamp);
profileCreated = true;
} else {
- profile = profileService.load(cookieProfileId);
+ profile = profileService.load(profileId);
if (profile == null) {
// this can happen if we have an old cookie but have reset the server,
// or if we merged the profiles and somehow this cookie didn't get updated.
- profile = createNewProfile(null, response, timestamp);
+ profile = createNewProfile(profileId, response, timestamp);
profileCreated = true;
} else {
Changes changesObject = checkMergedProfile(response, profile, session);
@@ -324,7 +328,7 @@ public class ContextServlet extends HttpServlet {
}
private Changes handleRequest(ContextRequest contextRequest, Session session, Profile profile, ContextResponse data,
- ServletRequest request, ServletResponse response, Date timestamp) {
+ ServletRequest request, ServletResponse response, Date timestamp) {
Changes changes = ServletCommon.handleEvents(contextRequest.getEvents(), session, profile, request, response, timestamp,
privacyService, eventService);
data.setProcessedEvents(changes.getProcessedItems());
[unomi] 10/11: UNOMI-363 Fix mappings
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit d2b905f92159a9836dacd9fdde8b353d771f194b
Author: Serge Huber <sh...@apache.org>
AuthorDate: Tue Jul 21 13:32:46 2020 +0200
UNOMI-363 Fix mappings
(cherry picked from commit ff3558d726481ff04a40e241174b3529a25f1c78)
---
.../core/src/main/resources/META-INF/cxs/mappings/profile.json | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json
index 2911216..a484d91 100644
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json
+++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json
@@ -39,15 +39,6 @@
},
"consents": {
"properties": {
- "scope": {
- "type": "string"
- },
- "typeIdentifier": {
- "type": "string"
- },
- "status": {
- "type": "string"
- },
"statusDate": {
"type": "date"
},
[unomi] 04/11: refresh profile index
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit 29f603a7f82ae96519f88abcbce7ba17c4df6475
Author: Gilad Weinbach <gw...@yotpo.com>
AuthorDate: Mon Jun 29 18:35:12 2020 +0300
refresh profile index
(cherry picked from commit 554ea6e6993ed0e268f7c23e5e7ecb332f3a72dc)
---
.../ElasticSearchPersistenceServiceImpl.java | 17 ++++++++++++++++-
.../unomi/persistence/spi/PersistenceService.java | 9 +++++++++
.../services/impl/profiles/ProfileServiceImpl.java | 6 ++----
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
index 456a930..aef7b34 100644
--- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
+++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
@@ -1732,7 +1732,6 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
return routing;
}
-
@Override
public void refresh() {
new InClassLoaderExecute<Boolean>(metricsService, this.getClass().getName() + ".refresh") {
@@ -1748,10 +1747,26 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService,
return true;
}
}.catchingExecuteInClassLoader(true);
+ }
+ @Override
+ public <T extends Item> void refreshIndex(Class<T> clazz, Date dateHint){
+ new InClassLoaderExecute<Boolean>(metricsService, this.getClass().getName() + ".refreshIndex") {
+ protected Boolean execute(Object... args) {
+ try {
+ String itemType = Item.getItemType(clazz);
+ String index = getIndex(itemType, dateHint);
+ client.indices().refresh(Requests.refreshRequest(index), RequestOptions.DEFAULT);
+ } catch (IOException e) {
+ e.printStackTrace();//TODO manage ES7
+ }
+ return true;
+ }
+ }.catchingExecuteInClassLoader(true);
}
+
@Override
public void purge(final Date date) {
new InClassLoaderExecute<Object>(metricsService, this.getClass().getName() + ".purgeWithDate") {
diff --git a/persistence-spi/src/main/java/org/apache/unomi/persistence/spi/PersistenceService.java b/persistence-spi/src/main/java/org/apache/unomi/persistence/spi/PersistenceService.java
index 7311353..80bf444 100644
--- a/persistence-spi/src/main/java/org/apache/unomi/persistence/spi/PersistenceService.java
+++ b/persistence-spi/src/main/java/org/apache/unomi/persistence/spi/PersistenceService.java
@@ -443,6 +443,15 @@ public interface PersistenceService {
void refresh();
/**
+ * Updates the persistence's engine specific index.
+ *
+ * @param clazz will use an index by class type
+ * @param dateHint for index with time, can be null
+ * @param <T> a class that extends Item
+ */
+ <T extends Item> void refreshIndex(Class<T> clazz, Date dateHint);
+
+ /**
* Purges all data in the context server up to the specified date, not included.
*
* @param date the date (not included) before which we want to erase all data
diff --git a/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java
index c0269ed..42873ea 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java
@@ -524,11 +524,9 @@ public class ProfileServiceImpl implements ProfileService, SynchronousBundleList
profile.setSystemProperty("lastUpdated", new Date());
if (persistenceService.save(profile)) {
if (forceRefresh) {
- // triggering a load will force an in-place refresh, that may be expensive in performance but will make data immediately available.
- return persistenceService.load(profile.getItemId(), Profile.class);
- } else {
- return profile;
+ persistenceService.refreshIndex(Profile.class, null);
}
+ return profile;
}
return null;
}
[unomi] 02/11: fix(SetEventOccurenceCountAction) - fix future
timestamp check
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit e4cdce082890b8d247fc4dbeb59f1f75ae6842ef
Author: nlevitsky <nl...@yotpo.com>
AuthorDate: Sun Jun 14 17:40:09 2020 +0300
fix(SetEventOccurenceCountAction) - fix future timestamp check
(cherry picked from commit 88ac76cb0393bd65832dd3411b6abd0b0ccc37b0)
---
.../plugins/baseplugin/actions/SetEventOccurenceCountAction.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetEventOccurenceCountAction.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetEventOccurenceCountAction.java
index 3c4e6f2..d3e80b9 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetEventOccurenceCountAction.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetEventOccurenceCountAction.java
@@ -90,8 +90,8 @@ public class SetEventOccurenceCountAction implements ActionExecutor {
//Only increase the counter by 1 if the current event is in the now-numberOfDays range
LocalDateTime now = LocalDateTime.now(ZoneId.of("UTC"));
LocalDateTime eventTime = LocalDateTime.ofInstant(event.getTimeStamp().toInstant(),ZoneId.of("UTC"));
- long daysDiff = Duration.between(eventTime,now).toDays();
- if (daysDiff >= 0 && daysDiff <= numberOfDays) {
+ Duration durationDiff = Duration.between(eventTime,now);
+ if (!durationDiff.isNegative() && durationDiff.toDays() <= numberOfDays) {
count++;
}
[unomi] 01/11: Porting ITest fixes
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit deb906fad6b106200e75c69728394071fa3fc4dc
Author: Serge Huber <sh...@jahia.com>
AuthorDate: Mon Jul 27 09:53:27 2020 +0200
Porting ITest fixes
---
.../test/java/org/apache/unomi/itests/BaseIT.java | 43 +++++++++++++++++-----
.../org/apache/unomi/itests/ContextServletIT.java | 42 ++++++++++++++++-----
.../apache/unomi/itests/ProfileImportActorsIT.java | 33 +++++++++++++----
.../unomi/itests/ProfileImportRankingIT.java | 22 ++++++++---
.../unomi/itests/ProfileImportSurfersIT.java | 33 +++++++++++------
.../java/org/apache/unomi/itests/TestUtils.java | 12 +++++-
.../java/org/apache/unomi/web/ContextServlet.java | 6 ++-
7 files changed, 145 insertions(+), 46 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 6651562..f6c35e4 100644
--- a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
@@ -17,6 +17,10 @@
package org.apache.unomi.itests;
+import org.apache.unomi.api.Item;
+import org.apache.unomi.api.conditions.Condition;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.persistence.spi.PersistenceService;
import org.junit.Assert;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
@@ -24,9 +28,10 @@ import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.karaf.container.internal.JavaVersionUtil;
import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
-import org.ops4j.pax.exam.options.MavenUrlReference;
import org.ops4j.pax.exam.options.extra.VMOption;
+import org.ops4j.pax.exam.util.Filter;
+import javax.inject.Inject;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@@ -36,7 +41,12 @@ import java.util.function.Supplier;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.*;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile;
/**
* Base class for integration tests.
@@ -50,6 +60,27 @@ public abstract class BaseIT {
protected static final String KARAF_DIR = "target/exam";
protected static final String UNOMI_KEY = "670c26d1cc413346c3b2fd9ce65dab41";
+ @Inject
+ @Filter(timeout = 600000)
+ protected PersistenceService persistenceService;
+
+ @Inject
+ @Filter(timeout = 600000)
+ protected DefinitionsService definitionsService;
+
+ protected void removeItems(final Class<? extends Item> ...classes) throws InterruptedException {
+ Condition condition = new Condition(definitionsService.getConditionType("matchAllCondition"));
+ for (Class<? extends Item> aClass : classes) {
+ persistenceService.removeByQuery(condition, aClass);
+ }
+ refreshPersistence();
+ }
+
+ protected void refreshPersistence() throws InterruptedException {
+ persistenceService.refresh();
+ Thread.sleep(1000);
+ }
+
@Configuration
public Option[] config() throws InterruptedException {
@@ -59,13 +90,6 @@ public abstract class BaseIT {
.type("tar.gz")
.versionAsInProject();
- MavenUrlReference routerRepo = maven()
- .groupId("org.apache.unomi")
- .artifactId("unomi-router-karaf-feature")
- .classifier("features")
- .type("xml")
- .versionAsInProject();
-
List<Option> options = new ArrayList<>();
Option[] commonOptions = new Option[]{
@@ -109,7 +133,6 @@ public abstract class BaseIT {
systemProperty("org.apache.unomi.hazelcast.tcp-ip.members").value("127.0.0.1"),
systemProperty("org.apache.unomi.hazelcast.tcp-ip.interface").value("127.0.0.1"),
systemProperty("unomi.autoStart").value("true"),
- features(routerRepo, "unomi-router-karaf-feature"),
CoreOptions.bundleStartLevel(100),
CoreOptions.frameworkStartLevel(100)
};
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 926627b..307a38e 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
@@ -21,7 +21,12 @@ 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.Segment;
import org.apache.unomi.api.services.DefinitionsService;
@@ -87,6 +92,8 @@ public class ContextServletIT extends BaseIT {
@Filter(timeout = 600000)
protected SegmentService segmentService;
+ private Profile profile;
+
@Before
public void setUp() throws InterruptedException {
//Create a past-event segment
@@ -100,7 +107,12 @@ public class ContextServletIT extends BaseIT {
segmentCondition.setParameter("eventCondition",pastEventEventCondition);
segment.setCondition(segmentCondition);
segmentService.setSegmentDefinition(segment);
- Thread.sleep(2000);
+
+ String profileId = "test-profile-id";
+ profile = new Profile(profileId);
+ profileService.save(profile);
+
+ refreshPersistence();
}
@After
@@ -108,8 +120,8 @@ public class ContextServletIT extends BaseIT {
TestUtils.removeAllEvents(definitionsService, persistenceService);
TestUtils.removeAllSessions(definitionsService, persistenceService);
TestUtils.removeAllProfiles(definitionsService, persistenceService);
+ profileService.delete(profile.getItemId(), false);
segmentService.removeSegmentDefinition(SEGMENT_ID,false);
- persistenceService.refresh();
}
@Test
@@ -126,6 +138,7 @@ public class ContextServletIT extends BaseIT {
Event event = new Event(eventId, eventTypeOriginal, session, profile, scope, null, null, new Date());
profileService.save(profile);
this.eventService.send(event);
+ refreshPersistence();
Thread.sleep(2000);
event.setEventType(eventTypeUpdated); //change the event so we can see the update effect
@@ -137,6 +150,7 @@ public class ContextServletIT extends BaseIT {
request.addHeader(THIRD_PARTY_HEADER_NAME, UNOMI_KEY);
request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.create("application/json")));
TestUtils.executeContextJSONRequest(request, sessionId);
+ refreshPersistence();
Thread.sleep(2000); //Making sure event is updated in DB
//Assert
@@ -159,6 +173,7 @@ public class ContextServletIT extends BaseIT {
Event event = new Event(eventId, eventTypeOriginal, session, profile, scope, null, null, new Date());
profileService.save(profile);
this.eventService.send(event);
+ refreshPersistence();
Thread.sleep(2000);
event.setEventType(eventTypeUpdated); //change the event so we can see the update effect
@@ -169,6 +184,7 @@ public class ContextServletIT extends BaseIT {
HttpPost request = new HttpPost(URL + CONTEXT_URL);
request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.create("application/json")));
TestUtils.executeContextJSONRequest(request, sessionId);
+ refreshPersistence();
Thread.sleep(2000); //Making sure event is updated in DB
//Assert
@@ -182,16 +198,14 @@ public class ContextServletIT extends BaseIT {
public void testUpdateEventFromContextAuthorizedThirdPartyNoItemID_Fail() throws IOException, InterruptedException {
//Arrange
String eventId = "test-event-id3";
- 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-updated";
- Profile profile = new Profile(profileId);
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);
this.eventService.send(event);
+ refreshPersistence();
Thread.sleep(2000);
event.setEventType(eventTypeUpdated); //change the event so we can see the update effect
@@ -202,6 +216,7 @@ public class ContextServletIT extends BaseIT {
HttpPost request = new HttpPost(URL + CONTEXT_URL);
request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.create("application/json")));
TestUtils.executeContextJSONRequest(request, sessionId);
+ refreshPersistence();
Thread.sleep(2000); //Making sure event is updated in DB
//Assert
@@ -211,7 +226,7 @@ public class ContextServletIT extends BaseIT {
}
@Test
- public void testCreateEventsWithNoTimestampParam_profileAddedToSegment() throws IOException {
+ public void testCreateEventsWithNoTimestampParam_profileAddedToSegment() throws IOException, InterruptedException {
//Arrange
String sessionId = "test-session-id";
String scope = "test-scope";
@@ -227,17 +242,22 @@ public class ContextServletIT extends BaseIT {
HttpPost request = new HttpPost(URL + CONTEXT_URL);
request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.create("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);
ContextResponse response = (TestUtils.executeContextJSONRequest(request, sessionId)).getContextResponse(); //second event
+ refreshPersistence();
+
//Assert
assertEquals(1, response.getProfileSegments().size());
assertThat(response.getProfileSegments(),hasItem(SEGMENT_ID));
}
@Test
- public void testCreateEventWithTimestampParam_pastEvent_profileIsNotAddedToSegment() throws IOException {
+ public void testCreateEventWithTimestampParam_pastEvent_profileIsNotAddedToSegment() throws IOException, InterruptedException {
//Arrange
String sessionId = "test-session-id";
String scope = "test-scope";
@@ -257,17 +277,19 @@ public class ContextServletIT extends BaseIT {
request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.create("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());
}
@Test
- public void testCreateEventWithTimestampParam_futureEvent_profileIsNotAddedToSegment() throws IOException {
+ public void testCreateEventWithTimestampParam_futureEvent_profileIsNotAddedToSegment() throws IOException, InterruptedException {
//Arrange
String sessionId = "test-session-id";
String scope = "test-scope";
@@ -287,10 +309,12 @@ public class ContextServletIT extends BaseIT {
request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.create("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());
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 677ccbc..0d31b7f 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportActorsIT.java
@@ -34,7 +34,12 @@ import org.ops4j.pax.exam.util.Filter;
import javax.inject.Inject;
import java.io.File;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
/**
* Created by amidani on 14/08/2017.
@@ -43,9 +48,11 @@ import java.util.*;
@ExamReactorStrategy(PerSuite.class)
public class ProfileImportActorsIT 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
@@ -66,11 +73,17 @@ public class ProfileImportActorsIT extends BaseIT {
profileService.setPropertyType(propertyTypeTwitterId);
profileService.setPropertyType(propertyTypeActorsGenres);
- PropertyType propTwitterId = profileService.getPropertyType("twitterId");
- Assert.assertNotNull(propTwitterId);
+ PropertyType propTwitterId = keepTrying("Failed waiting for property type 'twitterId'",
+ () -> profileService.getPropertyType("twitterId"),
+ Objects::nonNull,
+ 1000,
+ 100);
- PropertyType propActorsGenre = profileService.getPropertyType("movieGenres");
- Assert.assertNotNull(propActorsGenre);
+ PropertyType propActorsGenre = keepTrying("Failed waiting for property type 'movieGenres'",
+ () -> profileService.getPropertyType("movieGenres"),
+ Objects::nonNull,
+ 1000,
+ 100);
/*** Actors Test ***/
@@ -101,7 +114,11 @@ public class ProfileImportActorsIT extends BaseIT {
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);
+ keepTrying("Failed waiting for actors initial import to complete",
+ () -> profileService.findProfilesByPropertyValue("properties.city", "hollywood", 0, 10, null),
+ (p) -> p.getTotalSize() == 6,
+ 1000,
+ 200);
List<ImportConfiguration> importConfigurations = importConfigurationService.getAll();
Assert.assertEquals(1, importConfigurations.size());
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 9694598..9159426 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
@@ -38,6 +38,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
/**
* Created by amidani on 09/08/2017.
@@ -71,11 +72,17 @@ public class ProfileImportRankingIT extends BaseIT {
profileService.setPropertyType(propertyTypeRank);
- PropertyType propUciId = profileService.getPropertyType("uciId");
- Assert.assertNotNull(propUciId);
+ PropertyType propUciId = keepTrying("Failed waiting for property type 'uciId'",
+ () -> profileService.getPropertyType("uciId"),
+ Objects::nonNull,
+ 1000,
+ 100);
- PropertyType propRankId = profileService.getPropertyType("rank");
- Assert.assertNotNull(propRankId);
+ PropertyType propRankId = keepTrying("Failed waiting for property type 'rank'",
+ () -> profileService.getPropertyType("rank"),
+ Objects::nonNull,
+ 1000,
+ 100);
/*** Surfers Test ***/
@@ -108,8 +115,11 @@ public class ProfileImportRankingIT extends BaseIT {
//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);
- List<ImportConfiguration> importConfigurations = importConfigurationService.getAll();
- Assert.assertEquals(1, importConfigurations.size());
+ List<ImportConfiguration> importConfigurations = keepTrying("Failed waiting for import configurations list with 1 item",
+ () -> 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 e4bbf69..01ea0fe 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
@@ -40,8 +40,8 @@ import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
+import java.util.Objects;
/**
* Created by amidani on 09/08/2017.
@@ -67,11 +67,13 @@ public class ProfileImportSurfersIT extends BaseIT {
profileService.setPropertyType(propertyType);
- PropertyType propAlive = profileService.getPropertyType("alive");
+ keepTrying("Failed waiting for property type 'alive'",
+ () -> profileService.getPropertyType("alive"),
+ Objects::nonNull,
+ 1000,
+ 100);
- Assert.assertNotNull("Alive property should not be null", propAlive);
-
- propAlive = RouterUtils.getPropertyTypeById(profileService.getTargetPropertyTypes("profiles"), "alive");
+ PropertyType propAlive = RouterUtils.getPropertyTypeById(profileService.getTargetPropertyTypes("profiles"), "alive");
Assert.assertNotNull("Lookup of alive property through profiles target has failed !", propAlive);
@@ -107,8 +109,11 @@ public class ProfileImportSurfersIT extends BaseIT {
//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);
- List<ImportConfiguration> importConfigurations = importConfigurationService.getAll();
- Assert.assertEquals(1, importConfigurations.size());
+ 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);
@@ -152,8 +157,11 @@ public class ProfileImportSurfersIT extends BaseIT {
//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);
- importConfigurations = importConfigurationService.getAll();
- Assert.assertEquals(1, importConfigurations.size());
+ 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);
@@ -191,8 +199,11 @@ public class ProfileImportSurfersIT extends BaseIT {
//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);
- importConfigurations = importConfigurationService.getAll();
- Assert.assertEquals(1, importConfigurations.size());
+ 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);
Assert.assertEquals(0, jordyProfileDelete.getList().size());
diff --git a/itests/src/test/java/org/apache/unomi/itests/TestUtils.java b/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
index eae0252..6f45456 100644
--- a/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
+++ b/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
@@ -18,6 +18,7 @@
package org.apache.unomi.itests;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
@@ -33,11 +34,14 @@ import org.apache.unomi.api.services.DefinitionsService;
import org.apache.unomi.persistence.spi.CustomObjectMapper;
import org.apache.unomi.persistence.spi.PersistenceService;
import org.junit.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.IOException;
public class TestUtils {
private static final String JSON_MYME_TYPE = "application/json";
+ private final static Logger LOGGER = LoggerFactory.getLogger(TestUtils.class);
public static <T> T retrieveResourceFromResponse(HttpResponse response, Class<T> clazz) throws IOException {
if (response == null) {
@@ -53,6 +57,7 @@ public class TestUtils {
T value = mapper.readValue(jsonFromResponse, clazz);
return value;
} catch (Throwable t) {
+ LOGGER.error("Error parsing response JSON", t);
t.printStackTrace();
}
return null;
@@ -61,7 +66,12 @@ public class TestUtils {
public static RequestResponse executeContextJSONRequest(HttpPost request, String sessionId) throws IOException {
try (CloseableHttpResponse response = HttpClientBuilder.create().build().execute(request)) {
// validate mimeType
- String mimeType = ContentType.getOrDefault(response.getEntity()).getMimeType();
+ HttpEntity entity = response.getEntity();
+ String mimeType = ContentType.getOrDefault(entity).getMimeType();
+ if (!JSON_MYME_TYPE.equals(mimeType)) {
+ String entityContent = EntityUtils.toString(entity);
+ LOGGER.warn("Invalid response: " + entityContent);
+ }
Assert.assertEquals("Response content type should be " + JSON_MYME_TYPE, JSON_MYME_TYPE, mimeType);
// validate context
diff --git a/wab/src/main/java/org/apache/unomi/web/ContextServlet.java b/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
index 693c23e..3604162 100644
--- a/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
+++ b/wab/src/main/java/org/apache/unomi/web/ContextServlet.java
@@ -179,7 +179,11 @@ public class ContextServlet extends HttpServlet {
// We must reload the profile with the session ID as some properties could be missing from the session profile
// #personalIdentifier
profile = profileService.load(sessionProfile.getItemId());
- HttpUtils.sendProfileCookie(profile, response, profileIdCookieName, profileIdCookieDomain, profileIdCookieMaxAgeInSeconds);
+ if (profile != null) {
+ HttpUtils.sendProfileCookie(profile, response, profileIdCookieName, profileIdCookieDomain, profileIdCookieMaxAgeInSeconds);
+ } else {
+ logger.warn("Couldn't load profile {} referenced in session {}", sessionProfile.getItemId(), session.getItemId());
+ }
}
// Handle anonymous situation
[unomi] 03/11: feat(org.apache.unomi.services.cfg) - add an
environment variable for a configuration property
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit 6d87742b63c9dc2ab3b5714931cdf49a44f0be84
Author: nlevitsky <nl...@yotpo.com>
AuthorDate: Thu Jun 25 11:00:55 2020 +0300
feat(org.apache.unomi.services.cfg) - add an environment variable for a configuration property
(cherry picked from commit 473fb679d5365dc6ce72b9fab718b4b08129a4a8)
---
package/src/main/resources/etc/custom.system.properties | 2 ++
services/src/main/resources/org.apache.unomi.services.cfg | 3 +++
2 files changed, 5 insertions(+)
diff --git a/package/src/main/resources/etc/custom.system.properties b/package/src/main/resources/etc/custom.system.properties
index bd23640..87b7464 100644
--- a/package/src/main/resources/etc/custom.system.properties
+++ b/package/src/main/resources/etc/custom.system.properties
@@ -105,6 +105,8 @@ org.apache.unomi.profile.purge.inactiveTime=${env:UNOMI_PROFILE_PURGE_INACTIVETI
org.apache.unomi.profile.purge.existTime=${env:UNOMI_PROFILE_PURGE_EXISTTIME:--1}
# Purge all sessions/events that have been created for a specific number of months
org.apache.unomi.event.purge.existTime=${env:UNOMI_EVENT_PURGE_EXISTTIME:-12}
+# Refresh Elasticsearch after saving a profile
+org.apache.unomi.profile.forceRefreshOnSave=${env:UNOMI_PROFILE_REFRESH_ON_SAVE:-false}
# When performing segment updates, this controls the size of the scrolling query size used to iterate over all the
# profiles that need updating
org.apache.unomi.segment.update.batchSize=${env:UNOMI_SEGMENT_UPDATE_BATCHSIZE:-1000}
diff --git a/services/src/main/resources/org.apache.unomi.services.cfg b/services/src/main/resources/org.apache.unomi.services.cfg
index 792f990..08295cb 100644
--- a/services/src/main/resources/org.apache.unomi.services.cfg
+++ b/services/src/main/resources/org.apache.unomi.services.cfg
@@ -24,6 +24,9 @@ profile.purge.inactiveTime=${org.apache.unomi.profile.purge.inactiveTime:-180}
# Purge profiles that have been created for a specific number of days
profile.purge.existTime=${org.apache.unomi.profile.purge.existTime:--1}
+# Refresh Elasticsearch after saving a profile
+profile.forceRefreshOnSave=${org.apache.unomi.profile.forceRefreshOnSave:-false}
+
# Purge all sessions/events that have been created for a specific number of months
event.purge.existTime=${org.apache.unomi.event.purge.existTime:-12}
[unomi] 07/11: Add itests for sending a new event with profile id
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit fe4f09cbda13e35f0cd30867ae20990c985e48db
Author: Shir <sb...@yotpo.com>
AuthorDate: Mon Jul 20 11:28:44 2020 +0300
Add itests for sending a new event with profile id
(cherry picked from commit f83a236a9914ef12af7a455c329c7799b6566f5b)
---
.../org/apache/unomi/itests/ContextServletIT.java | 27 ++++++++++++++++++++++
.../java/org/apache/unomi/itests/TestUtils.java | 11 ++++++---
2 files changed, 35 insertions(+), 3 deletions(-)
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 307a38e..0587a21 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
@@ -319,4 +319,31 @@ public class ContextServletIT extends BaseIT {
//Assert
assertEquals(0,response.getProfileSegments().size());
}
+
+ @Test
+ public void testCreateEventWithProfileId_Success() throws IOException, InterruptedException {
+ //Arrange
+ String eventId = "test-event-id1";
+ 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.setEvents(Arrays.asList(event));
+
+ //Act
+ HttpPost request = new HttpPost(URL + CONTEXT_URL);
+ request.addHeader(THIRD_PARTY_HEADER_NAME, UNOMI_KEY);
+ request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.create("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());
+ }
}
diff --git a/itests/src/test/java/org/apache/unomi/itests/TestUtils.java b/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
index 6f45456..5e385f5 100644
--- a/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
+++ b/itests/src/test/java/org/apache/unomi/itests/TestUtils.java
@@ -78,9 +78,10 @@ public class TestUtils {
ContextResponse context = TestUtils.retrieveResourceFromResponse(response, ContextResponse.class);
Assert.assertNotNull("Context should not be null", context);
Assert.assertNotNull("Context profileId should not be null", context.getProfileId());
- Assert.assertEquals("Context sessionId should be the same as the sessionId used to request the context", sessionId,
- context.getSessionId());
-
+ if (sessionId != null) {
+ Assert.assertEquals("Context sessionId should be the same as the sessionId used to request the context", sessionId,
+ context.getSessionId());
+ }
String cookieHeader = null;
if (response.containsHeader("Set-Cookie")) {
cookieHeader = response.getHeaders("Set-Cookie")[0].toString().substring(12);
@@ -89,6 +90,10 @@ public class TestUtils {
}
}
+ public static RequestResponse executeContextJSONRequest(HttpPost request) throws IOException {
+ return executeContextJSONRequest(request, null);
+ }
+
public static boolean removeAllProfiles(DefinitionsService definitionsService, PersistenceService persistenceService) {
Condition condition = new Condition(definitionsService.getConditionType("profilePropertyCondition"));
condition.setParameter("propertyName","itemType");
[unomi] 08/11: UNOMI-363 add consent mapping
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit d7ab62e9e5389eaf4308a00d6cedecb2d6fb024d
Author: Taybou <be...@gmail.com>
AuthorDate: Mon Jul 20 17:48:41 2020 +0200
UNOMI-363 add consent mapping
(cherry picked from commit 0f59e7235122a8d17b61c2401b16899f9e53bd9b)
---
.../resources/META-INF/cxs/mappings/consent.json | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/consent.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/consent.json
new file mode 100644
index 0000000..6d4d57d
--- /dev/null
+++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/consent.json
@@ -0,0 +1,37 @@
+{
+ "dynamic_templates": [
+ {
+ "all": {
+ "match": "*",
+ "match_mapping_type": "string",
+ "mapping": {
+ "type": "text",
+ "analyzer": "folding",
+ "fields": {
+ "keyword": {
+ "type": "keyword",
+ "ignore_above": 256
+ }
+ }
+ }
+ }
+ }
+ ],
+ "properties": {
+ "scope": {
+ "type": "string"
+ },
+ "typeIdentifier": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ },
+ "statusDate": {
+ "type": "date"
+ },
+ "revokeDate": {
+ "type": "date"
+ }
+ }
+}
[unomi] 09/11: UNOMI-363 add consent mapping in the profile.json
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit f70ec426cfec4731790dc954308b8747d0074b22
Author: Taybou <be...@gmail.com>
AuthorDate: Tue Jul 21 09:54:22 2020 +0200
UNOMI-363 add consent mapping in the profile.json
(cherry picked from commit 574d57e1c4ea2ccf69164b9770b4b5f2d4e4e5bd)
---
.../resources/META-INF/cxs/mappings/consent.json | 37 ----------------------
.../resources/META-INF/cxs/mappings/profile.json | 25 +++++++++++++--
2 files changed, 22 insertions(+), 40 deletions(-)
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/consent.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/consent.json
deleted file mode 100644
index 6d4d57d..0000000
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/consent.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "dynamic_templates": [
- {
- "all": {
- "match": "*",
- "match_mapping_type": "string",
- "mapping": {
- "type": "text",
- "analyzer": "folding",
- "fields": {
- "keyword": {
- "type": "keyword",
- "ignore_above": 256
- }
- }
- }
- }
- }
- ],
- "properties": {
- "scope": {
- "type": "string"
- },
- "typeIdentifier": {
- "type": "string"
- },
- "status": {
- "type": "string"
- },
- "statusDate": {
- "type": "date"
- },
- "revokeDate": {
- "type": "date"
- }
- }
-}
diff --git a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json
index 7732186..2911216 100644
--- a/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json
+++ b/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json
@@ -20,8 +20,8 @@
"properties": {
"properties": {
"properties": {
- "age" : {
- "type" : "long"
+ "age": {
+ "type": "long"
},
"firstVisit": {
"type": "date"
@@ -36,6 +36,25 @@
"type": "long"
}
}
+ },
+ "consents": {
+ "properties": {
+ "scope": {
+ "type": "string"
+ },
+ "typeIdentifier": {
+ "type": "string"
+ },
+ "status": {
+ "type": "string"
+ },
+ "statusDate": {
+ "type": "date"
+ },
+ "revokeDate": {
+ "type": "date"
+ }
+ }
}
}
-}
\ No newline at end of file
+}
[unomi] 06/11: Fix compilation issue in Windows
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch unomi-1.5.x
in repository https://gitbox.apache.org/repos/asf/unomi.git
commit 9e18dd4e42ada9a463e6af11cdd22ce7147cdd93
Author: sergehuber <sh...@jahia.com>
AuthorDate: Sun Jul 12 10:10:57 2020 +0200
Fix compilation issue in Windows
(cherry picked from commit 1f0b9f86bc37701adb9e939015db759ec1b0131f)
---
.../conditions/PropertyConditionEvaluatorTest.java | 26 ++++++++++++----------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/plugins/baseplugin/src/test/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluatorTest.java b/plugins/baseplugin/src/test/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluatorTest.java
index dff90fb..05ac126 100644
--- a/plugins/baseplugin/src/test/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluatorTest.java
+++ b/plugins/baseplugin/src/test/java/org/apache/unomi/plugins/baseplugin/conditions/PropertyConditionEvaluatorTest.java
@@ -44,10 +44,10 @@ public class PropertyConditionEvaluatorTest {
public static final Date SESSION_LAST_EVENT_DATE = new Date();
public static final int THREAD_POOL_SIZE = 300;
public static final int WORKER_COUNT = 500000;
- private static PropertyConditionEvaluator propertyConditionEvaluator = new PropertyConditionEvaluator();
- private static Event mockEvent = generateMockEvent();
- private static Profile mockProfile = generateMockProfile();
- private static Session mockSession = generateMockSession();
+ private static final PropertyConditionEvaluator propertyConditionEvaluator = new PropertyConditionEvaluator();
+ private static final Event mockEvent = generateMockEvent();
+ private static final Profile mockProfile = generateMockProfile();
+ private static final Session mockSession = generateMockSession();
@Test
public void testHardcodedEvaluator() {
@@ -117,30 +117,32 @@ public class PropertyConditionEvaluatorTest {
if (vulnFile.exists()) {
vulnFile.delete();
}
+ String vulnFileCanonicalPath = vulnFile.getCanonicalPath();
+ vulnFileCanonicalPath = vulnFileCanonicalPath.replace("\\", "\\\\"); // this is required for Windows support
try {
- propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "@java.lang.Runtime@getRuntime().exec('touch " + vulnFile.getCanonicalPath() + "')");
+ propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "@java.lang.Runtime@getRuntime().exec('touch " + vulnFileCanonicalPath + "')");
} catch (RuntimeException | MethodFailedException re) {
// we ignore these exceptions as they are expected.
}
- assertFalse("Vulnerability successfully executed ! File created at " + vulnFile.getCanonicalPath(), vulnFile.exists());
+ assertFalse("Vulnerability successfully executed ! File created at " + vulnFileCanonicalPath, vulnFile.exists());
try {
- propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "(#cmd='touch " + vulnFile.getCanonicalPath() + "').(#cmds={'bash','-c',#cmd}).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start())");
+ propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "(#cmd='touch " + vulnFileCanonicalPath + "').(#cmds={'bash','-c',#cmd}).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start())");
} catch (RuntimeException | MethodFailedException re) {
// we ignore these exceptions as they are expected.
}
vulnFile = new File("target/vuln-file.txt");
- assertFalse("Vulnerability successfully executed ! File created at " + vulnFile.getCanonicalPath(), vulnFile.exists());
+ assertFalse("Vulnerability successfully executed ! File created at " + vulnFileCanonicalPath, vulnFile.exists());
try {
- propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "(#cmd='touch " + vulnFile.getCanonicalPath() + "').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start())");
+ propertyConditionEvaluator.getOGNLPropertyValue(mockEvent, "(#cmd='touch " + vulnFileCanonicalPath + "').(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c',#cmd}:{'bash','-c',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start())");
} catch (RuntimeException | MethodFailedException re) {
// we ignore these exceptions as they are expected.
}
vulnFile = new File("target/vuln-file.txt");
- assertFalse("Vulnerability successfully executed ! File created at " + vulnFile.getCanonicalPath(), vulnFile.exists());
+ assertFalse("Vulnerability successfully executed ! File created at " + vulnFileCanonicalPath, vulnFile.exists());
}
private void runHardcodedTest(int workerCount, ExecutorService executorService) throws InterruptedException {
- List<Callable<Object>> todo = new ArrayList<Callable<Object>>(workerCount);
+ List<Callable<Object>> todo = new ArrayList<>(workerCount);
long startTime = System.currentTimeMillis();
for (int i = 0; i < workerCount; i++) {
todo.add(new HardcodedWorker());
@@ -151,7 +153,7 @@ public class PropertyConditionEvaluatorTest {
}
private void runOGNLTest(int workerCount, ExecutorService executorService) throws InterruptedException {
- List<Callable<Object>> todo = new ArrayList<Callable<Object>>(workerCount);
+ List<Callable<Object>> todo = new ArrayList<>(workerCount);
long startTime = System.currentTimeMillis();
for (int i = 0; i < workerCount; i++) {
todo.add(new OGNLWorker());