From 32885e09df3226534d03e3210dbbc5d660924063 Mon Sep 17 00:00:00 2001 From: Juuxel Date: Sun, 21 Apr 2019 13:31:20 +0300 Subject: [PATCH] Fix some bugs with potted plants, add tests for Identifier --- .../gens/block/PottedPlantLootTable.kt | 2 +- .../gens/block/PottedPlantModel.kt | 2 +- .../gens/block/TrapdoorBlockModel.kt | 6 +-- .../jsonfactory/tests/IdentifierTests.kt | 53 +++++++++++++++++++ 4 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 src/test/kotlin/io/github/cottonmc/jsonfactory/tests/IdentifierTests.kt diff --git a/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/PottedPlantLootTable.kt b/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/PottedPlantLootTable.kt index 51302d8..8af6834 100644 --- a/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/PottedPlantLootTable.kt +++ b/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/PottedPlantLootTable.kt @@ -10,7 +10,7 @@ import io.github.cottonmc.jsonfactory.output.loot.Pool import io.github.cottonmc.jsonfactory.output.prefixed object PottedPlantLootTable : ContentGenerator( - "Potted Plant Model", "loot_tables/blocks", GeneratorInfo.POTTED_PLANTS, + "Potted Plant Loot Table", "loot_tables/blocks", GeneratorInfo.POTTED_PLANTS, resourceRoot = ResourceRoot.Data ) { override fun generate(id: Identifier) = listOf( diff --git a/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/PottedPlantModel.kt b/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/PottedPlantModel.kt index 29c7d13..1f65421 100644 --- a/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/PottedPlantModel.kt +++ b/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/PottedPlantModel.kt @@ -11,7 +11,7 @@ object PottedPlantModel : ContentGenerator("Potted Plant Model", "models/block", Model( parent = Identifier.mc("block/flower_pot_cross"), textures = mapOf( - "plant" to id + "plant" to id.prefixPath("block/") ) ).prefixed("potted") ) diff --git a/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/TrapdoorBlockModel.kt b/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/TrapdoorBlockModel.kt index 396186c..fd9da95 100644 --- a/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/TrapdoorBlockModel.kt +++ b/src/main/kotlin/io/github/cottonmc/jsonfactory/gens/block/TrapdoorBlockModel.kt @@ -11,19 +11,19 @@ internal object TrapdoorBlockModel : ContentGenerator("Trapdoor Block Model", "m Model( parent = Identifier.mc("block/template_orientable_trapdoor_bottom"), textures = mapOf( - "texture" to id.prefixPath("block/").suffixPath("_trapdoor") + "texture" to id.wrapPath("block/", "_trapdoor") ) ).suffixed("trapdoor_bottom"), Model( parent = Identifier.mc("block/template_orientable_trapdoor_top"), textures = mapOf( - "texture" to id.prefixPath("block/").suffixPath("_trapdoor") + "texture" to id.wrapPath("block/", "_trapdoor") ) ).suffixed("trapdoor_top"), Model( parent = Identifier.mc("block/template_orientable_trapdoor_open"), textures = mapOf( - "texture" to id.prefixPath("block/").suffixPath("_trapdoor") + "texture" to id.wrapPath("block/", "_trapdoor") ) ).suffixed("trapdoor_open") ) diff --git a/src/test/kotlin/io/github/cottonmc/jsonfactory/tests/IdentifierTests.kt b/src/test/kotlin/io/github/cottonmc/jsonfactory/tests/IdentifierTests.kt new file mode 100644 index 0000000..faa8294 --- /dev/null +++ b/src/test/kotlin/io/github/cottonmc/jsonfactory/tests/IdentifierTests.kt @@ -0,0 +1,53 @@ +package io.github.cottonmc.jsonfactory.tests + +import io.github.cottonmc.jsonfactory.data.Identifier +import org.junit.jupiter.api.Test +import strikt.api.expectThat +import strikt.assertions.isEqualTo +import strikt.assertions.isNull + +class IdentifierTests { + private val base = Identifier("json_factory", "test") + + @Test + fun prefixPath() { + expectThat(base.prefixPath("my_prefix/")) + .isEqualTo(Identifier("json_factory", "my_prefix/test")) + } + + @Test + fun suffixPath() { + expectThat(base.suffixPath("/my_suffix")) + .isEqualTo(Identifier("json_factory", "test/my_suffix")) + } + + @Test + fun wrapPath() { + expectThat(base.wrapPath("my_prefix/", "/my_suffix")) + .isEqualTo(Identifier("json_factory", "my_prefix/test/my_suffix")) + } + + @Test + fun `wrapPath equals prefixPath + suffixPath`() { + expectThat(base.wrapPath("my_prefix/", "/my_suffix")) + .isEqualTo(base.prefixPath("my_prefix/").suffixPath("/my_suffix")) + } + + @Test + fun minecraft() { + expectThat(Identifier.mc("example")) + .isEqualTo(Identifier("minecraft", "example")) + } + + @Test + fun `Identifier from combined parts`() { + expectThat(Identifier("json_factory:test")) + .isEqualTo(base) + } + + @Test + fun `invalid Identifier from combined parts`() { + expectThat(Identifier.orNull("invalid identifier =D")) + .isNull() + } +}