Add support for legacy "=" prefix.
This commit is contained in:
parent
7a0a252ad3
commit
cb0f0161be
|
@ -79,6 +79,9 @@ public abstract class BaseParamWithPrefix<T extends BaseParam> extends BaseParam
|
|||
case "~":
|
||||
myPrefix = ParamPrefixEnum.APPROXIMATE;
|
||||
break;
|
||||
case "=":
|
||||
myPrefix = ParamPrefixEnum.EQUAL;
|
||||
break;
|
||||
default :
|
||||
throw new DataFormatException("Invalid prefix: \"" + prefix + "\"");
|
||||
}
|
||||
|
|
|
@ -41,11 +41,24 @@ public class DateParamTest {
|
|||
assertEquals(ParamPrefixEnum.GREATERTHAN, input.getPrefix());
|
||||
}
|
||||
|
||||
/**
|
||||
* We support legacy prefixes in addtion to the standard ParamPrefixEnum values.
|
||||
*
|
||||
* Testing here since BaseParamWithPrefix is abstract.
|
||||
*/
|
||||
@Test
|
||||
public void testLegacyPrefixParse() {
|
||||
DateParam input = new DateParam(">2020-01-01");
|
||||
assertEquals(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, translateLegacyPrefix(">="));
|
||||
assertEquals(ParamPrefixEnum.GREATERTHAN, translateLegacyPrefix(">"));
|
||||
assertEquals(ParamPrefixEnum.LESSTHAN_OR_EQUALS, translateLegacyPrefix("<="));
|
||||
assertEquals(ParamPrefixEnum.LESSTHAN, translateLegacyPrefix("<"));
|
||||
assertEquals(ParamPrefixEnum.APPROXIMATE, translateLegacyPrefix("~"));
|
||||
assertEquals(ParamPrefixEnum.EQUAL, translateLegacyPrefix("="));
|
||||
}
|
||||
|
||||
assertEquals(ParamPrefixEnum.GREATERTHAN, input.getPrefix());
|
||||
private ParamPrefixEnum translateLegacyPrefix(String legacyPrefix) {
|
||||
DateParam input = new DateParam(legacyPrefix + "2020-01-01");
|
||||
return input.getPrefix();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue