Add support for legacy "=" prefix.

This commit is contained in:
Michael Buckley 2021-02-04 13:31:56 -05:00
parent 7a0a252ad3
commit cb0f0161be
2 changed files with 18 additions and 2 deletions

View File

@ -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 + "\"");
}

View File

@ -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