-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOB-9716 - single primitive array bug
- Loading branch information
1 parent
3e6aa4a
commit 0469733
Showing
2 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
...dTest/java/com/iterable/iterableapi/util/SinglePrimitiveArrayNestedCriteriaMatchTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.iterable.iterableapi.util; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
|
||
import org.json.JSONArray; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
@RunWith(JUnit4.class) | ||
public class SinglePrimitiveArrayNestedCriteriaMatchTest { | ||
|
||
static final String mockDataArrayNested = "{\n" + | ||
" \"count\": 1,\n" + | ||
" \"criteriaSets\": [\n" + | ||
" {\n" + | ||
" \"criteriaId\": \"467\",\n" + | ||
" \"name\": \"Custom event - single primitive\",\n" + | ||
" \"createdAt\": 1728166585122,\n" + | ||
" \"updatedAt\": 1729581351423,\n" + | ||
" \"searchQuery\": {\n" + | ||
" \"combinator\": \"And\",\n" + | ||
" \"searchQueries\": [\n" + | ||
" {\n" + | ||
" \"combinator\": \"And\",\n" + | ||
" \"searchQueries\": [\n" + | ||
" {\n" + | ||
" \"dataType\": \"customEvent\",\n" + | ||
" \"searchCombo\": {\n" + | ||
" \"combinator\": \"And\",\n" + | ||
" \"searchQueries\": [\n" + | ||
" {\n" + | ||
" \"dataType\": \"customEvent\",\n" + | ||
" \"field\": \"eventName\",\n" + | ||
" \"comparatorType\": \"Equals\",\n" + | ||
" \"value\": \"animal_found\",\n" + | ||
" \"fieldType\": \"string\"\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"dataType\": \"customEvent\",\n" + | ||
" \"field\": \"animal_found.count\",\n" + | ||
" \"comparatorType\": \"DoesNotEqual\",\n" + | ||
" \"value\": \"4\",\n" + | ||
" \"fieldType\": \"string\"\n" + | ||
" }\n" + | ||
" ]\n" + | ||
" }\n" + | ||
" }\n" + | ||
" ]\n" + | ||
" }\n" + | ||
" ]\n" + | ||
" }\n" + | ||
" }\n" + | ||
" ]\n" + | ||
"}"; | ||
|
||
|
||
private CriteriaCompletionChecker evaluator; | ||
|
||
@Before | ||
public void setUp() { | ||
evaluator = new CriteriaCompletionChecker(); | ||
} | ||
|
||
@Test | ||
public void testSinglePrimitiveArrayNestedCriteriaMatchPass() throws Exception { | ||
String jsonString = "[\n" + | ||
" {\n" + | ||
" \"dataFields\": {\n" + | ||
" \"count\": [5,8,9]\n" + | ||
" },\n" + | ||
" \"eventType\": \"customEvent\",\n" + | ||
" \"eventName\": \"animal_found\"\n" + | ||
" }\n" + | ||
"]"; | ||
JSONArray jsonArray = new JSONArray(jsonString); | ||
String result = evaluator.getMatchedCriteria(mockDataArrayNested, jsonArray); | ||
assertNotNull(result); | ||
} | ||
|
||
@Test | ||
public void testSinglePrimitiveArrayNestedCriteriaMatchFail() throws Exception { | ||
String jsonString = "[\n" + | ||
" {\n" + | ||
" \"dataFields\": {\n" + | ||
" \"count\": [4, 8, 9]\n" + | ||
" },\n" + | ||
" \"eventType\": \"customEvent\",\n" + | ||
" \"eventName\": \"animal_found\"\n" + | ||
" }\n" + | ||
"]"; | ||
JSONArray jsonArray = new JSONArray(jsonString); | ||
String result = evaluator.getMatchedCriteria(mockDataArrayNested, jsonArray); | ||
assertNull(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters