fix junit

This commit is contained in:
Anthony Stirling 2025-07-02 16:33:27 +01:00
parent a6fee5e90f
commit 9ebb4a3c31
2 changed files with 6 additions and 8 deletions

View File

@ -1,6 +1,7 @@
package stirling.software.common.util; package stirling.software.common.util;
import java.io.IOException; import java.io.IOException;
import java.text.MessageFormat;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -104,7 +105,7 @@ public class ExceptionUtils {
*/ */
public static IOException createIOException( public static IOException createIOException(
String messageKey, String defaultMessage, Exception cause, Object... args) { String messageKey, String defaultMessage, Exception cause, Object... args) {
String message = String.format(defaultMessage, args); String message = MessageFormat.format(defaultMessage, args);
return new IOException(message, cause); return new IOException(message, cause);
} }
@ -119,7 +120,7 @@ public class ExceptionUtils {
*/ */
public static RuntimeException createRuntimeException( public static RuntimeException createRuntimeException(
String messageKey, String defaultMessage, Exception cause, Object... args) { String messageKey, String defaultMessage, Exception cause, Object... args) {
String message = String.format(defaultMessage, args); String message = MessageFormat.format(defaultMessage, args);
return new RuntimeException(message, cause); return new RuntimeException(message, cause);
} }
@ -133,7 +134,7 @@ public class ExceptionUtils {
*/ */
public static IllegalArgumentException createIllegalArgumentException( public static IllegalArgumentException createIllegalArgumentException(
String messageKey, String defaultMessage, Object... args) { String messageKey, String defaultMessage, Object... args) {
String message = String.format(defaultMessage, args); String message = MessageFormat.format(defaultMessage, args);
return new IllegalArgumentException(message); return new IllegalArgumentException(message);
} }

View File

@ -56,11 +56,8 @@ public class ConvertWebsiteToPDF {
} }
// Validate the URL format // Validate the URL format
if (!URL.matches("^https?://.*") || !GeneralUtils.isValidURL(URL)) { if (!URL.matches("^https?://.*") || !GeneralUtils.isValidURL(URL)) {
throw ExceptionUtils.createIllegalArgumentException( throw ExceptionUtils.createInvalidArgumentException(
"error.invalidFormat", "URL", "provided format is invalid");
"Invalid {0} format: {1}",
"URL",
"provided format is invalid");
} }
// validate the URL is reachable // validate the URL is reachable