diff --git a/confectory-core/src/main/java/net/obvj/confectory/source/StringSource.java b/confectory-core/src/main/java/net/obvj/confectory/source/StringSource.java index 149e1960..ece89945 100644 --- a/confectory-core/src/main/java/net/obvj/confectory/source/StringSource.java +++ b/confectory-core/src/main/java/net/obvj/confectory/source/StringSource.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Objects; +import java.util.UUID; import net.obvj.confectory.ConfigurationSourceException; import net.obvj.confectory.mapper.Mapper; @@ -32,6 +33,7 @@ */ public class StringSource extends AbstractSource implements Source { + private final String uuid; /** * Builds a new configuration source from the specified string. * @@ -40,6 +42,7 @@ public class StringSource extends AbstractSource implements Source public StringSource(String source) { super(Objects.requireNonNull(source, "The source string must not be null")); + uuid = UUID.randomUUID().toString(); } @Override @@ -56,4 +59,10 @@ public T load(Mapper mapper) } } + @Override + public String toString() + { + return new StringBuilder().append(getClass().getSimpleName()).append("(").append(uuid).append(")") + .toString(); + } } diff --git a/confectory-core/src/test/java/net/obvj/confectory/ConfigurationTest.java b/confectory-core/src/test/java/net/obvj/confectory/ConfigurationTest.java index 4e9c5b42..7e94430f 100644 --- a/confectory-core/src/test/java/net/obvj/confectory/ConfigurationTest.java +++ b/confectory-core/src/test/java/net/obvj/confectory/ConfigurationTest.java @@ -96,10 +96,10 @@ void equalsAndHashCode_notSimilarObjectsPlacedInAHashSet_differentObject() void toString_validString() { assertThat(CONFIG_NS1_STRING_1.toString().replaceAll("\"", ""), - containsAll("namespace:" + NAMESPACE1, "source:" + SOURCE_STRING1, "precedence:1")); + containsAll("namespace:" + NAMESPACE1, "source:StringSource", "precedence:1")); assertThat(CONFIG_NS1_STRING_1B.toString().replaceAll("\"", ""), - containsAll("namespace:" + NAMESPACE1, "source:" + SOURCE_STRING1, "precedence:2")); + containsAll("namespace:" + NAMESPACE1, "source:StringSource", "precedence:2")); } @Test