Skip to content

Commit

Permalink
fix(engine): ensure task queries are parsed properly in filters
Browse files Browse the repository at this point in the history
Related to CAM-10639
  • Loading branch information
koevskinikola committed Jul 31, 2019
1 parent e070d6a commit 27a8ada
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class JsonTaskQueryConverter extends JsonObjectConverter<TaskQuery> {
public static final String MAX_PRIORITY = "maxPriority";
public static final String ASSIGNEE = "assignee";
public static final String ASSIGNEE_LIKE = "assigneeLike";
public static final String ASSIGNEE_IN = "assigneeIn";
public static final String INVOLVED_USER = "involvedUser";
public static final String OWNER = "owner";
public static final String UNASSIGNED = "unassigned";
Expand Down Expand Up @@ -139,6 +140,12 @@ public JsonObject toJsonObject(TaskQuery taskQuery, boolean isOrQueryActive) {
JsonUtil.addField(json, MIN_PRIORITY, query.getMinPriority());
JsonUtil.addField(json, MAX_PRIORITY, query.getMaxPriority());
JsonUtil.addField(json, ASSIGNEE, query.getAssignee());

if (query.getAssigneeIn() != null) {
JsonUtil.addArrayField(json, ASSIGNEE_IN,
query.getAssigneeIn().toArray(new String[query.getAssigneeIn().size()]));
}

JsonUtil.addField(json, ASSIGNEE_LIKE, query.getAssigneeLike());
JsonUtil.addField(json, INVOLVED_USER, query.getInvolvedUser());
JsonUtil.addField(json, OWNER, query.getOwner());
Expand Down Expand Up @@ -304,6 +311,9 @@ public TaskQuery toObject(JsonObject json) {
if (json.has(ASSIGNEE_LIKE)) {
query.taskAssigneeLike(JsonUtil.getString(json, ASSIGNEE_LIKE));
}
if (json.has(ASSIGNEE_IN)) {
query.taskAssigneeIn(getArray(JsonUtil.getArray(json, ASSIGNEE_IN)));
}
if (json.has(INVOLVED_USER)) {
query.taskInvolvedUser(JsonUtil.getString(json, INVOLVED_USER));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public void testTaskQuery() {
query.taskAssigneeExpression(testString);
query.taskAssigneeLike(testString);
query.taskAssigneeLikeExpression(testString);
query.taskAssigneeIn(testString);
query.taskInvolvedUser(testString);
query.taskInvolvedUserExpression(testString);
query.taskOwner(testString);
Expand Down Expand Up @@ -247,6 +248,7 @@ public void testTaskQuery() {
assertEquals(testString, query.getExpressions().get("taskAssignee"));
assertEquals(testString, query.getAssigneeLike());
assertEquals(testString, query.getExpressions().get("taskAssigneeLike"));
assertTrue(query.getAssigneeIn().contains(testString));
assertEquals(testString, query.getInvolvedUser());
assertEquals(testString, query.getExpressions().get("taskInvolvedUser"));
assertEquals(testString, query.getOwner());
Expand Down Expand Up @@ -1873,6 +1875,43 @@ public void testDueDate() {
assertThat(filterService.count(filter.getId()), is(1L));
}

public void testAssigneeInPositive() {
// given
TaskQueryImpl taskQuery = new TaskQueryImpl();
taskQuery.taskAssigneeIn(testString);

// when
// save filter
filter.setQuery(taskQuery);
filterService.saveFilter(filter);

// fetch from db
filter = filterService.createTaskFilterQuery().singleResult();
taskQuery = filter.getQuery();

// then
assertTrue(taskQuery.getAssigneeIn().contains(testString));
}

public void testAssigneeInNegative() {
// given
TaskQueryImpl taskQuery = new TaskQueryImpl();

// when
// save filter
filter.setQuery(taskQuery);
filterService.saveFilter(filter);

// fetch from db
filter = filterService.createTaskFilterQuery().singleResult();

// test query
taskQuery = filter.getQuery();

// then
assertNull(taskQuery.getAssigneeIn());
}

/**
* See CAM-9613
*/
Expand Down

0 comments on commit 27a8ada

Please sign in to comment.