diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/file/dump/DumpLog.java b/Plan/src/main/java/com/djrapitops/plan/utilities/file/dump/DumpLog.java index dd1098987..ff9f92403 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/file/dump/DumpLog.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/file/dump/DumpLog.java @@ -17,7 +17,7 @@ public class DumpLog { * * @param header The name of the header */ - void addHeader(String header) { + public void addHeader(String header) { addLine(""); addLine("--- " + header + " ---"); } @@ -28,7 +28,7 @@ public class DumpLog { * @param key The key * @param value The value */ - void add(String key, String value) { + public void add(String key, String value) { addLine(key + ": " + value); } @@ -38,7 +38,7 @@ public class DumpLog { * @param key The key * @param value The value */ - void add(String key, boolean value) { + public void add(String key, boolean value) { addLine(key + ": " + value); } @@ -49,7 +49,7 @@ public class DumpLog { * @param key The key * @param value The CharSequences stored in an Iterable */ - void add(String key, Iterable value) { + public void add(String key, Iterable value) { addLine(key + ": " + String.join(", ", value)); } @@ -58,7 +58,7 @@ public class DumpLog { * * @param lines The CharSequences stored in an Iterable */ - void addLines(Iterable lines) { + public void addLines(Iterable lines) { lines.forEach(this::addLine); } @@ -67,7 +67,7 @@ public class DumpLog { * * @param lines The lines */ - void addLines(CharSequence... lines) { + public void addLines(CharSequence... lines) { Arrays.stream(lines).forEach(this::addLine); } @@ -76,7 +76,7 @@ public class DumpLog { * * @param line The content of the line */ - private void addLine(CharSequence line) { + public void addLine(CharSequence line) { lines.add(line == null ? "\n" : line.toString()); } diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/utilities/dump/DumpLogTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/utilities/dump/DumpLogTest.java new file mode 100644 index 000000000..97d339e9a --- /dev/null +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/utilities/dump/DumpLogTest.java @@ -0,0 +1,40 @@ +package test.java.main.java.com.djrapitops.plan.utilities.dump; + +import main.java.com.djrapitops.plan.utilities.file.dump.DumpLog; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; + +/** + * @author Fuzzlemann + */ +public class DumpLogTest { + + @Test + public void testDumpLogCreation() { + DumpLog testLog = new DumpLog(); + + testLog.addHeader("Test Header"); + testLog.add("StringValue", "Test"); + testLog.add("BooleanValue", true); + testLog.add("IterableValue", Arrays.asList("Iterable 1", "Iterable 2")); + + testLog.addLine(new StringBuilder("CharSequence Test")); + testLog.addLines(new StringBuilder("CharSequences Test"), new StringBuilder("CharSequences Test")); + testLog.addLines(Arrays.asList("Iterable 1", "Iterable 2")); + + String expResult = "\n--- Test Header ---\n" + + "StringValue: Test\n" + + "BooleanValue: true\n" + + "IterableValue: Iterable 1, Iterable 2\n" + + "CharSequence Test\n" + + "CharSequences Test\n" + + "CharSequences Test\n" + + "Iterable 1\n" + + "Iterable 2"; + String result = testLog.toString(); + + Assert.assertEquals(expResult, result); + } +}