diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSetup.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSetup.java index 5a3d8fac7..18578cc0c 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSetup.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestItemSetup.java @@ -1,12 +1,19 @@ package io.github.thebusybiscuit.slimefun4.testing.tests.items; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import be.seeseemelk.mockbukkit.MockBukkit; import be.seeseemelk.mockbukkit.ServerMock; @@ -14,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup; import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup; import io.github.thebusybiscuit.slimefun4.testing.TestUtilities; import me.mrCookieSlime.Slimefun.SlimefunPlugin; +import me.mrCookieSlime.Slimefun.Objects.Category; @TestMethodOrder(value = OrderAnnotation.class) public class TestItemSetup { @@ -49,4 +57,17 @@ public class TestItemSetup { public void testWikiSetup() { Assertions.assertDoesNotThrow(() -> PostSetup.setupWiki()); } + + @Test + @Order(value = 3) + public void testCategoryTranslations() throws IOException { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/languages/categories_en.yml"), StandardCharsets.UTF_8))) { + FileConfiguration config = YamlConfiguration.loadConfiguration(reader); + + for (Category category : SlimefunPlugin.getRegistry().getCategories()) { + String path = category.getKey().getNamespace() + '.' + category.getKey().getKey(); + Assertions.assertTrue(config.contains(path)); + } + } + } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/researches/TestResearchSetup.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/researches/TestResearchSetup.java index 09d2c75ac..1b7d67d7d 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/researches/TestResearchSetup.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/researches/TestResearchSetup.java @@ -1,14 +1,26 @@ package io.github.thebusybiscuit.slimefun4.testing.tests.researches; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import be.seeseemelk.mockbukkit.MockBukkit; +import io.github.thebusybiscuit.slimefun4.core.researching.Research; import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; import me.mrCookieSlime.Slimefun.SlimefunPlugin; +@TestMethodOrder(value = OrderAnnotation.class) public class TestResearchSetup { @BeforeAll @@ -23,14 +35,29 @@ public class TestResearchSetup { } @Test + @Order(value = 1) public void testForExceptions() { // Not really ideal but still important to test. // Research amount is variable, so we can't test for that. // We are really only concerned about any runtime exceptions here. + SlimefunPlugin.getRegistry().setResearchingEnabled(true); Assertions.assertDoesNotThrow(() -> ResearchSetup.setupResearches()); // Running it a second time should NOT be allowed. Assertions.assertThrows(UnsupportedOperationException.class, () -> ResearchSetup.setupResearches()); } + @Test + @Order(value = 2) + public void testResearchTranslations() throws IOException { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/languages/researches_en.yml"), StandardCharsets.UTF_8))) { + FileConfiguration config = YamlConfiguration.loadConfiguration(reader); + + for (Research research : SlimefunPlugin.getRegistry().getResearches()) { + String path = research.getKey().getNamespace() + '.' + research.getKey().getKey(); + Assertions.assertTrue(config.contains(path)); + } + } + } + }