You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jk...@apache.org on 2022/11/09 09:58:43 UTC
[unomi] branch refactor-control-groups updated: UNOMI-690, UNOMI-696: Fix itests
This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch refactor-control-groups
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/refactor-control-groups by this push:
new e67997cdb UNOMI-690, UNOMI-696: Fix itests
e67997cdb is described below
commit e67997cdbd105759362aa945f3c932ce01932291
Author: Kevan <ke...@jahia.com>
AuthorDate: Wed Nov 9 10:58:33 2022 +0100
UNOMI-690, UNOMI-696: Fix itests
---
.../java/org/apache/unomi/api/ContextResponse.java | 50 +-
.../apache/unomi/api/PersonalizationResult.java | 7 +
.../org/apache/unomi/itests/ContextServletIT.java | 103 +--
.../resources/personalization-controlgroup.json | 988 ---------------------
.../unomi/rest/endpoints/ContextJsonEndpoint.java | 9 +-
5 files changed, 50 insertions(+), 1107 deletions(-)
diff --git a/api/src/main/java/org/apache/unomi/api/ContextResponse.java b/api/src/main/java/org/apache/unomi/api/ContextResponse.java
index cb0ee4ab8..2eaf098f3 100644
--- a/api/src/main/java/org/apache/unomi/api/ContextResponse.java
+++ b/api/src/main/java/org/apache/unomi/api/ContextResponse.java
@@ -20,8 +20,10 @@ package org.apache.unomi.api;
import org.apache.unomi.api.conditions.Condition;
import org.apache.unomi.api.services.RulesService;
+import javax.xml.bind.annotation.XmlTransient;
import java.io.Serializable;
import java.util.*;
+import java.util.stream.Collectors;
/**
* A context server response resulting from the evaluation of a client's context request. Note that all returned values result of the evaluation of the data provided in the
@@ -49,7 +51,7 @@ public class ContextResponse implements Serializable {
private int processedEvents;
- private Map<String, List<String>> personalizations;
+ private Map<String, PersonalizationResult> personalizationResults;
private Set<Condition> trackedConditions;
@@ -57,8 +59,6 @@ public class ContextResponse implements Serializable {
private Map<String, Consent> consents = new LinkedHashMap<>();
- private Map<String, Object> additionalResponseData = new HashMap<>();
-
/**
* Retrieves the profile identifier associated with the profile of the user on behalf of which the client performed the context request.
*
@@ -198,21 +198,38 @@ public class ContextResponse implements Serializable {
}
/**
- * @deprecated personalizations results are more complex since 2.1.0 and they are now available under:
- * additionalResponseData.personalizationResults
+ * @deprecated personalizations results are more complex since 2.1.0 and they are now available under: getPersonalizationResults()
*/
@Deprecated
+ @XmlTransient
public Map<String, List<String>> getPersonalizations() {
- return personalizations;
+ if (personalizationResults != null) {
+ return personalizationResults.entrySet()
+ .stream()
+ .collect(Collectors.toMap(Map.Entry::getKey,
+ entry -> entry.getValue().getContentIds()));
+ }
+ return null;
}
/**
- * @deprecated personalizations results are more complex since 2.1.0 and they are now available under:
- * additionalResponseData.personalizationResults
+ * @deprecated personalizations results are more complex since 2.1.0 and they are now available under: setPersonalizationResults(Map<String, PersonalizationResult> personalizationResults)
*/
@Deprecated
public void setPersonalizations(Map<String, List<String>> personalizations) {
- this.personalizations = personalizations;
+ // do nothing, use setPersonalizationResults() instead
+ }
+
+ /**
+ * Get the result of the personalization resolutions done during the context request.
+ * @return a Map key/value pair (key:personalization id, value:the result that contains the matching content ids and additional information)
+ */
+ public Map<String, PersonalizationResult> getPersonalizationResults() {
+ return personalizationResults;
+ }
+
+ public void setPersonalizationResults(Map<String, PersonalizationResult> personalizationResults) {
+ this.personalizationResults = personalizationResults;
}
/**
@@ -275,19 +292,4 @@ public class ContextResponse implements Serializable {
public void setConsents(Map<String, Consent> consents) {
this.consents = consents;
}
-
- /**
- * Useful open map for additional information that could be returned by Unomi during the context request.
- * @return additional properties
- */
- public Map<String, Object> getAdditionalResponseData() {
- return additionalResponseData;
- }
-
- /**
- * Useful open map for additional information that could be returned by Unomi during the context request.
- */
- public void setAdditionalResponseData(Map<String, Object> additionalResponseData) {
- this.additionalResponseData = additionalResponseData;
- }
}
diff --git a/api/src/main/java/org/apache/unomi/api/PersonalizationResult.java b/api/src/main/java/org/apache/unomi/api/PersonalizationResult.java
index ceb2e2ade..15c6ab5a5 100644
--- a/api/src/main/java/org/apache/unomi/api/PersonalizationResult.java
+++ b/api/src/main/java/org/apache/unomi/api/PersonalizationResult.java
@@ -38,6 +38,9 @@ public class PersonalizationResult implements Serializable {
int changeType = EventService.NO_CHANGE;
+ public PersonalizationResult() {
+ }
+
public PersonalizationResult(List<String> contentIds) {
this.contentIds = contentIds;
}
@@ -50,6 +53,10 @@ public class PersonalizationResult implements Serializable {
return contentIds;
}
+ public void setContentIds(List<String> contentIds) {
+ this.contentIds = contentIds;
+ }
+
/**
* Useful open map to return additional result information to the client
* @return map of key/value pair for additional information, like: inControlGroup
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 cfa9275cd..8c4d97eda 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
@@ -21,13 +21,7 @@ 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.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.Scope;
-import org.apache.unomi.api.Session;
+import org.apache.unomi.api.*;
import org.apache.unomi.api.conditions.Condition;
import org.apache.unomi.api.segments.Scoring;
import org.apache.unomi.api.segments.Segment;
@@ -560,6 +554,8 @@ public class ContextServletIT extends BaseIT {
List<String> variants = contextResponse.getPersonalizations().get("perso-by-interest");
assertEquals("Invalid response code", 200, response.getStatusCode());
assertEquals("Perso should be empty, profile is empty", 0, variants.size());
+ variants = contextResponse.getPersonalizationResults().get("perso-by-interest").getContentIds();
+ assertEquals("Perso should be empty, profile is empty", 0, variants.size());
// set profile for matching
Profile profile = profileService.load(TEST_PROFILE_ID);
@@ -577,6 +573,9 @@ public class ContextServletIT extends BaseIT {
assertEquals("Invalid response code", 200, response.getStatusCode());
assertEquals("Perso should contains the good number of variants", 1, variants.size());
assertEquals("Variant is not the expected one", "matching-fishing-interests-custom-score-100-variant-expected-score-120", variants.get(0));
+ variants = contextResponse.getPersonalizationResults().get("perso-by-interest").getContentIds();
+ assertEquals("Perso should contains the good number of variants", 1, variants.size());
+ assertEquals("Variant is not the expected one", "matching-fishing-interests-custom-score-100-variant-expected-score-120", variants.get(0));
// modify profile to add interests
profile = profileService.load(TEST_PROFILE_ID);
@@ -617,87 +616,15 @@ public class ContextServletIT extends BaseIT {
assertEquals("Variant is not the expected one", "matching-football-interests-variant-expected-score-51", variants.get(4));
assertEquals("Variant is not the expected one", "matching-tennis-interests-variant-expected-score-31", variants.get(5));
assertEquals("Variant is not the expected one", "not-matching-tennis-interests-custom-score-100-variant-expected-score-30", variants.get(6));
- }
-
- @Test
- public void testPersonalizationWithControlGroup() throws Exception {
-
- Map<String, String> parameters = new HashMap<>();
- parameters.put("storeInSession", "false");
- HttpPost request = new HttpPost(getFullUrl(CONTEXT_URL));
- 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());
-
- ContextResponse contextResponse = response.getContextResponse();
-
- 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");
- assertControlGroups(profileControlGroups);
-
- 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(getFullUrl(CONTEXT_URL));
- request.setEntity(
- new StringEntity(getValidatedBundleJSON("personalization-controlgroup.json", parameters), ContentType.APPLICATION_JSON));
- response = TestUtils.executeContextJSONRequest(request);
- assertEquals("Invalid response code", 200, response.getStatusCode());
- 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");
- assertControlGroups(sessionControlGroups);
-
- Session updatedSession = profileService.loadSession(contextResponse.getSessionId(), new Date());
- 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) {
- assertEquals("Personalizations don't have expected size", 2, personalizations.size());
-
- List<String> perso1Contents = personalizations.get("perso1");
- assertEquals("Perso 1 content list size doesn't match", 10, perso1Contents.size());
- List<String> expectedPerso1Contents = new ArrayList<>();
- expectedPerso1Contents.add("perso1content1");
- expectedPerso1Contents.add("perso1content2");
- expectedPerso1Contents.add("perso1content3");
- expectedPerso1Contents.add("perso1content4");
- expectedPerso1Contents.add("perso1content5");
- expectedPerso1Contents.add("perso1content6");
- expectedPerso1Contents.add("perso1content7");
- expectedPerso1Contents.add("perso1content8");
- expectedPerso1Contents.add("perso1content9");
- expectedPerso1Contents.add("perso1content10");
- assertEquals("Perso1 contents do not match", expectedPerso1Contents, perso1Contents);
- }
-
- 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);
- 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"));
+ variants = contextResponse.getPersonalizationResults().get("perso-by-interest").getContentIds();
+ assertEquals("Perso should contains the good number of variants", 7, variants.size());
+ assertEquals("Variant is not the expected one", "matching-fishing-interests-custom-score-100-variant-expected-score-120", variants.get(0));
+ assertEquals("Variant is not the expected one", "matching-football-cars-interests-variant-expected-score-91", variants.get(1));
+ assertEquals("Variant is not the expected one", "not-matching-football-cars-interests-variant-expected-score-90", variants.get(2));
+ assertEquals("Variant is not the expected one", "not-matching-tennis-fishing-interests-variant-expected-score-50", variants.get(3));
+ assertEquals("Variant is not the expected one", "matching-football-interests-variant-expected-score-51", variants.get(4));
+ assertEquals("Variant is not the expected one", "matching-tennis-interests-variant-expected-score-31", variants.get(5));
+ assertEquals("Variant is not the expected one", "not-matching-tennis-interests-custom-score-100-variant-expected-score-30", variants.get(6));
}
@Test
diff --git a/itests/src/test/resources/personalization-controlgroup.json b/itests/src/test/resources/personalization-controlgroup.json
deleted file mode 100644
index c4a1bcf98..000000000
--- a/itests/src/test/resources/personalization-controlgroup.json
+++ /dev/null
@@ -1,988 +0,0 @@
-{
- "source": {
- "itemId": "CMSServer",
- "itemType": "custom",
- "scope": "acme",
- "properties": {}
- },
- "requireSegments": true,
- "requiredProfileProperties": [
- "unomiControlGroups"
- ],
- "requiredSessionProperties": [
- "unomiControlGroups"
- ],
- "personalizations": [
- {
- "id": "perso1",
- "strategy": "score-sorted",
- "strategyOptions": {
- "threshold": -1,
- "controlGroup" : {
- "percentage" : 100.0,
- "displayName" : "First perso",
- "path" : "/home/perso1.html",
- "storeInSession" : ###storeInSession###
- }
- },
- "contents": [
- {
- "id": "perso1content1",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ],
- "properties": {
- "interests": "health food"
- }
- },
- {
- "id": "perso1content2",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/contactus.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso1content3",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/documentation.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso1content4",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/aboutus.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso1content5",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/products.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso1content6",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/services.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso1content7",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/community.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso1content8",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/projects.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso1content9",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/home.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso1content10",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/theend.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- }
- ]
- },
- {
- "id": "perso2",
- "strategy": "score-sorted",
- "strategyOptions": {
- "threshold": -1
- },
- "contents": [
- {
- "id": "perso2content1",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ],
- "properties": {
- "interests": "health food"
- }
- },
- {
- "id": "perso2content2",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/contactus.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso1content3",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/documentation.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso2content4",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/aboutus.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso2content5",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/products.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso2content6",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/services.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso2content7",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/community.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso2content8",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/projects.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso2content9",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/home.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- },
- {
- "id": "perso2content10",
- "filters": [
- {
- "condition": {
- "parameterValues": {
- "minimumEventCount": 1,
- "eventCondition": {
- "type": "booleanCondition",
- "parameterValues": {
- "operator": "and",
- "subConditions" : [
- {
- "type": "eventTypeCondition",
- "parameterValues": {
- "eventTypeId": "view"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.pagePath",
- "propertyValue": "/theend.html",
- "comparisonOperator": "equals"
- }
- },
- {
- "type": "eventPropertyCondition",
- "parameterValues": {
- "propertyName": "target.properties.pageInfo.language",
- "propertyValue": "en",
- "comparisonOperator": "equals"
- }
- }
- ]
- }
- },
- "numberOfDays": 30
- },
- "type": "pastEventCondition"
- },
- "properties": {
- "score": -1000
- }
- }
- ]
- }
- ]
- }
- ],
- "sessionId": "test-session-id"
-}
\ No newline at end of file
diff --git a/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java
index 49b1c535b..c6f98bd37 100644
--- a/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/ContextJsonEndpoint.java
@@ -203,17 +203,12 @@ public class ContextJsonEndpoint {
List<PersonalizationService.PersonalizationRequest> personalizations = contextRequest.getPersonalizations();
if (personalizations != null) {
- data.setPersonalizations(new HashMap<>());
- Map<String, PersonalizationResult> personalizationResults = new HashMap<>();
+ data.setPersonalizationResults(new HashMap<>());
for (PersonalizationService.PersonalizationRequest personalization : sanitizePersonalizations(personalizations)) {
PersonalizationResult personalizationResult = personalizationService.personalizeList(eventsRequestContext.getProfile(), eventsRequestContext.getSession(), personalization);
eventsRequestContext.addChanges(personalizationResult.getChangeType());
-
- // Support for old personalization result in response
- data.getPersonalizations().put(personalization.getId(), personalizationResult.getContentIds());
- personalizationResults.put(personalization.getId(), personalizationResult);
+ data.getPersonalizationResults().put(personalization.getId(), personalizationResult);
}
- data.getAdditionalResponseData().put("personalizationResults", personalizationResults);
}
if (contextRequest.isRequireSegments()) {