Skip to content

Commit

Permalink
adjust exception message
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Mar 14, 2024
1 parent 06ca1c7 commit 3cf671d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void validateStringParameter(final Map<String, Object> parameters,
Object fieldValue = parameters.get(fieldName);
if (!(fieldValue instanceof String)) {
throw new IllegalArgumentException(
String.format(Locale.ROOT, "Parameter [%s] cannot be cast to [%s]", fieldName, String.class.getName())
String.format(Locale.ROOT, "Parameter [%s] must be of %s type", fieldName, String.class.getName())
);
}
if (!allowEmpty && StringUtils.isEmpty(fieldValue.toString())) {
Expand All @@ -49,7 +49,7 @@ public static void validatePositiveIntegerParameter(
String fieldValueString = parameters.get(fieldName).toString();
if (!(NumberUtils.isParsable(fieldValueString))) {
throw new IllegalArgumentException(
String.format(Locale.ROOT, "Parameter [%s] cannot be cast to [%s]", fieldName, Number.class.getName())
String.format(Locale.ROOT, "Parameter [%s] must be of %s type", fieldName, Number.class.getName())
);
}
int fieldValueInt = NumberUtils.createInteger(fieldValueString);
Expand All @@ -75,7 +75,7 @@ public static void validateDoubleParameterWithinRange(
String fieldValueString = parameters.get(fieldName).toString();
if (!(NumberUtils.isParsable(fieldValueString))) {
throw new IllegalArgumentException(
String.format(Locale.ROOT, "Parameter [%s] cannot be cast to [%s]", fieldName, Number.class.getName())
String.format(Locale.ROOT, "Parameter [%s] must be of %s type", fieldName, Number.class.getName())
);
}
double fieldValueDouble = NumberUtils.createDouble(fieldValueString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testChunkerWithDelimiterFieldNotString() {
() -> new DelimiterChunker(Map.of(DELIMITER_FIELD, List.of("")))
);
Assert.assertEquals(
String.format(Locale.ROOT, "Parameter [%s] cannot be cast to [%s]", DELIMITER_FIELD, String.class.getName()),
String.format(Locale.ROOT, "Parameter [%s] must be of %s type", DELIMITER_FIELD, String.class.getName()),
exception.getMessage()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testValidateAndParseParameters_whenIllegalTokenLimitType_thenFail()
() -> fixedTokenLengthChunker.validateParameters(parameters)
);
assertEquals(
String.format(Locale.ROOT, "Parameter [%s] cannot be cast to [%s]", TOKEN_LIMIT_FIELD, Number.class.getName()),
String.format(Locale.ROOT, "Parameter [%s] must be of %s type", TOKEN_LIMIT_FIELD, Number.class.getName()),
illegalArgumentException.getMessage()
);
}
Expand All @@ -100,7 +100,7 @@ public void testValidateAndParseParameters_whenIllegalOverlapRateType_thenFail()
() -> fixedTokenLengthChunker.validateParameters(parameters)
);
assertEquals(
String.format(Locale.ROOT, "Parameter [%s] cannot be cast to [%s]", OVERLAP_RATE_FIELD, Number.class.getName()),
String.format(Locale.ROOT, "Parameter [%s] must be of %s type", OVERLAP_RATE_FIELD, Number.class.getName()),
illegalArgumentException.getMessage()
);
}
Expand All @@ -126,7 +126,7 @@ public void testValidateAndParseParameters_whenIllegalTokenizerType_thenFail() {
() -> fixedTokenLengthChunker.validateParameters(parameters)
);
assertEquals(
String.format(Locale.ROOT, "Parameter [%s] cannot be cast to [%s]", TOKENIZER_FIELD, String.class.getName()),
String.format(Locale.ROOT, "Parameter [%s] must be of %s type", TOKENIZER_FIELD, String.class.getName()),
illegalArgumentException.getMessage()
);
}
Expand Down

0 comments on commit 3cf671d

Please sign in to comment.