DATACMNS-107 - Added support for True and False as query method keywords.

This commit is contained in:
Oliver Gierke
2011-12-05 12:52:52 +01:00
parent f7b796dcee
commit 498f40b69f
2 changed files with 30 additions and 1 deletions

View File

@@ -187,13 +187,15 @@ public class Part {
WITHIN("Within"),
REGEX("Regex"),
EXISTS(0, "Exists"),
TRUE(0, "True"),
FALSE(0, "False"),
NEGATING_SIMPLE_PROPERTY("Not"),
SIMPLE_PROPERTY;
// Need to list them again explicitly as the order is important
// (esp. for IS_NULL, IS_NOT_NULL)
private static final List<Part.Type> ALL = Arrays.asList(IS_NOT_NULL, IS_NULL, BETWEEN, LESS_THAN, LESS_THAN_EQUAL, GREATER_THAN, GREATER_THAN_EQUAL,
NOT_LIKE, LIKE, NOT_IN, IN, NEAR, WITHIN, REGEX, EXISTS, NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);
NOT_LIKE, LIKE, NOT_IN, IN, NEAR, WITHIN, REGEX, EXISTS, TRUE, FALSE, NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);
private final List<String> keywords;
private final int numberOfArguments;

View File

@@ -259,6 +259,32 @@ public class PartTreeUnitTests {
assertThat(part.getParameterRequired(), is(true));
}
/**
* @see DATACMNS-107
*/
@Test
public void parsesTrueKeywordCorrectly() {
Part part = part("activeTrue");
assertThat(part.getType(), is(Type.TRUE));
assertThat(part.getProperty().toDotPath(), is("active"));
assertThat(part.getNumberOfArguments(), is(0));
assertThat(part.getParameterRequired(), is(false));
}
/**
* @see DATACMNS-107
*/
@Test
public void parsesFalseKeywordCorrectly() {
Part part = part("activeTrue");
assertThat(part.getType(), is(Type.TRUE));
assertThat(part.getProperty().toDotPath(), is("active"));
assertThat(part.getNumberOfArguments(), is(0));
assertThat(part.getParameterRequired(), is(false));
}
private PartTree partTree(String source) {
return new PartTree(source, User.class);
}
@@ -307,5 +333,6 @@ public class PartTreeUnitTests {
String firstname;
String lastname;
double[] location;
boolean active;
}
}