package nl.timfalken.copperkeys; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Map; import java.util.stream.Stream; import org.junit.jupiter.api.Test; import org.yaml.snakeyaml.Yaml; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; class ResourcePackTest { @Test @SuppressWarnings("unchecked") void packMcmetaIsValidAndHasPackFormat() throws IOException { Map root = new Yaml().load(Files.readString(Path.of("resource-pack/pack.mcmeta"))); Map pack = (Map) root.get("pack"); assertNotNull(pack.get("pack_format")); assertFalse(String.valueOf(pack.get("description")).isBlank()); assertTrue(((Number) pack.get("pack_format")).intValue() > 0); } @Test void advancementFilesAreValidMappings() throws IOException { Path dir = Path.of("src/main/resources/advancements"); try (Stream files = Files.list(dir)) { var json = files.filter(p -> p.getFileName().toString().endsWith(".json")).toList(); assertFalse(json.isEmpty()); Yaml yaml = new Yaml(); for (Path file : json) { Object loaded = yaml.load(Files.readString(file)); assertTrue(loaded instanceof Map, file.toString()); } } } }