From e1ebc2221ddf5b8553bf7e433c6d858c957b810f Mon Sep 17 00:00:00 2001 From: Miklas Boskamp Date: Thu, 25 Jul 2019 13:02:28 +0200 Subject: [PATCH] feat(engine): introduce case-insensitive variable queries * ProcessInstanceQuery * CaseExecutionQuery * CaseInstanceQuery * ExecutionQuery * HistoricCaseInstanceQuery * HistoricProcessInstanceQuery * VariableInstanceQuery Related to CAM-10647, CAM-10395, Closes #416 --- .../history/HistoricCaseInstanceQueryDto.java | 19 + .../HistoricProcessInstanceQueryDto.java | 20 +- .../dto/runtime/CaseExecutionQueryDto.java | 22 +- .../dto/runtime/CaseInstanceQueryDto.java | 19 + .../rest/dto/runtime/ExecutionQueryDto.java | 20 +- .../dto/runtime/ProcessInstanceQueryDto.java | 27 + .../dto/runtime/VariableInstanceQueryDto.java | 21 + .../CaseExecutionRestServiceQueryTest.java | 610 +++++++++++++++++- .../CaseInstanceRestServiceQueryTest.java | 377 ++++++++++- .../rest/ExecutionRestServiceQueryTest.java | 572 +++++++++++++++- .../ProcessInstanceRestServiceQueryTest.java | 535 ++++++++++++++- .../VariableInstanceRestServiceQueryTest.java | 536 ++++++++++++++- ...toricCaseInstanceRestServiceQueryTest.java | 468 ++++++++++++-- ...icProcessInstanceRestServiceQueryTest.java | 423 +++++++++++- .../history/HistoricCaseInstanceQuery.java | 10 + .../history/HistoricProcessInstanceQuery.java | 10 + .../impl/AbstractVariableQueryImpl.java | 33 +- .../bpm/engine/impl/QueryVariableValue.java | 6 + .../engine/impl/TaskQueryVariableValue.java | 4 +- .../engine/runtime/CaseExecutionQuery.java | 10 + .../bpm/engine/runtime/CaseInstanceQuery.java | 10 + .../bpm/engine/runtime/ExecutionQuery.java | 10 + .../engine/runtime/ProcessInstanceQuery.java | 10 + .../engine/runtime/VariableInstanceQuery.java | 36 ++ .../impl/mapping/entity/CaseExecution.xml | 3 +- .../engine/impl/mapping/entity/Commons.xml | 12 + .../engine/impl/mapping/entity/Execution.xml | 5 +- .../mapping/entity/HistoricCaseInstance.xml | 2 +- .../entity/HistoricProcessInstance.xml | 2 +- .../bpm/engine/impl/mapping/entity/Task.xml | 11 +- .../impl/mapping/entity/VariableInstance.xml | 3 +- .../AbstractVariableIgnoreCaseTest.java | 185 ++++++ ...eExecutionQueryVariableIgnoreCaseTest.java | 173 +++++ .../ExecutionQueryVariableIgnoreCaseTest.java | 166 +++++ ...seInstanceQueryVariableIgnoreCaseTest.java | 58 ++ ...ssInstanceQueryVariableIgnoreCaseTest.java | 45 ++ ...ssInstanceQueryVariableIgnoreCaseTest.java | 46 ++ ...leInstanceQueryVariableIgnoreCaseTest.java | 48 ++ 38 files changed, 4345 insertions(+), 222 deletions(-) create mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/variables/AbstractVariableIgnoreCaseTest.java create mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/variables/CaseExecutionQueryVariableIgnoreCaseTest.java create mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ExecutionQueryVariableIgnoreCaseTest.java create mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/variables/HistoricCaseInstanceQueryVariableIgnoreCaseTest.java create mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/variables/HistoricProcessInstanceQueryVariableIgnoreCaseTest.java create mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ProcessInstanceQueryVariableIgnoreCaseTest.java create mode 100644 engine/src/test/java/org/camunda/bpm/engine/test/api/variables/VariableInstanceQueryVariableIgnoreCaseTest.java diff --git a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricCaseInstanceQueryDto.java b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricCaseInstanceQueryDto.java index 76c0d446abf..8e4886d2a46 100644 --- a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricCaseInstanceQueryDto.java +++ b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricCaseInstanceQueryDto.java @@ -94,6 +94,9 @@ public class HistoricCaseInstanceQueryDto extends AbstractQueryDto variables; + protected Boolean variableValuesIgnoreCase; + protected Boolean variableNamesIgnoreCase; + public HistoricCaseInstanceQueryDto() {} public HistoricCaseInstanceQueryDto(ObjectMapper objectMapper, MultivaluedMap queryParameters) { @@ -230,6 +233,16 @@ public void setVariables(List variables) { this.variables = variables; } + @CamundaQueryParam(value = "variableValuesIgnoreCase", converter = BooleanConverter.class) + public void setVariableValuesIgnoreCase(Boolean variableValuesIgnoreCase) { + this.variableValuesIgnoreCase = variableValuesIgnoreCase; + } + + @CamundaQueryParam(value = "variableNamesIgnoreCase", converter = BooleanConverter.class) + public void setVariableNamesIgnoreCase(Boolean variableNamesIgnoreCase) { + this.variableNamesIgnoreCase = variableNamesIgnoreCase; + } + @CamundaQueryParam(value = "caseActivityIdIn", converter = StringListConverter.class) public void setCaseActivityIdIn(List caseActivityIdIn) { this.caseActivityIdIn = caseActivityIdIn; @@ -326,6 +339,12 @@ protected void applyFilters(HistoricCaseInstanceQuery query) { if (caseActivityIdIn != null && !caseActivityIdIn.isEmpty()) { query.caseActivityIdIn(caseActivityIdIn.toArray(new String[caseActivityIdIn.size()])); } + if(Boolean.TRUE.equals(variableNamesIgnoreCase)) { + query.matchVariableNamesIgnoreCase(); + } + if(Boolean.TRUE.equals(variableValuesIgnoreCase)) { + query.matchVariableValuesIgnoreCase(); + } if (variables != null) { for (VariableQueryParameterDto variableQueryParam : variables) { String variableName = variableQueryParam.getName(); diff --git a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricProcessInstanceQueryDto.java b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricProcessInstanceQueryDto.java index 99d8b5c7454..4634c036dd4 100644 --- a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricProcessInstanceQueryDto.java +++ b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/history/HistoricProcessInstanceQueryDto.java @@ -116,6 +116,9 @@ public class HistoricProcessInstanceQueryDto extends AbstractQueryDto variables; + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; + private List orQueries; public HistoricProcessInstanceQueryDto() {} @@ -278,6 +281,16 @@ public void setVariables(List variables) { this.variables = variables; } + @CamundaQueryParam(value = "variableNamesIgnoreCase", converter = BooleanConverter.class) + public void setVariableNamesIgnoreCase(Boolean variableNamesIgnoreCase) { + this.variableNamesIgnoreCase = variableNamesIgnoreCase; + } + + @CamundaQueryParam(value = "variableValuesIgnoreCase", converter = BooleanConverter.class) + public void setVariableValuesIgnoreCase(Boolean variableValuesIgnoreCase) { + this.variableValuesIgnoreCase = variableValuesIgnoreCase; + } + public String getIncidentType() { return incidentType; } @@ -469,7 +482,12 @@ protected void applyFilters(HistoricProcessInstanceQuery query) { if (TRUE.equals(withoutTenantId)) { query.withoutTenantId(); } - + if(TRUE.equals(variableNamesIgnoreCase)) { + query.matchVariableNamesIgnoreCase(); + } + if(TRUE.equals(variableValuesIgnoreCase)) { + query.matchVariableValuesIgnoreCase(); + } if (variables != null) { for (VariableQueryParameterDto variableQueryParam : variables) { String variableName = variableQueryParam.getName(); diff --git a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/CaseExecutionQueryDto.java b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/CaseExecutionQueryDto.java index 4e196ffaecf..c13885d0253 100644 --- a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/CaseExecutionQueryDto.java +++ b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/CaseExecutionQueryDto.java @@ -70,6 +70,9 @@ public class CaseExecutionQueryDto extends AbstractQueryDto protected List variables; protected List caseInstanceVariables; + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; + public CaseExecutionQueryDto() { } @@ -137,6 +140,16 @@ public void setVariables(List variables) { this.variables = variables; } + @CamundaQueryParam(value = "variableNamesIgnoreCase", converter = BooleanConverter.class) + public void setVariableNamesIgnoreCase(Boolean variableNamesIgnoreCase) { + this.variableNamesIgnoreCase = variableNamesIgnoreCase; + } + + @CamundaQueryParam(value = "variableValuesIgnoreCase", converter = BooleanConverter.class) + public void setVariableValuesIgnoreCase(Boolean variableValuesIgnoreCase) { + this.variableValuesIgnoreCase = variableValuesIgnoreCase; + } + @CamundaQueryParam(value = "caseInstanceVariables", converter = VariableListConverter.class) public void setCaseInstanceVariables(List caseInstanceVariables) { this.caseInstanceVariables = caseInstanceVariables; @@ -198,6 +211,14 @@ protected void applyFilters(CaseExecutionQuery query) { query.disabled(); } + if(Boolean.TRUE.equals(variableNamesIgnoreCase)) { + query.matchVariableNamesIgnoreCase(); + } + + if(Boolean.TRUE.equals(variableValuesIgnoreCase)) { + query.matchVariableValuesIgnoreCase(); + } + if (variables != null) { for (VariableQueryParameterDto variableQueryParam : variables) { @@ -266,5 +287,4 @@ protected void applySortBy(CaseExecutionQuery query, String sortBy, Map { protected List variables; + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; + public CaseInstanceQueryDto() { } @@ -156,6 +159,16 @@ public void setVariables(List variables) { this.variables = variables; } + @CamundaQueryParam(value = "variableNamesIgnoreCase", converter = BooleanConverter.class) + public void setVariableNamesIgnoreCase(Boolean variableNamesIgnoreCase) { + this.variableNamesIgnoreCase = variableNamesIgnoreCase; + } + + @CamundaQueryParam(value = "variableValuesIgnoreCase", converter = BooleanConverter.class) + public void setVariableValuesIgnoreCase(Boolean variableValuesIgnoreCase) { + this.variableValuesIgnoreCase = variableValuesIgnoreCase; + } + @Override protected boolean isValidSortByValue(String value) { return VALID_SORT_BY_VALUES.contains(value); @@ -210,6 +223,12 @@ protected void applyFilters(CaseInstanceQuery query) { if (terminated != null && terminated == true) { query.terminated(); } + if(Boolean.TRUE.equals(variableNamesIgnoreCase)) { + query.matchVariableNamesIgnoreCase(); + } + if(Boolean.TRUE.equals(variableValuesIgnoreCase)) { + query.matchVariableValuesIgnoreCase(); + } if (variables != null) { for (VariableQueryParameterDto variableQueryParam : variables) { diff --git a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/ExecutionQueryDto.java b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/ExecutionQueryDto.java index 98aff8395fe..05495ed90a0 100644 --- a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/ExecutionQueryDto.java +++ b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/ExecutionQueryDto.java @@ -69,6 +69,9 @@ public class ExecutionQueryDto extends AbstractQueryDto { private List variables; private List processVariables; + Boolean variableValuesIgnoreCase; + Boolean variableNamesIgnoreCase; + public ExecutionQueryDto() { } @@ -122,6 +125,16 @@ public void setProcessVariables(List processVariables this.processVariables = processVariables; } + @CamundaQueryParam(value = "variableValuesIgnoreCase", converter = BooleanConverter.class) + public void setVariableValuesIgnoreCase(Boolean variableValuesIgnoreCase) { + this.variableValuesIgnoreCase = variableValuesIgnoreCase; + } + + @CamundaQueryParam(value = "variableNamesIgnoreCase", converter = BooleanConverter.class) + public void setVariableNamesIgnoreCase(Boolean variableNamesIgnoreCase) { + this.variableNamesIgnoreCase = variableNamesIgnoreCase; + } + @CamundaQueryParam(value = "active", converter = BooleanConverter.class) public void setActive(Boolean active) { this.active = active; @@ -211,7 +224,12 @@ protected void applyFilters(ExecutionQuery query) { if (tenantIdIn != null && !tenantIdIn.isEmpty()) { query.tenantIdIn(tenantIdIn.toArray(new String[tenantIdIn.size()])); } - + if(Boolean.TRUE.equals(variableNamesIgnoreCase)) { + query.matchVariableNamesIgnoreCase(); + } + if(Boolean.TRUE.equals(variableValuesIgnoreCase)) { + query.matchVariableValuesIgnoreCase(); + } if (variables != null) { for (VariableQueryParameterDto variableQueryParam : variables) { String variableName = variableQueryParam.getName(); diff --git a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/ProcessInstanceQueryDto.java b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/ProcessInstanceQueryDto.java index 59e507158f5..bd2db10c76d 100644 --- a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/ProcessInstanceQueryDto.java +++ b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/ProcessInstanceQueryDto.java @@ -85,6 +85,9 @@ public class ProcessInstanceQueryDto extends AbstractQueryDto variables; private List orQueries; @@ -246,6 +249,24 @@ public void setVariables(List variables) { this.variables = variables; } + public Boolean isVariableNamesIgnoreCase() { + return variableNamesIgnoreCase; + } + + @CamundaQueryParam(value = "variableNamesIgnoreCase", converter = BooleanConverter.class) + public void setVariableNamesIgnoreCase(Boolean variableNamesCaseInsensitive) { + this.variableNamesIgnoreCase = variableNamesCaseInsensitive; + } + + public Boolean isVariableValuesIgnoreCase() { + return variableValuesIgnoreCase; + } + + @CamundaQueryParam(value ="variableValuesIgnoreCase", converter = BooleanConverter.class) + public void setVariableValuesIgnoreCase(Boolean variableValuesCaseInsensitive) { + this.variableValuesIgnoreCase = variableValuesCaseInsensitive; + } + public Boolean isWithIncident() { return withIncident; } @@ -448,6 +469,12 @@ protected void applyFilters(ProcessInstanceQuery query) { if (TRUE.equals(isProcessDefinitionWithoutTenantId)) { query.processDefinitionWithoutTenantId(); } + if(TRUE.equals(variableNamesIgnoreCase)) { + query.matchVariableNamesIgnoreCase(); + } + if(TRUE.equals(variableValuesIgnoreCase)) { + query.matchVariableValuesIgnoreCase(); + } if (variables != null) { for (VariableQueryParameterDto variableQueryParam : variables) { String variableName = variableQueryParam.getName(); diff --git a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/VariableInstanceQueryDto.java b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/VariableInstanceQueryDto.java index 795ad15d91d..872ef675f20 100644 --- a/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/VariableInstanceQueryDto.java +++ b/engine-rest/engine-rest/src/main/java/org/camunda/bpm/engine/rest/dto/runtime/VariableInstanceQueryDto.java @@ -27,6 +27,7 @@ import org.camunda.bpm.engine.rest.dto.AbstractQueryDto; import org.camunda.bpm.engine.rest.dto.CamundaQueryParam; import org.camunda.bpm.engine.rest.dto.VariableQueryParameterDto; +import org.camunda.bpm.engine.rest.dto.converter.BooleanConverter; import org.camunda.bpm.engine.rest.dto.converter.StringArrayConverter; import org.camunda.bpm.engine.rest.dto.converter.StringListConverter; import org.camunda.bpm.engine.rest.dto.converter.VariableListConverter; @@ -57,6 +58,8 @@ public class VariableInstanceQueryDto extends AbstractQueryDto variableValues; + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; protected String[] executionIdIn; protected String[] processInstanceIdIn; protected String[] caseExecutionIdIn; @@ -87,6 +90,16 @@ public void setVariableValues(List variableValues) { this.variableValues = variableValues; } + @CamundaQueryParam(value = "variableNamesIgnoreCase", converter = BooleanConverter.class) + public void setVariableNamesIgnoreCase(Boolean variableNamesIgnoreCase) { + this.variableNamesIgnoreCase = variableNamesIgnoreCase; + } + + @CamundaQueryParam(value = "variableValuesIgnoreCase", converter = BooleanConverter.class) + public void setVariableValuesIgnoreCase(Boolean variableValuesIgnoreCase) { + this.variableValuesIgnoreCase = variableValuesIgnoreCase; + } + @CamundaQueryParam(value="executionIdIn", converter = StringArrayConverter.class) public void setExecutionIdIn(String[] executionIdIn) { this.executionIdIn = executionIdIn; @@ -147,6 +160,14 @@ protected void applyFilters(VariableInstanceQuery query) { query.variableNameLike(variableNameLike); } + if(Boolean.TRUE.equals(variableNamesIgnoreCase)) { + query.matchVariableNamesIgnoreCase(); + } + + if(Boolean.TRUE.equals(variableValuesIgnoreCase)) { + query.matchVariableValuesIgnoreCase(); + } + if (variableValues != null) { for (VariableQueryParameterDto variableQueryParam : variableValues) { String variableName = variableQueryParam.getName(); diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/CaseExecutionRestServiceQueryTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/CaseExecutionRestServiceQueryTest.java index 1c0860a3208..0457fc43270 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/CaseExecutionRestServiceQueryTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/CaseExecutionRestServiceQueryTest.java @@ -761,8 +761,7 @@ public void testMultipleCaseInstanceVariableParametersAsPost() { } @Test - public void testVariableParameters() { - // equals + public void testVariableValueEquals() { String variableName = "varName"; String variableValue = "varValue"; String queryValue = variableName + "_eq_" + variableValue; @@ -776,9 +775,13 @@ public void testVariableParameters() { .get(CASE_EXECUTION_QUERY_URL); verify(mockedQuery).variableValueEquals(variableName, variableValue); + } - // greater then - queryValue = variableName + "_gt_" + variableValue; + @Test + public void testVariableValueGreaterThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gt_" + variableValue; given() .queryParam("variables", queryValue) @@ -789,9 +792,13 @@ public void testVariableParameters() { .get(CASE_EXECUTION_QUERY_URL); verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + } - // greater then equals - queryValue = variableName + "_gteq_" + variableValue; + @Test + public void testVariableValueGreaterThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gteq_" + variableValue; given() .queryParam("variables", queryValue) @@ -802,9 +809,13 @@ public void testVariableParameters() { .get(CASE_EXECUTION_QUERY_URL); verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + } - // lower then - queryValue = variableName + "_lt_" + variableValue; + @Test + public void testVariableValueLessThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lt_" + variableValue; given() .queryParam("variables", queryValue) @@ -815,10 +826,13 @@ public void testVariableParameters() { .get(CASE_EXECUTION_QUERY_URL); verify(mockedQuery).variableValueLessThan(variableName, variableValue); + } - // lower then equals - queryValue = variableName + "_lteq_" + variableValue; - + @Test + public void testVariableValueLessThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lteq_" + variableValue; given() .queryParam("variables", queryValue) .then() @@ -828,9 +842,13 @@ public void testVariableParameters() { .get(CASE_EXECUTION_QUERY_URL); verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + } - // like - queryValue = variableName + "_like_" + variableValue; + @Test + public void testVariableValueLike() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; given() .queryParam("variables", queryValue) @@ -841,9 +859,13 @@ public void testVariableParameters() { .get(CASE_EXECUTION_QUERY_URL); verify(mockedQuery).variableValueLike(variableName, variableValue); + } - // not equals - queryValue = variableName + "_neq_" + variableValue; + @Test + public void testVariableValueNotEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; given() .queryParam("variables", queryValue) @@ -857,15 +879,201 @@ public void testVariableParameters() { } @Test - public void testVariableParametersAsPost() { - // equals + public void testVariableNamesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableNamesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + } + + @Test + public void testVariableValuesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableNamesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + } + + @Test + public void testVariableValuesLikeIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueLike(variableName, variableValue); + } + + @Test + public void testCaseInstanceVariableNamesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + + given() + .queryParam("caseInstanceVariables", queryValue) + .queryParam("variableNamesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueEquals(variableName, variableValue); + } + + @Test + public void testCaseInstanceVariableValuesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + + given() + .queryParam("caseInstanceVariables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueEquals(variableName, variableValue); + } + + @Test + public void testCaseInstanceVariablesNamesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + + given() + .queryParam("caseInstanceVariables", queryValue) + .queryParam("variableNamesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueNotEquals(variableName, variableValue); + } + + @Test + public void testCaseInstanceVariableValuesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + + given() + .queryParam("caseInstanceVariables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueNotEquals(variableName, variableValue); + } + + @Test + public void testCaseInstanceVariableValuesLikeIgnoreCase() { String variableName = "varName"; String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + + given() + .queryParam("caseInstanceVariables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueLike(variableName, variableValue); + } + @Test + public void testVariableValueEqualsAsPost() { Map variableJson = new HashMap(); - variableJson.put("name", variableName); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "eq"); - variableJson.put("value", variableValue); List> variables = new ArrayList>(); variables.add(variableJson); @@ -882,11 +1090,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_EXECUTION_QUERY_URL); - verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } - // greater then + @Test + public void testVariableValueGreaterThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "gt"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -896,11 +1115,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_EXECUTION_QUERY_URL); - verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + verify(mockedQuery).variableValueGreaterThan("varName", "varValue"); + } - // greater then equals + @Test + public void testVariableValueGreaterThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "gteq"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -910,11 +1140,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_EXECUTION_QUERY_URL); - verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + verify(mockedQuery).variableValueGreaterThanOrEqual("varName", "varValue"); + } - // lower then + @Test + public void testVariableValueLessThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "lt"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -924,11 +1165,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_EXECUTION_QUERY_URL); - verify(mockedQuery).variableValueLessThan(variableName, variableValue); + verify(mockedQuery).variableValueLessThan("varName", "varValue"); + } - // lower then equals + @Test + public void testVariableValueLessThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "lteq"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -938,11 +1190,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_EXECUTION_QUERY_URL); - verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + verify(mockedQuery).variableValueLessThanOrEqual("varName", "varValue"); + } - // like + @Test + public void testVariableValueLikeAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "like"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -952,11 +1215,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_EXECUTION_QUERY_URL); - verify(mockedQuery).variableValueLike(variableName, variableValue); + verify(mockedQuery).variableValueLike("varName", "varValue"); + } - // not equals + @Test + public void testVariableValueNotEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "neq"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -966,7 +1240,279 @@ public void testVariableParametersAsPost() { .when() .post(CASE_EXECUTION_QUERY_URL); - verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesLikeIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueLike("varName", "varValue"); + } + + + @Test + public void testVariableNamesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testCaseInstanceVariableValuesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("caseInstanceVariables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueEquals("varName", "varValue"); + } + + @Test + public void testCaseInstanceVariableValuesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("caseInstanceVariables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueNotEquals("varName", "varValue"); + } + + @Test + public void testCaseInstanceVariableValuesLikeIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("caseInstanceVariables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueLike("varName", "varValue"); + } + + + @Test + public void testCaseInstanceVariableNamesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("caseInstanceVariables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueEquals("varName", "varValue"); + } + + @Test + public void testCaseInstanceVariableNamesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("caseInstanceVariables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).caseInstanceVariableValueNotEquals("varName", "varValue"); } @Test diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/CaseInstanceRestServiceQueryTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/CaseInstanceRestServiceQueryTest.java index 271022f2ed3..d83aeca74f3 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/CaseInstanceRestServiceQueryTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/CaseInstanceRestServiceQueryTest.java @@ -473,8 +473,7 @@ public void testMultipleParametersAsPost() { } @Test - public void testVariableParameters() { - // equals + public void testVariableValueEquals() { String variableName = "varName"; String variableValue = "varValue"; String queryValue = variableName + "_eq_" + variableValue; @@ -488,9 +487,13 @@ public void testVariableParameters() { .get(CASE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueEquals(variableName, variableValue); + } - // greater then - queryValue = variableName + "_gt_" + variableValue; + @Test + public void testVariableValueGreaterThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gt_" + variableValue; given() .queryParam("variables", queryValue) @@ -501,9 +504,13 @@ public void testVariableParameters() { .get(CASE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + } - // greater then equals - queryValue = variableName + "_gteq_" + variableValue; + @Test + public void testVariableValueGreaterThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gteq_" + variableValue; given() .queryParam("variables", queryValue) @@ -514,9 +521,13 @@ public void testVariableParameters() { .get(CASE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + } - // lower then - queryValue = variableName + "_lt_" + variableValue; + @Test + public void testVariableValueLessThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lt_" + variableValue; given() .queryParam("variables", queryValue) @@ -527,9 +538,13 @@ public void testVariableParameters() { .get(CASE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueLessThan(variableName, variableValue); + } - // lower then equals - queryValue = variableName + "_lteq_" + variableValue; + @Test + public void testVariableValueLessThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lteq_" + variableValue; given() .queryParam("variables", queryValue) @@ -540,9 +555,13 @@ public void testVariableParameters() { .get(CASE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + } - // like - queryValue = variableName + "_like_" + variableValue; + @Test + public void testVariableValueLike() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; given() .queryParam("variables", queryValue) @@ -553,9 +572,13 @@ public void testVariableParameters() { .get(CASE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueLike(variableName, variableValue); + } - // not equals - queryValue = variableName + "_neq_" + variableValue; + @Test + public void testVariableValueNotEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; given() .queryParam("variables", queryValue) @@ -569,15 +592,106 @@ public void testVariableParameters() { } @Test - public void testVariableParametersAsPost() { - // equals + public void testVariableValuesEqualsIgnoreCase() { String variableName = "varName"; String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableValuesLikeIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueLike(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + @Test + public void testVariableNamesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableNamesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableNamesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testVariableValueEqualsAsPost() { Map variableJson = new HashMap(); - variableJson.put("name", variableName); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "eq"); - variableJson.put("value", variableValue); List> variables = new ArrayList>(); variables.add(variableJson); @@ -594,11 +708,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_INSTANCE_QUERY_URL); - verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } - // greater then + @Test + public void testVariableGreaterThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "gt"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -608,11 +733,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_INSTANCE_QUERY_URL); - verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + verify(mockedQuery).variableValueGreaterThan("varName", "varValue"); + } - // greater then equals + @Test + public void testVariableValueGreaterThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "gteq"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -622,11 +758,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_INSTANCE_QUERY_URL); - verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + verify(mockedQuery).variableValueGreaterThanOrEqual("varName", "varValue"); + } - // lower then + @Test + public void testVariableValueLessThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "lt"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -636,11 +783,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_INSTANCE_QUERY_URL); - verify(mockedQuery).variableValueLessThan(variableName, variableValue); + verify(mockedQuery).variableValueLessThan("varName", "varValue"); + } - // lower then equals + @Test + public void testVariableValueLessThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "lteq"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -650,11 +808,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_INSTANCE_QUERY_URL); - verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + verify(mockedQuery).variableValueLessThanOrEqual("varName", "varValue"); + } - // like + @Test + public void testVariableValueLikeAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "like"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -664,11 +833,22 @@ public void testVariableParametersAsPost() { .when() .post(CASE_INSTANCE_QUERY_URL); - verify(mockedQuery).variableValueLike(variableName, variableValue); + verify(mockedQuery).variableValueLike("varName", "varValue"); + } - // not equals + @Test + public void testVariableValueNotEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); variableJson.put("operator", "neq"); + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + given() .contentType(POST_JSON_CONTENT_TYPE) .body(json) @@ -678,7 +858,142 @@ public void testVariableParametersAsPost() { .when() .post(CASE_INSTANCE_QUERY_URL); - verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueEquals("varName", "varValue"); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableValuesLikeIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueLike("varName", "varValue"); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableNamesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueEquals("varName", "varValue"); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(CASE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + verify(mockedQuery).matchVariableNamesIgnoreCase(); } @Test diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ExecutionRestServiceQueryTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ExecutionRestServiceQueryTest.java index 15f4cf92e96..f8134456412 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ExecutionRestServiceQueryTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ExecutionRestServiceQueryTest.java @@ -249,7 +249,7 @@ private Map getCompleteQueryParameters() { } @Test - public void testVariableParameters() { + public void testVariableValueEquals() { String variableName = "varName"; String variableValue = "varValue"; String queryValue = variableName + "_eq_" + variableValue; @@ -257,44 +257,602 @@ public void testVariableParameters() { .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(EXECUTION_QUERY_URL); verify(mockedQuery).variableValueEquals(variableName, variableValue); + } - queryValue = variableName + "_gt_" + variableValue; + @Test + public void testVariableValueGreaterThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gt_" + variableValue; given().queryParam("variables", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(EXECUTION_QUERY_URL); verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + } - queryValue = variableName + "_gteq_" + variableValue; + @Test + public void testVariableValueGreaterThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gteq_" + variableValue; given().queryParam("variables", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(EXECUTION_QUERY_URL); verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + } - queryValue = variableName + "_lt_" + variableValue; + @Test + public void testVariableValueLessThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lt_" + variableValue; given().queryParam("variables", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(EXECUTION_QUERY_URL); verify(mockedQuery).variableValueLessThan(variableName, variableValue); + } - queryValue = variableName + "_lteq_" + variableValue; + @Test + public void testVariableValueLessThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lteq_" + variableValue; given().queryParam("variables", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(EXECUTION_QUERY_URL); verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + } - queryValue = variableName + "_like_" + variableValue; + @Test + public void testVariableValueLike() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; given().queryParam("variables", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(EXECUTION_QUERY_URL); verify(mockedQuery).variableValueLike(variableName, variableValue); + } - queryValue = variableName + "_neq_" + variableValue; + @Test + public void testVariableValueNotEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; given().queryParam("variables", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(EXECUTION_QUERY_URL); verify(mockedQuery).variableValueNotEquals(variableName, variableValue); } + @Test + public void testVariableValuesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(EXECUTION_QUERY_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(EXECUTION_QUERY_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableValuesLikeIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(EXECUTION_QUERY_URL); + verify(mockedQuery).variableValueLike(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + + @Test + public void testVariableNamesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(EXECUTION_QUERY_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(EXECUTION_QUERY_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testProcessVariableValuesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("processVariables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(EXECUTION_QUERY_URL); + verify(mockedQuery).processVariableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testProcessVariableValuesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("processVariables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(EXECUTION_QUERY_URL); + verify(mockedQuery).processVariableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testProcessVariableNamesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("processVariables", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(EXECUTION_QUERY_URL); + verify(mockedQuery).processVariableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testProcessVariableNamesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("processVariables", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(EXECUTION_QUERY_URL); + verify(mockedQuery).processVariableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testVariableValueEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableValueGreaterThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gt"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).variableValueGreaterThan("varName", "varValue"); + } + + @Test + public void testVariableValueGreaterThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gteq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).variableValueGreaterThanOrEqual("varName", "varValue"); + } + + @Test + public void testVariableValueLessThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lt"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).variableValueLessThan("varName", "varValue"); + } + + @Test + public void testVariableValueLessThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lteq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).variableValueLessThanOrEqual("varName", "varValue"); + } + + @Test + public void testVariableValueLikeAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).variableValueLike("varName", "varValue"); + } + + @Test + public void testVariableValueNotEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesLikeIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueLike("varName", "varValue"); + } + + + @Test + public void testVariableNamesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testProcessVariableValuesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("processVariables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).processVariableValueEquals("varName", "varValue"); + } + + @Test + public void testProcessVariableValuesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("processVariables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).processVariableValueNotEquals("varName", "varValue"); + } + + @Test + public void testProcessVariableNamesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("processVariables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).processVariableValueEquals("varName", "varValue"); + } + + @Test + public void testProcessVariableNamesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("processVariables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(EXECUTION_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).processVariableValueNotEquals("varName", "varValue"); + } + @Test public void testProcessVariableParameters() { String variableName = "varName"; diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ProcessInstanceRestServiceQueryTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ProcessInstanceRestServiceQueryTest.java index c64cf177b30..c3166b0db54 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ProcessInstanceRestServiceQueryTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/ProcessInstanceRestServiceQueryTest.java @@ -75,6 +75,8 @@ public class ProcessInstanceRestServiceQueryTest extends protected static final String PROCESS_INSTANCE_QUERY_URL = TEST_RESOURCE_ROOT_PATH + "/process-instance"; protected static final String PROCESS_INSTANCE_COUNT_QUERY_URL = PROCESS_INSTANCE_QUERY_URL + "/count"; + private static final String TEST_VAR_NAME = "varName"; + private static final String TEST_VAR_VALUE = "varValue"; protected ProcessInstanceQuery mockedQuery; @Before @@ -267,52 +269,529 @@ private Map getCompleteQueryParameters() { } @Test - public void testVariableParameters() { + public void testVariableValueEquals() { String variableName = "varName"; String variableValue = "varValue"; String queryValue = variableName + "_eq_" + variableValue; - given().queryParam("variables", queryValue) - .then().expect().statusCode(Status.OK.getStatusCode()) - .when().get(PROCESS_INSTANCE_QUERY_URL); + + given() + .queryParam("variables", queryValue) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + } + + @Test + public void testVariableValueGreaterThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gt_" + variableValue; + + given() + .queryParam("variables", queryValue) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); - queryValue = variableName + "_gt_" + variableValue; - given().queryParam("variables", queryValue) - .then().expect().statusCode(Status.OK.getStatusCode()) - .when().get(PROCESS_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + } + + @Test + public void testVariableValueGreaterThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gteq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); - queryValue = variableName + "_gteq_" + variableValue; - given().queryParam("variables", queryValue) - .then().expect().statusCode(Status.OK.getStatusCode()) - .when().get(PROCESS_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + } + + @Test + public void testVariableValueLessThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lt_" + variableValue; + + given() + .queryParam("variables", queryValue) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); - queryValue = variableName + "_lt_" + variableValue; - given().queryParam("variables", queryValue) - .then().expect().statusCode(Status.OK.getStatusCode()) - .when().get(PROCESS_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueLessThan(variableName, variableValue); + } + + @Test + public void testVariableValueLessThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lteq_" + variableValue; + given() + .queryParam("variables", queryValue) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); - queryValue = variableName + "_lteq_" + variableValue; - given().queryParam("variables", queryValue) - .then().expect().statusCode(Status.OK.getStatusCode()) - .when().get(PROCESS_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + } + + @Test + public void testVariableValueLike() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + + given() + .queryParam("variables", queryValue) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); - queryValue = variableName + "_like_" + variableValue; - given().queryParam("variables", queryValue) - .then().expect().statusCode(Status.OK.getStatusCode()) - .when().get(PROCESS_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueLike(variableName, variableValue); + } + + @Test + public void testVariableValueNotEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); - queryValue = variableName + "_neq_" + variableValue; - given().queryParam("variables", queryValue) - .then().expect().statusCode(Status.OK.getStatusCode()) - .when().get(PROCESS_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueNotEquals(variableName, variableValue); } + @Test + public void testVariableNamesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableNamesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + } + + @Test + public void testVariableValuesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableNamesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + } + + @Test + public void testVariableValuesLikeIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + + given() + .queryParam("variables", queryValue) + .queryParam("variableValuesIgnoreCase", true) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .get(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueLike(variableName, variableValue); + } + + @Test + public void testVariableValueEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableValueGreaterThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gt"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueGreaterThan("varName", "varValue"); + } + + @Test + public void testVariableValueGreaterThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gteq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueGreaterThanOrEqual("varName", "varValue"); + } + + @Test + public void testVariableValueLessThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lt"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueLessThan("varName", "varValue"); + } + + @Test + public void testVariableValueLessThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lteq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueLessThanOrEqual("varName", "varValue"); + } + + @Test + public void testVariableValueLikeAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueLike("varName", "varValue"); + } + + @Test + public void testVariableValueNotEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesLikeIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueLike("varName", "varValue"); + } + + + @Test + public void testVariableNamesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(PROCESS_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + @Test public void testMultipleVariableParameters() { String variableName1 = "varName"; diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/VariableInstanceRestServiceQueryTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/VariableInstanceRestServiceQueryTest.java index 2dce1d3b4b1..984ca6b46d0 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/VariableInstanceRestServiceQueryTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/VariableInstanceRestServiceQueryTest.java @@ -27,7 +27,6 @@ import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; @@ -493,7 +492,7 @@ public void testAdditionalParametersExcludingVariableValuesAsPost() { } @Test - public void testVariableParameters() { + public void testVariableValueEquals() { String variableName = "varName"; String variableValue = "varValue"; String queryValue = variableName + "_eq_" + variableValue; @@ -501,46 +500,563 @@ public void testVariableParameters() { .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(VARIABLE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } - queryValue = variableName + "_gt_" + variableValue; + @Test + public void testVariableValueGreaterThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gt_" + variableValue; given().queryParam("variableValues", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(VARIABLE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + verify(mockedQuery).disableBinaryFetching(); - queryValue = variableName + "_gteq_" + variableValue; + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueGreaterThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gteq_" + variableValue; given().queryParam("variableValues", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(VARIABLE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + verify(mockedQuery).disableBinaryFetching(); - queryValue = variableName + "_lt_" + variableValue; + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueLessThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lt_" + variableValue; given().queryParam("variableValues", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(VARIABLE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueLessThan(variableName, variableValue); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } - queryValue = variableName + "_lteq_" + variableValue; + @Test + public void testVariableValueLessThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lteq_" + variableValue; given().queryParam("variableValues", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(VARIABLE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + verify(mockedQuery).disableBinaryFetching(); - queryValue = variableName + "_like_" + variableValue; + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueLike() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; given().queryParam("variableValues", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(VARIABLE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueLike(variableName, variableValue); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } - queryValue = variableName + "_neq_" + variableValue; + @Test + public void testVariableValueNotEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; given().queryParam("variableValues", queryValue) .then().expect().statusCode(Status.OK.getStatusCode()) .when().get(VARIABLE_INSTANCE_QUERY_URL); verify(mockedQuery).variableValueNotEquals(variableName, variableValue); - verify(mockedQuery, times(7)).disableBinaryFetching(); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValuesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variableValues", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(VARIABLE_INSTANCE_QUERY_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variableValues", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(VARIABLE_INSTANCE_QUERY_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValuesLikeIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + given().queryParam("variableValues", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(VARIABLE_INSTANCE_QUERY_URL); + verify(mockedQuery).variableValueLike(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + + @Test + public void testVariableNamesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variableValues", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(VARIABLE_INSTANCE_QUERY_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variableValues", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(VARIABLE_INSTANCE_QUERY_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueEquals("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueGreaterThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gt"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueGreaterThan("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueGreaterThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gteq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueGreaterThanOrEqual("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueLessThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lt"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueLessThan("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueLessThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lteq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueLessThanOrEqual("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueLikeAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueLike("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValueNotEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValuesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); // requirement to not break existing API; should be: - // verify(mockedQuery, times(7)).disableCustomObjectDeserialization(); + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableValuesLikeIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueLike("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + + @Test + public void testVariableNamesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); + verify(mockedQuery, never()).disableCustomObjectDeserialization(); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variableValues", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(VARIABLE_INSTANCE_QUERY_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + verify(mockedQuery).disableBinaryFetching(); + + // requirement to not break existing API; should be: + // verify(variableInstanceQueryMock).disableCustomObjectDeserialization(); verify(mockedQuery, never()).disableCustomObjectDeserialization(); } diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricCaseInstanceRestServiceQueryTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricCaseInstanceRestServiceQueryTest.java index 3cc05fb0209..e9ea3c9e527 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricCaseInstanceRestServiceQueryTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricCaseInstanceRestServiceQueryTest.java @@ -731,92 +731,452 @@ public void testQueryByCaseDefinitionKeyNotInAsPost() { } @Test - public void testVariableParameters() { - // equals + public void testVariableValueEquals() { String variableName = "varName"; String variableValue = "varValue"; String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + } - given() - .queryParam("variables", queryValue) - .then().expect() - .statusCode(Status.OK.getStatusCode()) - .when() - .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + @Test + public void testVariableValueGreaterThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gt_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + } + @Test + public void testVariableValueGreaterThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gteq_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + } + + @Test + public void testVariableValueLessThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lt_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueLessThan(variableName, variableValue); + } + + @Test + public void testVariableValueLessThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lteq_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + } + + @Test + public void testVariableValueLike() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueLike(variableName, variableValue); + } + + @Test + public void testVariableValueNotEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + } + + @Test + public void testVariableValuesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } - // greater then - queryValue = variableName + "_gt_" + variableValue; + @Test + public void testVariableValuesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableValuesLikeIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueLike(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + + @Test + public void testVariableNamesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testVariableValueEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) - .then().expect() - .statusCode(Status.OK.getStatusCode()) - .when() - .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableValueGreaterThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gt"); - // greater then equals - queryValue = variableName + "_gteq_" + variableValue; + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) - .then().expect() - .statusCode(Status.OK.getStatusCode()) - .when() - .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + verify(mockedQuery).variableValueGreaterThan("varName", "varValue"); + } - // lower then - queryValue = variableName + "_lt_" + variableValue; + @Test + public void testVariableValueGreaterThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gteq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) - .then().expect() - .statusCode(Status.OK.getStatusCode()) - .when() - .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueLessThan(variableName, variableValue); + verify(mockedQuery).variableValueGreaterThanOrEqual("varName", "varValue"); + } - // lower then equals - queryValue = variableName + "_lteq_" + variableValue; + @Test + public void testVariableValueLessThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lt"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) - .then().expect() - .statusCode(Status.OK.getStatusCode()) - .when() - .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + verify(mockedQuery).variableValueLessThan("varName", "varValue"); + } - // like - queryValue = variableName + "_like_" + variableValue; + @Test + public void testVariableValueLessThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lteq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) - .then().expect() - .statusCode(Status.OK.getStatusCode()) + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).variableValueLessThanOrEqual("varName", "varValue"); + } + + @Test + public void testVariableValueLikeAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).variableValueLike("varName", "varValue"); + } + + @Test + public void testVariableValueNotEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) .when() - .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } - verify(mockedQuery).variableValueLike(variableName, variableValue); + @Test + public void testVariableValuesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesLikeIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueLike("varName", "varValue"); + } - // not equals - queryValue = variableName + "_neq_" + variableValue; + @Test + public void testVariableNamesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + given() - .queryParam("variables", queryValue) - .then().expect() - .statusCode(Status.OK.getStatusCode()) + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) .when() - .get(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } - verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + @Test + public void testVariableNamesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_CASE_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); } @Test diff --git a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricProcessInstanceRestServiceQueryTest.java b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricProcessInstanceRestServiceQueryTest.java index 8b091d889d1..56bd3764c6b 100644 --- a/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricProcessInstanceRestServiceQueryTest.java +++ b/engine-rest/engine-rest/src/test/java/org/camunda/bpm/engine/rest/history/HistoricProcessInstanceRestServiceQueryTest.java @@ -1172,99 +1172,452 @@ private void verifyProcessDefinitionKeyInListInvocation() { } @Test - public void testVariableParameters() { - // equals + public void testVariableValueEquals() { String variableName = "varName"; String variableValue = "varValue"; String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + } + + @Test + public void testVariableValueGreaterThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gt_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + } + + @Test + public void testVariableValueGreaterThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_gteq_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + } + + @Test + public void testVariableValueLessThan() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lt_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueLessThan(variableName, variableValue); + } + + @Test + public void testVariableValueLessThanEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_lteq_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + } + + @Test + public void testVariableValueLike() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueLike(variableName, variableValue); + } + + @Test + public void testVariableValueNotEquals() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variables", queryValue) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + } + + @Test + public void testVariableValuesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + @Test + public void testVariableValuesLikeIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_like_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableValuesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueLike(variableName, variableValue); + verify(mockedQuery).matchVariableValuesIgnoreCase(); + } + + + @Test + public void testVariableNamesEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_eq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCase() { + String variableName = "varName"; + String variableValue = "varValue"; + String queryValue = variableName + "_neq_" + variableValue; + given().queryParam("variables", queryValue).queryParam("variableNamesIgnoreCase", true) + .then().expect().statusCode(Status.OK.getStatusCode()) + .when().get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).matchVariableNamesIgnoreCase(); + } + + @Test + public void testVariableValueEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() - .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueEquals(variableName, variableValue); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableValueGreaterThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gt"); + + List> variables = new ArrayList>(); + variables.add(variableJson); - // greater then - queryValue = variableName + "_gt_" + variableValue; + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() - .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueGreaterThan(variableName, variableValue); + verify(mockedQuery).variableValueGreaterThan("varName", "varValue"); + } + + @Test + public void testVariableValueGreaterThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "gteq"); - // greater then equals - queryValue = variableName + "_gteq_" + variableValue; + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() - .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueGreaterThanOrEqual(variableName, variableValue); + verify(mockedQuery).variableValueGreaterThanOrEqual("varName", "varValue"); + } + + @Test + public void testVariableValueLessThanAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lt"); - // lower then - queryValue = variableName + "_lt_" + variableValue; + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() - .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueLessThan(variableName, variableValue); + verify(mockedQuery).variableValueLessThan("varName", "varValue"); + } - // lower then equals - queryValue = variableName + "_lteq_" + variableValue; + @Test + public void testVariableValueLessThanEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "lteq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() - .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueLessThanOrEqual(variableName, variableValue); + verify(mockedQuery).variableValueLessThanOrEqual("varName", "varValue"); + } - // like - queryValue = variableName + "_like_" + variableValue; + @Test + public void testVariableValueLikeAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() - .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueLike(variableName, variableValue); + verify(mockedQuery).variableValueLike("varName", "varValue"); + } - // not equals - queryValue = variableName + "_neq_" + variableValue; + @Test + public void testVariableValueNotEqualsAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); given() - .queryParam("variables", queryValue) + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) .then() .expect() .statusCode(Status.OK.getStatusCode()) .when() - .get(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); - verify(mockedQuery).variableValueNotEquals(variableName, variableValue); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); + } + + @Test + public void testVariableValuesLikeIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "like"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableValuesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableValuesIgnoreCase(); + verify(mockedQuery).variableValueLike("varName", "varValue"); + } + + + @Test + public void testVariableNamesEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "eq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueEquals("varName", "varValue"); + } + + @Test + public void testVariableNamesNotEqualsIgnoreCaseAsPost() { + Map variableJson = new HashMap(); + variableJson.put("name", "varName"); + variableJson.put("value", "varValue"); + variableJson.put("operator", "neq"); + + List> variables = new ArrayList>(); + variables.add(variableJson); + + Map json = new HashMap(); + json.put("variables", variables); + json.put("variableNamesIgnoreCase", true); + + given() + .contentType(POST_JSON_CONTENT_TYPE) + .body(json) + .then() + .expect() + .statusCode(Status.OK.getStatusCode()) + .when() + .post(HISTORIC_PROCESS_INSTANCE_RESOURCE_URL); + + verify(mockedQuery).matchVariableNamesIgnoreCase(); + verify(mockedQuery).variableValueNotEquals("varName", "varValue"); } @Test diff --git a/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstanceQuery.java b/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstanceQuery.java index 4bcb0f64e60..f9d221df034 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstanceQuery.java +++ b/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstanceQuery.java @@ -134,6 +134,16 @@ public interface HistoricCaseInstanceQuery extends Query, U> extends protected List queryVariableValues = new ArrayList(); + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; + public AbstractVariableQueryImpl() { } @@ -95,6 +98,24 @@ public T variableValueLike(String name, String value) { addVariable(name, value, QueryOperator.LIKE, true); return (T)this; } + + @SuppressWarnings("unchecked") + public T matchVariableNamesIgnoreCase() { + this.variableNamesIgnoreCase = true; + for (QueryVariableValue variable : this.queryVariableValues) { + variable.setVariableNameIgnoreCase(true); + } + return (T)this; + } + + @SuppressWarnings("unchecked") + public T matchVariableValuesIgnoreCase() { + this.variableValuesIgnoreCase = true; + for (QueryVariableValue variable : this.queryVariableValues) { + variable.setVariableValueIgnoreCase(true); + } + return (T)this; + } protected void addVariable(String name, Object value, QueryOperator operator, boolean processInstanceScope) { ensureNotNull(NotValidException.class, "name", name); @@ -113,7 +134,10 @@ protected void addVariable(String name, Object value, QueryOperator operator, bo throw new NotValidException("Booleans and null cannot be used in 'like' condition"); } } - queryVariableValues.add(new QueryVariableValue(name, value, operator, processInstanceScope)); + + boolean shouldMatchVariableValuesIgnoreCase = Boolean.TRUE.equals(variableValuesIgnoreCase) && value != null && String.class.isAssignableFrom(value.getClass()); + boolean shouldMatchVariableNamesIgnoreCase = Boolean.TRUE.equals(variableNamesIgnoreCase); + queryVariableValues.add(new QueryVariableValue(name, value, operator, processInstanceScope, shouldMatchVariableNamesIgnoreCase, shouldMatchVariableValuesIgnoreCase)); } private boolean isBoolean(Object value) { @@ -138,5 +162,12 @@ public List getQueryVariableValues() { return queryVariableValues; } + public Boolean isVariableNamesIgnoreCase() { + return variableNamesIgnoreCase; + } + + public Boolean isVariableValuesIgnoreCase() { + return variableValuesIgnoreCase; + } } diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/QueryVariableValue.java b/engine/src/main/java/org/camunda/bpm/engine/impl/QueryVariableValue.java index 848623e9f0d..ad40d2d5041 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/QueryVariableValue.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/QueryVariableValue.java @@ -42,10 +42,16 @@ public class QueryVariableValue implements Serializable { protected boolean variableValueIgnoreCase; public QueryVariableValue(String name, Object value, QueryOperator operator, boolean local) { + this(name, value, operator, local, false, false); + } + + public QueryVariableValue(String name, Object value, QueryOperator operator, boolean local, boolean variableNameIgnoreCase, boolean variableValueIgnoreCase) { this.name = name; this.value = Variables.untypedValue(value); this.operator = operator; this.local = local; + this.variableNameIgnoreCase = variableNameIgnoreCase; + this.variableValueIgnoreCase = variableValueIgnoreCase; } public void initialize(VariableSerializers serializers) { diff --git a/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryVariableValue.java b/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryVariableValue.java index 07ee701f637..020465bed16 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryVariableValue.java +++ b/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryVariableValue.java @@ -46,10 +46,8 @@ public TaskQueryVariableValue(String name, Object value, QueryOperator operator, } public TaskQueryVariableValue(String name, Object value, QueryOperator operator, boolean isTaskVariable, boolean isProcessInstanceVariable, boolean variableNameIgnoreCase, boolean variableValueIgnoreCase) { - super(name, value, operator, isTaskVariable); + super(name, value, operator, isTaskVariable, variableNameIgnoreCase, variableValueIgnoreCase); this.isProcessInstanceVariable = isProcessInstanceVariable; - this.variableNameIgnoreCase = variableNameIgnoreCase; - this.variableValueIgnoreCase = variableValueIgnoreCase; } diff --git a/engine/src/main/java/org/camunda/bpm/engine/runtime/CaseExecutionQuery.java b/engine/src/main/java/org/camunda/bpm/engine/runtime/CaseExecutionQuery.java index 3bc9a5979df..e220bcf3d92 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/runtime/CaseExecutionQuery.java +++ b/engine/src/main/java/org/camunda/bpm/engine/runtime/CaseExecutionQuery.java @@ -104,6 +104,16 @@ public interface CaseExecutionQuery extends Query{ /** Only select executions which contain an activity with the given id. **/ ExecutionQuery activityId(String activityId); + /** + * The query will match the names of variables in a case-insensitive way. + */ + ExecutionQuery matchVariableNamesIgnoreCase(); + + /** + * The query will match the values of variables in a case-insensitive way. + */ + ExecutionQuery matchVariableValuesIgnoreCase(); + /** * Only select executions which have a local variable with the given value. The type * of variable is determined based on the value, using types configured in diff --git a/engine/src/main/java/org/camunda/bpm/engine/runtime/ProcessInstanceQuery.java b/engine/src/main/java/org/camunda/bpm/engine/runtime/ProcessInstanceQuery.java index 9ccc6a5cfb3..de4b4de2de4 100644 --- a/engine/src/main/java/org/camunda/bpm/engine/runtime/ProcessInstanceQuery.java +++ b/engine/src/main/java/org/camunda/bpm/engine/runtime/ProcessInstanceQuery.java @@ -113,6 +113,16 @@ public interface ProcessInstanceQuery extends Query + * Note: This affects all variableValueXXX filters: + *
    + *
  • {@link #variableValueEquals(String, Object)}
  • + *
  • {@link #variableValueGreaterThan(String, Object)}
  • + *
  • {@link #variableValueGreaterThanOrEqual(String, Object)}
  • + *
  • {@link #variableValueLessThan(String, Object)}
  • + *
  • {@link #variableValueLessThanOrEqual(String, Object)}
  • + *
  • {@link #variableValueLike(String, String)}
  • + *
  • {@link #variableValueNotEquals(String, Object)}
  • + *
+ * It does not affect: + *
    + *
  • {@link #variableName(String)}
  • + *
  • {@link #variableNameIn(String...)}
  • + *
  • {@link #variableNameLike(String)}
  • + *
      + */ + VariableInstanceQuery matchVariableNamesIgnoreCase(); + + /** + * The query will match the values of variables in a case-insensitive way.
      + * Note: This affects all variableValueXXX filters: + *
        + *
      • {@link #variableValueEquals(String, Object)}
      • + *
      • {@link #variableValueGreaterThan(String, Object)}
      • + *
      • {@link #variableValueGreaterThanOrEqual(String, Object)}
      • + *
      • {@link #variableValueLessThan(String, Object)}
      • + *
      • {@link #variableValueLessThanOrEqual(String, Object)}
      • + *
      • {@link #variableValueLike(String, String)}
      • + *
      • {@link #variableValueNotEquals(String, Object)}
      • + *
      + */ + VariableInstanceQuery matchVariableValuesIgnoreCase(); + /** * Only select variables instances which have the given name and value. The type * of variable is determined based on the value, using types configured in diff --git a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/CaseExecution.xml b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/CaseExecution.xml index 826916269e2..a52165ec93f 100644 --- a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/CaseExecution.xml +++ b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/CaseExecution.xml @@ -221,8 +221,7 @@ from ${prefix}ACT_RU_VARIABLE where - NAME_= #{queryVariableValue.name} - + and RES.ID_ = CASE_EXECUTION_ID_ diff --git a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Commons.xml b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Commons.xml index 79cb418aaf6..b68b7b7ce64 100644 --- a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Commons.xml +++ b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Commons.xml @@ -83,6 +83,18 @@ ) + + + + UPPER(NAME_)= UPPER(#{queryVariableValue.name}) + + + NAME_= #{queryVariableValue.name} + + + ${collationForCaseSensitivity} + + = diff --git a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Execution.xml b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Execution.xml index b37bf40d269..fb4d9cdad67 100644 --- a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Execution.xml +++ b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Execution.xml @@ -337,8 +337,7 @@ from ${prefix}ACT_RU_VARIABLE WHERE - NAME_= #{queryVariableValue.name} - + and RES.ID_ = EXECUTION_ID_ @@ -450,7 +449,7 @@ from ${prefix}ACT_RU_VARIABLE WHERE - NAME_= #{queryVariableValue.name} + diff --git a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/HistoricCaseInstance.xml b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/HistoricCaseInstance.xml index 375568f0080..09e4dc86fb2 100644 --- a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/HistoricCaseInstance.xml +++ b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/HistoricCaseInstance.xml @@ -252,7 +252,7 @@ from ${prefix}ACT_HI_VARINST WHERE - NAME_= #{queryVariableValue.name} + AND CASE_INST_ID_ = RES.CASE_INST_ID_ diff --git a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/HistoricProcessInstance.xml b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/HistoricProcessInstance.xml index 947872dce57..5827a9b8588 100644 --- a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/HistoricProcessInstance.xml +++ b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/HistoricProcessInstance.xml @@ -439,7 +439,7 @@ from ${prefix}ACT_HI_VARINST WHERE - NAME_= #{queryVariableValue.name} + AND PROC_INST_ID_ = SELF.PROC_INST_ID_ diff --git a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Task.xml b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Task.xml index 17af784f7e7..db3b2f81b68 100644 --- a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Task.xml +++ b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/Task.xml @@ -595,16 +595,7 @@ from ${prefix}ACT_RU_VARIABLE WHERE - - - UPPER(NAME_)= UPPER(#{queryVariableValue.name}) - - - NAME_= #{queryVariableValue.name} - - - ${collationForCaseSensitivity} - + and RES.ID_ = TASK_ID_ diff --git a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/VariableInstance.xml b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/VariableInstance.xml index 5a2c3348280..2fa31257c38 100644 --- a/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/VariableInstance.xml +++ b/engine/src/main/resources/org/camunda/bpm/engine/impl/mapping/entity/VariableInstance.xml @@ -432,7 +432,8 @@ - and RES.NAME_= #{queryVariableValue.name} + and + diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/AbstractVariableIgnoreCaseTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/AbstractVariableIgnoreCaseTest.java new file mode 100644 index 00000000000..0590d7157c4 --- /dev/null +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/AbstractVariableIgnoreCaseTest.java @@ -0,0 +1,185 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.test.api.variables; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.impl.AbstractVariableQueryImpl; +import org.camunda.bpm.engine.test.ProcessEngineRule; +import org.junit.Rule; +import org.junit.Test; + +@SuppressWarnings("unchecked") +public abstract class AbstractVariableIgnoreCaseTest { + + protected abstract T createQuery(); + + protected abstract void assertThatTwoInstancesAreEqual(U one, U two); + + protected static final String VARIABLE_NAME = "variableName"; + protected static final String VARIABLE_NAME_LC = VARIABLE_NAME.toLowerCase(); + protected static final String VARIABLE_VALUE = "variableValue"; + protected static final String VARIABLE_VALUE_LC = VARIABLE_VALUE.toLowerCase(); + protected static final String VARIABLE_VALUE_LC_LIKE = "%" + VARIABLE_VALUE_LC.substring(2, 10) + "%"; + protected static final String VARIABLE_VALUE_NE = "nonExistent"; + protected static Map VARIABLES = new HashMap<>(); + static { + VARIABLES.put(VARIABLE_NAME, VARIABLE_VALUE); + } + + @Rule + public ProcessEngineRule engineRule = new ProcessEngineRule(); + + public U instance; + + protected T queryNameIgnoreCase() { + return (T) createQuery().matchVariableNamesIgnoreCase(); + } + + protected T queryValueIgnoreCase() { + return (T) createQuery().matchVariableValuesIgnoreCase(); + } + + protected T queryNameValueIgnoreCase() { + return (T) queryNameIgnoreCase().matchVariableValuesIgnoreCase(); + } + + protected void assertThatListContainsOnlyExpectedElement(List instances, U instance) { + assertThat(instances.size()).isEqualTo(1); + assertThatTwoInstancesAreEqual(instances.get(0), instance); + } + + @Test + public void testVariableNameEqualsIgnoreCase() { + // given + // when + List eq = queryNameIgnoreCase().variableValueEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List eqNameLC = queryNameIgnoreCase().variableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List eqValueLC = queryNameIgnoreCase().variableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List eqNameValueLC = queryNameIgnoreCase().variableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + + // then + assertThatListContainsOnlyExpectedElement(eq, instance); + assertThatListContainsOnlyExpectedElement(eqNameLC, instance); + assertThat(eqValueLC).isEmpty(); + assertThat(eqNameValueLC).isEmpty(); + } + + @Test + public void testVariableNameNotEqualsIgnoreCase() { + // given + // when + List neq = queryNameIgnoreCase().variableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List neqNameLC = queryNameIgnoreCase().variableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List neqValueNE = queryNameIgnoreCase().variableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List neqNameLCValueNE = queryNameIgnoreCase().variableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThat(neq).isEmpty(); + assertThat(neqNameLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(neqValueNE, instance); + assertThatListContainsOnlyExpectedElement(neqNameLCValueNE, instance); + } + + @Test + public void testVariableValueEqualsIgnoreCase() { + // given + // when + List eq = queryValueIgnoreCase().variableValueEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List eqNameLC = queryValueIgnoreCase().variableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List eqValueLC = queryValueIgnoreCase().variableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List eqNameValueLC = queryValueIgnoreCase().variableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + + // then + assertThatListContainsOnlyExpectedElement(eq, instance); + assertThat(eqNameLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(eqValueLC, instance); + assertThat(eqNameValueLC).isEmpty(); + } + + @Test + public void testVariableValueNotEqualsIgnoreCase() { + // given + // when + List neq = queryValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List neqNameLC = queryValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List neqValueNE = queryValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List neqNameLCValueNE = queryValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThat(neq).isEmpty(); + assertThat(neqNameLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(neqValueNE, instance); + assertThat(neqNameLCValueNE).isEmpty(); + } + + @Test + public void testVariableValueLikeIgnoreCase() { + // given + // when + List like = queryNameValueIgnoreCase().variableValueLike(VARIABLE_NAME, VARIABLE_VALUE).list(); + List likeValueLC = queryValueIgnoreCase().variableValueLike(VARIABLE_NAME, VARIABLE_VALUE_LC_LIKE).list(); + + // then + assertThatListContainsOnlyExpectedElement(like, instance); + assertThatListContainsOnlyExpectedElement(likeValueLC, instance); + } + + @Test + public void testVariableNameAndValueEqualsIgnoreCase() { + // given + // when + List eq = queryNameValueIgnoreCase().variableValueEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List eqNameLC = queryNameValueIgnoreCase().variableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List eqValueLC = queryNameValueIgnoreCase().variableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List eqValueNE = queryNameValueIgnoreCase().variableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List eqNameValueLC = queryNameValueIgnoreCase().variableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + List eqNameLCValueNE = queryNameValueIgnoreCase().variableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThatListContainsOnlyExpectedElement(eq, instance); + assertThatListContainsOnlyExpectedElement(eqNameLC, instance); + assertThatListContainsOnlyExpectedElement(eqValueLC, instance); + assertThat(eqValueNE).isEmpty(); + assertThatListContainsOnlyExpectedElement(eqNameValueLC, instance); + assertThat(eqNameLCValueNE).isEmpty(); + } + + @Test + public void testVariableNameAndValueNotEqualsIgnoreCase() { + // given + // when + List neq = queryNameValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List neqNameLC = queryNameValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List neqValueLC = queryNameValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List neqValueNE = queryNameValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List neqNameValueLC = queryNameValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + List neqNameLCValueNE = queryNameValueIgnoreCase().variableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThat(neq).isEmpty(); + assertThat(neqNameLC).isEmpty(); + assertThat(neqValueLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(neqValueNE, instance); + assertThat(neqNameValueLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(neqNameLCValueNE, instance); + } +} diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/CaseExecutionQueryVariableIgnoreCaseTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/CaseExecutionQueryVariableIgnoreCaseTest.java new file mode 100644 index 00000000000..0cb9c7fe89a --- /dev/null +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/CaseExecutionQueryVariableIgnoreCaseTest.java @@ -0,0 +1,173 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.test.api.variables; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import org.camunda.bpm.engine.CaseService; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionQueryImpl; +import org.camunda.bpm.engine.repository.Deployment; +import org.camunda.bpm.engine.runtime.CaseExecution; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class CaseExecutionQueryVariableIgnoreCaseTest extends AbstractVariableIgnoreCaseTest { + + CaseService caseService; + RepositoryService repositoryService; + + @Before + public void init() { + caseService = engineRule.getCaseService(); + repositoryService = engineRule.getRepositoryService(); + + repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn").deploy(); + instance = caseService.withCaseDefinitionByKey("oneTaskCase").setVariables(VARIABLES).businessKey("oneTaskCase").create(); + } + + @After + public void tearDown() { + for (Deployment deployment : repositoryService.createDeploymentQuery().list()) { + repositoryService.deleteDeployment(deployment.getId(), true); + } + } + + @Override + protected CaseExecutionQueryImpl createQuery() { + return (CaseExecutionQueryImpl) caseService.createCaseExecutionQuery(); + } + + @Override + protected void assertThatTwoInstancesAreEqual(CaseExecution one, CaseExecution two) { + assertThat(one.getId()).isEqualTo(two.getId()); + } + + public void assertThatListContainsOnlyExpectedElements(List instances, CaseExecution instance) { + // normally we would only get one result. here we also get the corresponding CaseInstance + assertThat(instances.size()).isEqualTo(2); + assertThat(instances.get(0).getCaseInstanceId()).isEqualTo(instance.getCaseInstanceId()); + assertThat(instances.get(1).getCaseInstanceId()).isEqualTo(instance.getCaseInstanceId()); + } + + @Test + public void testCaseInstanceVariableNameEqualsIgnoreCase() { + // given + // when + List eq = queryNameIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List eqNameLC = queryNameIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List eqValueLC = queryNameIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List eqNameValueLC = queryNameIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + + // then + assertThatListContainsOnlyExpectedElements(eq, instance); + assertThatListContainsOnlyExpectedElements(eqNameLC, instance); + assertThat(eqValueLC).isEmpty(); + assertThat(eqNameValueLC).isEmpty(); + } + + @Test + public void testCaseInstanceVariableNameNotEqualsIgnoreCase() { + // given + // when + List neq = queryNameIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List neqNameLC = queryNameIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List neqValueNE = queryNameIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List neqNameLCValueNE = queryNameIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThat(neq).isEmpty(); + assertThat(neqNameLC).isEmpty(); + assertThatListContainsOnlyExpectedElements(neqValueNE, instance); + assertThatListContainsOnlyExpectedElements(neqNameLCValueNE, instance); + } + + @Test + public void testCaseInstanceVariableValueEqualsIgnoreCase() { + // given + // when + List eq = queryValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List eqNameLC = queryValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List eqValueLC = queryValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List eqNameValueLC = queryValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + + // then + assertThatListContainsOnlyExpectedElements(eq, instance); + assertThat(eqNameLC).isEmpty(); + assertThatListContainsOnlyExpectedElements(eqValueLC, instance); + assertThat(eqNameValueLC).isEmpty(); + } + + @Test + public void testCaseInstanceVariableValueNotEqualsIgnoreCase() { + // given + // when + List neq = queryValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List neqNameLC = queryValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List neqValueNE = queryValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List neqNameLCValueNE = queryValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThat(neq).isEmpty(); + assertThat(neqNameLC).isEmpty(); + assertThatListContainsOnlyExpectedElements(neqValueNE, instance); + assertThat(neqNameLCValueNE).isEmpty(); + } + + @Test + public void testCaseInstanceVariableNameAndValueEqualsIgnoreCase() { + // given + // when + List eq = queryNameValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List eqNameLC = queryNameValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List eqValueLC = queryNameValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List eqValueNE = queryNameValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List eqNameValueLC = queryNameValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + List eqNameLCValueNE = queryNameValueIgnoreCase().caseInstanceVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThatListContainsOnlyExpectedElements(eq, instance); + assertThatListContainsOnlyExpectedElements(eqNameLC, instance); + assertThatListContainsOnlyExpectedElements(eqValueLC, instance); + assertThat(eqValueNE).isEmpty(); + assertThatListContainsOnlyExpectedElements(eqNameValueLC, instance); + assertThat(eqNameLCValueNE).isEmpty(); + } + + @Test + public void testCaseInstanceVariableNameAndValueNotEqualsIgnoreCase() { + // given + // when + List neq = queryNameValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List neqNameLC = queryNameValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List neqValueLC = queryNameValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List neqValueNE = queryNameValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List neqNameValueLC = queryNameValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + List neqNameLCValueNE = queryNameValueIgnoreCase().caseInstanceVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThat(neq).isEmpty(); + assertThat(neqNameLC).isEmpty(); + assertThat(neqValueLC).isEmpty(); + assertThatListContainsOnlyExpectedElements(neqValueNE, instance); + assertThat(neqNameValueLC).isEmpty(); + assertThatListContainsOnlyExpectedElements(neqNameLCValueNE, instance); + } +} diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ExecutionQueryVariableIgnoreCaseTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ExecutionQueryVariableIgnoreCaseTest.java new file mode 100644 index 00000000000..6679ddd35f7 --- /dev/null +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ExecutionQueryVariableIgnoreCaseTest.java @@ -0,0 +1,166 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.test.api.variables; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.impl.ExecutionQueryImpl; +import org.camunda.bpm.engine.repository.Deployment; +import org.camunda.bpm.engine.runtime.Execution; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ExecutionQueryVariableIgnoreCaseTest extends AbstractVariableIgnoreCaseTest { + + RepositoryService repositoryService; + RuntimeService runtimeService; + + @Before + public void init() { + repositoryService = engineRule.getRepositoryService(); + runtimeService = engineRule.getRuntimeService(); + + repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml").deploy(); + instance = runtimeService.startProcessInstanceByKey("oneTaskProcess", VARIABLES); + } + + @After + public void tearDown() { + for (Deployment deployment : repositoryService.createDeploymentQuery().list()) { + repositoryService.deleteDeployment(deployment.getId(), true); + } + } + + @Override + protected ExecutionQueryImpl createQuery() { + return (ExecutionQueryImpl) runtimeService.createExecutionQuery(); + } + + @Override + protected void assertThatTwoInstancesAreEqual(Execution one, Execution two) { + assertThat(one.getId()).isEqualTo(two.getId()); + } + + @Test + public void testProcessVariableNameEqualsIgnoreCase() { + // given + // when + List eq = queryNameIgnoreCase().processVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List eqNameLC = queryNameIgnoreCase().processVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List eqValueLC = queryNameIgnoreCase().processVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List eqNameValueLC = queryNameIgnoreCase().processVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + + // then + assertThatListContainsOnlyExpectedElement(eq, instance); + assertThatListContainsOnlyExpectedElement(eqNameLC, instance); + assertThat(eqValueLC).isEmpty(); + assertThat(eqNameValueLC).isEmpty(); + } + + @Test + public void testProcessVariableNameNotEqualsIgnoreCase() { + // given + // when + List neq = queryNameIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List neqNameLC = queryNameIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List neqValueNE = queryNameIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List neqNameLCValueNE = queryNameIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThat(neq).isEmpty(); + assertThat(neqNameLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(neqValueNE, instance); + assertThatListContainsOnlyExpectedElement(neqNameLCValueNE, instance); + } + + @Test + public void testProcessVariableValueEqualsIgnoreCase() { + // given + // when + List eq = queryValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List eqNameLC = queryValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List eqValueLC = queryValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List eqNameValueLC = queryValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + + // then + assertThatListContainsOnlyExpectedElement(eq, instance); + assertThat(eqNameLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(eqValueLC, instance); + assertThat(eqNameValueLC).isEmpty(); + } + + @Test + public void testProcessVariableValueNotEqualsIgnoreCase() { + // given + // when + List neq = queryValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List neqNameLC = queryValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List neqValueNE = queryValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List neqNameLCValueNE = queryValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThat(neq).isEmpty(); + assertThat(neqNameLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(neqValueNE, instance); + assertThat(neqNameLCValueNE).isEmpty(); + } + + @Test + public void testProcessVariableNameAndValueEqualsIgnoreCase() { + // given + // when + List eq = queryNameValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List eqNameLC = queryNameValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List eqValueLC = queryNameValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List eqValueNE = queryNameValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List eqNameValueLC = queryNameValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + List eqNameLCValueNE = queryNameValueIgnoreCase().processVariableValueEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThatListContainsOnlyExpectedElement(eq, instance); + assertThatListContainsOnlyExpectedElement(eqNameLC, instance); + assertThatListContainsOnlyExpectedElement(eqValueLC, instance); + assertThat(eqValueNE).isEmpty(); + assertThatListContainsOnlyExpectedElement(eqNameValueLC, instance); + assertThat(eqNameLCValueNE).isEmpty(); + } + + @Test + public void testProcessVariableNameAndValueNotEqualsIgnoreCase() { + // given + // when + List neq = queryNameValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE).list(); + List neqNameLC = queryNameValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE).list(); + List neqValueLC = queryNameValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_LC).list(); + List neqValueNE = queryNameValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME, VARIABLE_VALUE_NE).list(); + List neqNameValueLC = queryNameValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_LC).list(); + List neqNameLCValueNE = queryNameValueIgnoreCase().processVariableValueNotEquals(VARIABLE_NAME_LC, VARIABLE_VALUE_NE).list(); + + // then + assertThat(neq).isEmpty(); + assertThat(neqNameLC).isEmpty(); + assertThat(neqValueLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(neqValueNE, instance); + assertThat(neqNameValueLC).isEmpty(); + assertThatListContainsOnlyExpectedElement(neqNameLCValueNE, instance); + } +} diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/HistoricCaseInstanceQueryVariableIgnoreCaseTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/HistoricCaseInstanceQueryVariableIgnoreCaseTest.java new file mode 100644 index 00000000000..224f337075d --- /dev/null +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/HistoricCaseInstanceQueryVariableIgnoreCaseTest.java @@ -0,0 +1,58 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.test.api.variables; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.history.HistoricCaseInstance; +import org.camunda.bpm.engine.impl.HistoricCaseInstanceQueryImpl; +import org.camunda.bpm.engine.repository.Deployment; +import org.junit.After; +import org.junit.Before; + +public class HistoricCaseInstanceQueryVariableIgnoreCaseTest extends AbstractVariableIgnoreCaseTest { + + RepositoryService repositoryService; + + @Before + public void init() { + repositoryService = engineRule.getRepositoryService(); + + repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn").deploy(); + engineRule.getCaseService().withCaseDefinitionByKey("oneTaskCase").setVariables(VARIABLES).businessKey("oneTaskCase").create(); + instance = engineRule.getHistoryService().createHistoricCaseInstanceQuery().singleResult(); + } + + @After + public void tearDown() { + for (Deployment deployment : repositoryService.createDeploymentQuery().list()) { + repositoryService.deleteDeployment(deployment.getId(), true); + } + } + + @Override + protected HistoricCaseInstanceQueryImpl createQuery() { + return (HistoricCaseInstanceQueryImpl) engineRule.getHistoryService().createHistoricCaseInstanceQuery(); + } + + @Override + protected void assertThatTwoInstancesAreEqual(HistoricCaseInstance one, HistoricCaseInstance two) { + assertThat(one.getId()).isEqualTo(two.getId()); + } + +} diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/HistoricProcessInstanceQueryVariableIgnoreCaseTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/HistoricProcessInstanceQueryVariableIgnoreCaseTest.java new file mode 100644 index 00000000000..eecdadb7951 --- /dev/null +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/HistoricProcessInstanceQueryVariableIgnoreCaseTest.java @@ -0,0 +1,45 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.test.api.variables; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl; +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Before; + +@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml") +public class HistoricProcessInstanceQueryVariableIgnoreCaseTest + extends AbstractVariableIgnoreCaseTest { + + @Before + public void init() { + engineRule.getRuntimeService().startProcessInstanceByKey("oneTaskProcess", VARIABLES); + instance = engineRule.getHistoryService().createHistoricProcessInstanceQuery().singleResult(); + } + + @Override + protected HistoricProcessInstanceQueryImpl createQuery() { + return (HistoricProcessInstanceQueryImpl) engineRule.getHistoryService().createHistoricProcessInstanceQuery(); + } + + @Override + protected void assertThatTwoInstancesAreEqual(HistoricProcessInstance one, HistoricProcessInstance two) { + assertThat(one.getId()).isEqualTo(two.getId()); + } +} diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ProcessInstanceQueryVariableIgnoreCaseTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ProcessInstanceQueryVariableIgnoreCaseTest.java new file mode 100644 index 00000000000..815072f1447 --- /dev/null +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/ProcessInstanceQueryVariableIgnoreCaseTest.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.test.api.variables; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Before; + +@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml") +public class ProcessInstanceQueryVariableIgnoreCaseTest extends AbstractVariableIgnoreCaseTest { + + RuntimeService runtimeService; + + @Before + public void init() { + runtimeService = engineRule.getRuntimeService(); + instance = runtimeService.startProcessInstanceByKey("oneTaskProcess", VARIABLES); + } + + protected ProcessInstanceQueryImpl createQuery() { + return (ProcessInstanceQueryImpl) runtimeService.createProcessInstanceQuery(); + } + + @Override + protected void assertThatTwoInstancesAreEqual(ProcessInstance one, ProcessInstance two) { + assertThat(one.getId()).isEqualTo(two.getId()); + } +} diff --git a/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/VariableInstanceQueryVariableIgnoreCaseTest.java b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/VariableInstanceQueryVariableIgnoreCaseTest.java new file mode 100644 index 00000000000..f7566eb1462 --- /dev/null +++ b/engine/src/test/java/org/camunda/bpm/engine/test/api/variables/VariableInstanceQueryVariableIgnoreCaseTest.java @@ -0,0 +1,48 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.test.api.variables; + +import org.assertj.core.api.Assertions; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.impl.VariableInstanceQueryImpl; +import org.camunda.bpm.engine.runtime.VariableInstance; +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Before; + +@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" }) +public class VariableInstanceQueryVariableIgnoreCaseTest extends AbstractVariableIgnoreCaseTest { + + RuntimeService runtimeService; + + @Before + public void init() { + runtimeService = engineRule.getRuntimeService(); + + runtimeService.startProcessInstanceByKey("oneTaskProcess", VARIABLES); + instance = runtimeService.createVariableInstanceQuery().singleResult(); + } + + @Override + protected VariableInstanceQueryImpl createQuery() { + return (VariableInstanceQueryImpl) runtimeService.createVariableInstanceQuery(); + } + + @Override + protected void assertThatTwoInstancesAreEqual(VariableInstance one, VariableInstance two) { + Assertions.assertThat(one.getId()).isEqualTo(two.getId()); + } +}