From a3650c017e30492abb5eb9c760afcb9dbe7b62b3 Mon Sep 17 00:00:00 2001 From: mark-terry <36909937+mark-terry@users.noreply.github.com> Date: Mon, 21 Dec 2020 08:38:01 +1000 Subject: [PATCH] TOML error string fix. (#401) Signed-off-by: Mark Terry --- src/main/java/net/consensys/orion/config/Config.java | 7 ++++--- .../java/net/consensys/orion/config/TomlConfigTest.java | 8 +------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/consensys/orion/config/Config.java b/src/main/java/net/consensys/orion/config/Config.java index b1c1134c..4b28fc43 100644 --- a/src/main/java/net/consensys/orion/config/Config.java +++ b/src/main/java/net/consensys/orion/config/Config.java @@ -71,14 +71,15 @@ public static Config load(final InputStream is) throws IOException { } @VisibleForTesting - public static Config load(final InputStream is, Map env) throws IOException { + public static Config load(final InputStream is, final Map env) throws IOException { return load(Configuration.fromToml(is, SCHEMA), env); } - private static Config load(final Configuration configuration, Map env) { + private static Config load(final Configuration configuration, final Map env) { final List errors = configuration.errors(); if (!errors.isEmpty()) { - String errorString = errors.stream().limit(5).map(ConfigurationError::toString).collect(Collectors.joining("\n")); + String errorString = + errors.stream().limit(5).map(ConfigurationError::getMessage).collect(Collectors.joining("\n")); if (errors.size() > 5) { errorString += "\n..."; } diff --git a/src/test/java/net/consensys/orion/config/TomlConfigTest.java b/src/test/java/net/consensys/orion/config/TomlConfigTest.java index 1297b399..dfeb09e3 100644 --- a/src/test/java/net/consensys/orion/config/TomlConfigTest.java +++ b/src/test/java/net/consensys/orion/config/TomlConfigTest.java @@ -136,16 +136,10 @@ void invalidConfigsThrowException() { final ConfigException e = assertThrows( ConfigException.class, () -> Config.load(this.getClass().getClassLoader().getResourceAsStream("invalidConfigTest.toml"))); - final String tuweniPrefix = "org.apache.tuweni.config.ConfigurationError: "; - final String message = tuweniPrefix - + "Value of property 'clienturl' is not a valid URL (line 4, column 1)\n" - + tuweniPrefix + final String message = "Value of property 'clienturl' is not a valid URL (line 4, column 1)\n" + "Value of property 'storage' must have storage type of \"leveldb\", \"mapdb\", \"sql\" or \"memory\" (line 11, column 1)\n" - + tuweniPrefix + "Value of property 'othernodes' is not a valid URL (line 6, column 1)\n" - + tuweniPrefix + "Value of property 'othernodes' is not a valid URL (line 6, column 1)\n" - + tuweniPrefix + "Value of property 'tlsservertrust' should be \"whitelist\", \"ca\", \"ca-or-whitelist\", \"tofu\", \"insecure-tofa\", \"ca-or-tofu\", \"insecure-ca-or-tofa\", \"insecure-no-validation\", \"insecure-record\", or \"insecure-ca-or-record\" (line 9, column 1)\n" + "..."; assertEquals(message, e.getMessage());