Skip to content

Commit

Permalink
Fix greaterOrEqual/lessOrEqual dump (MID-4581)
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Apr 13, 2018
1 parent 2610fc4 commit f8f8691
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 12 deletions.
Expand Up @@ -27,8 +27,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.xml.namespace.QName;

public abstract class ComparativeFilter<T extends Object> extends PropertyValueFilter<T> {

private boolean equals;
Expand Down
Expand Up @@ -17,15 +17,11 @@

import com.evolveum.midpoint.prism.ExpressionWrapper;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.PrismContainerValue;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.prism.match.MatchingRuleRegistry;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -77,7 +73,7 @@ public GreaterFilter<T> clone() {

@Override
protected String getFilterName() {
return "GREATER";
return isEquals() ? "GREATER-OR-EQUAL" : "GREATER";
}

@Override
Expand Down
Expand Up @@ -72,7 +72,7 @@ public LessFilter<T> clone() {

@Override
protected String getFilterName() {
return "LESS";
return isEquals() ? "LESS-OR-EQUAL" : "LESS";
}

@Override
Expand Down
Expand Up @@ -331,7 +331,8 @@ public String debugDump(int indent) {
StringBuilder sb = new StringBuilder();
DebugUtil.indentDebugDump(sb, indent);
sb.append(getFilterName()).append(":");
return debugDump(indent, sb);
debugDump(indent, sb);
return sb.toString();
}

@Override
Expand All @@ -343,7 +344,7 @@ public String toString() {

protected abstract String getFilterName();

protected String debugDump(int indent, StringBuilder sb) {
protected void debugDump(int indent, StringBuilder sb) {
sb.append("\n");
DebugUtil.indentDebugDump(sb, indent+1);
sb.append("PATH: ");
Expand Down Expand Up @@ -400,8 +401,6 @@ protected String debugDump(int indent, StringBuilder sb) {
sb.append("MATCHING: ");
sb.append(matchingRule);
}

return sb.toString();
}

protected String toString(StringBuilder sb){
Expand Down
Expand Up @@ -536,6 +536,16 @@ public void test300Greater() throws Exception {
checkQueryRoundtripFile(UserType.class, q, TEST_NAME);
}

@Test
public void test305GreaterOrEqual() throws Exception {
final String TEST_NAME = "test305GreaterOrEqual";
displayTestTitle(TEST_NAME);
ObjectQuery q = QueryBuilder.queryFor(UserType.class, getPrismContext())
.item(UserType.F_COST_CENTER).ge("100000")
.build();
checkQueryRoundtripFile(UserType.class, q, TEST_NAME);
}

@Test
public void test310AllComparisons() throws Exception {
final String TEST_NAME = "test310AllComparisons";
Expand Down
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2010-2018 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ 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.
-->
<query xmlns="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
<filter>
<greaterOrEqual>
<path>c:costCenter</path>
<value>100000</value>
</greaterOrEqual>
</filter>
</query>

0 comments on commit f8f8691

Please sign in to comment.