Skip to content

Commit

Permalink
fix: correctly compare equality of Double and Long
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilkka Kaakkola committed Nov 28, 2022
1 parent e4a64e8 commit f5e84c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private static boolean matchLongVariable(QueryOperator op, Long requested, Long
if (actual == null) {
return false;
}
return requested == actual;
return actual.equals(requested);
case EXISTS:
return actual != null;
case GREATER_THAN:
Expand Down Expand Up @@ -333,7 +333,7 @@ private static boolean matchLongVariable(QueryOperator op, Long requested, Long
if (actual == null) {
return true;
}
return requested != actual;
return !actual.equals(requested);
case NOT_EXISTS:
return actual == null;
default:
Expand All @@ -348,7 +348,7 @@ private static boolean matchDoubleVariable(QueryOperator op, Double requested, D
if (actual == null) {
return false;
}
return requested == actual;
return actual.equals(requested);
case EXISTS:
return actual != null;
case GREATER_THAN:
Expand Down Expand Up @@ -379,7 +379,7 @@ private static boolean matchDoubleVariable(QueryOperator op, Double requested, D
if (actual == null) {
return true;
}
return requested != actual;
return !actual.equals(requested);
case NOT_EXISTS:
return actual == null;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,31 @@ public void testOrQueryExecution() throws InterruptedException {
processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true);
processEngine.close();
}
}

@Test
public void testQueryExecutionVariableNumericValues() {
Deployment deployment = processEngine.getRepositoryService().createDeployment()
.addClasspathResource("org/flowable/engine/test/inmemory/triggerableExecution.bpmn20.xml").deploy();

try {
processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 100, "test-variable-2", 100.1));
processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 100, "test-variable-2", 100.1));
processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 200, "test-variable-2", 200.1));
processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 200, "test-variable-2", 200.1));
processEngine.getRuntimeService().startProcessInstanceByKey("triggerableExecution", map("test-variable-1", 300, "test-variable-2", 300.1));

assertThat(query().variableValueEquals("test-variable-1", 100).list()).hasSize(2);
assertThat(query().variableValueEquals("test-variable-1", 200).list()).hasSize(2);
assertThat(query().variableValueLessThanOrEqual("test-variable-1", 200).list()).hasSize(4);

assertThat(query().variableValueEquals("test-variable-2", 100.1).list()).hasSize(2);
assertThat(query().variableValueEquals("test-variable-2", 200.1).list()).hasSize(2);
assertThat(query().variableValueLessThanOrEqual("test-variable-2", 200.1).list()).hasSize(4);
} finally {
processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true);
processEngine.close();
}

}

Expand Down

0 comments on commit f5e84c0

Please sign in to comment.