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 2018/10/19 15:06:01 UTC
incubator-unomi git commit: UNOMI-202 add test with patch on
ConditionType and ActionType
Repository: incubator-unomi
Updated Branches:
refs/heads/master d5c560f39 -> 5ed92f9cc
UNOMI-202 add test with patch on ConditionType and ActionType
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/5ed92f9c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/5ed92f9c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/5ed92f9c
Branch: refs/heads/master
Commit: 5ed92f9cc03230a4c32f1c15c7ad2bb765bdebcb
Parents: d5c560f
Author: dgaillard <dg...@jahia.com>
Authored: Fri Oct 19 17:05:52 2018 +0200
Committer: dgaillard <dg...@jahia.com>
Committed: Fri Oct 19 17:05:52 2018 +0200
----------------------------------------------------------------------
.../java/org/apache/unomi/itests/PatchIT.java | 45 ++++++++++++++++++++
itests/src/test/resources/patch4.json | 19 +++++++++
itests/src/test/resources/patch5.json | 17 ++++++++
3 files changed, 81 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/5ed92f9c/itests/src/test/java/org/apache/unomi/itests/PatchIT.java
----------------------------------------------------------------------
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 8016693..412395e 100644
--- a/itests/src/test/java/org/apache/unomi/itests/PatchIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/PatchIT.java
@@ -18,6 +18,9 @@ package org.apache.unomi.itests;
import org.apache.unomi.api.Patch;
import org.apache.unomi.api.PropertyType;
+import org.apache.unomi.api.actions.ActionType;
+import org.apache.unomi.api.conditions.ConditionType;
+import org.apache.unomi.api.services.DefinitionsService;
import org.apache.unomi.api.services.PatchService;
import org.apache.unomi.api.services.ProfileService;
import org.apache.unomi.persistence.spi.CustomObjectMapper;
@@ -50,6 +53,10 @@ public class PatchIT extends BaseIT {
protected ProfileService profileService;
@Inject
+ @Filter(timeout = 60000)
+ protected DefinitionsService definitionsService;
+
+ @Inject
protected BundleContext bundleContext;
@Test
@@ -107,4 +114,42 @@ public class PatchIT extends BaseIT {
profileService.setPropertyType(income);
}
}
+
+ @Test
+ public void testPatchOnConditionType() throws IOException, InterruptedException {
+ ConditionType formCondition = definitionsService.getConditionType("formEventCondition");
+ Assert.assertTrue(formCondition.getMetadata().getSystemTags().contains("usableInPastEventCondition"));
+
+ try {
+ Patch patch = CustomObjectMapper.getObjectMapper().readValue(bundleContext.getBundle().getResource("patch4.json"), Patch.class);
+
+ patchService.patch(patch);
+
+ Thread.sleep(10000);
+
+ ConditionType newFormCondition = definitionsService.getConditionType("formEventCondition");
+ Assert.assertFalse(newFormCondition.getMetadata().getSystemTags().contains("usableInPastEventCondition"));
+ } finally {
+ definitionsService.setConditionType(formCondition);
+ }
+ }
+
+ @Test
+ public void testPatchOnActionType() throws IOException, InterruptedException {
+ ActionType mailAction = definitionsService.getActionType("sendMailAction");
+ Assert.assertTrue(mailAction.getMetadata().getSystemTags().contains("availableToEndUser"));
+
+ try {
+ Patch patch = CustomObjectMapper.getObjectMapper().readValue(bundleContext.getBundle().getResource("patch5.json"), Patch.class);
+
+ patchService.patch(patch);
+
+ Thread.sleep(10000);
+
+ ActionType newMailAction = definitionsService.getActionType("sendMailAction");
+ Assert.assertFalse(newMailAction.getMetadata().getSystemTags().contains("availableToEndUser"));
+ } finally {
+ definitionsService.setActionType(mailAction);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/5ed92f9c/itests/src/test/resources/patch4.json
----------------------------------------------------------------------
diff --git a/itests/src/test/resources/patch4.json b/itests/src/test/resources/patch4.json
new file mode 100644
index 0000000..9f848cb
--- /dev/null
+++ b/itests/src/test/resources/patch4.json
@@ -0,0 +1,19 @@
+{
+ "itemId": "formEventCondition-patch1",
+ "patchedItemId": "formEventCondition",
+ "patchedItemType": "condition",
+ "operation": "patch",
+ "data": [
+ {
+ "op": "replace",
+ "path": "/metadata/systemTags",
+ "value": [
+ "profileTags",
+ "event",
+ "condition",
+ "eventCondition",
+ "trackedCondition"
+ ]
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/5ed92f9c/itests/src/test/resources/patch5.json
----------------------------------------------------------------------
diff --git a/itests/src/test/resources/patch5.json b/itests/src/test/resources/patch5.json
new file mode 100644
index 0000000..6c336b9
--- /dev/null
+++ b/itests/src/test/resources/patch5.json
@@ -0,0 +1,17 @@
+{
+ "itemId": "sendMailAction-patch1",
+ "patchedItemId": "sendMailAction",
+ "patchedItemType": "action",
+ "operation": "patch",
+ "data": [
+ {
+ "op": "replace",
+ "path": "/metadata/systemTags",
+ "value": [
+ "profileTags",
+ "event",
+ "allowMultipleInstances"
+ ]
+ }
+ ]
+}