From eeb8c37461f6923fa6d153b22841b37a0c83c26a Mon Sep 17 00:00:00 2001 From: Abel Date: Wed, 30 Oct 2024 23:30:16 +0100 Subject: [PATCH 1/6] Add test for org.bukkit.craftbukkit.entity.CraftMinecart#minecartEntityTypeToMaterial --- ....bukkit.craftbukkit.entity.CraftMine.patch | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 patches/server/1058-Add-test-for-org.bukkit.craftbukkit.entity.CraftMine.patch diff --git a/patches/server/1058-Add-test-for-org.bukkit.craftbukkit.entity.CraftMine.patch b/patches/server/1058-Add-test-for-org.bukkit.craftbukkit.entity.CraftMine.patch new file mode 100644 index 000000000000..1b3fe8c527c4 --- /dev/null +++ b/patches/server/1058-Add-test-for-org.bukkit.craftbukkit.entity.CraftMine.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Abel +Date: Wed, 30 Oct 2024 23:29:26 +0100 +Subject: [PATCH] Add test for + org.bukkit.craftbukkit.entity.CraftMinecart#minecartEntityTypeToMaterial + + +diff --git a/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java +new file mode 100644 +index 0000000000000000000000000000000000000000..ea7c81ecc5deedc198dc2c3618d5c4a06d656e84 +--- /dev/null ++++ b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java +@@ -0,0 +1,37 @@ ++package org.bukkit.craftbukkit.entity; ++ ++import java.util.stream.Stream; ++import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.item.Item; ++import net.minecraft.world.item.Items; ++import org.junit.jupiter.params.ParameterizedTest; ++import org.junit.jupiter.params.provider.Arguments; ++import org.junit.jupiter.params.provider.MethodSource; ++ ++import static org.junit.jupiter.api.Assertions.*; ++ ++class CraftMinecartTest { ++ ++ private static Stream minecartTypesAsArguments() { ++ ++ return Stream.of( ++ Arguments.of(EntityType.MINECART, Items.MINECART), ++ Arguments.of(EntityType.CHEST_MINECART, Items.CHEST_MINECART), ++ Arguments.of(EntityType.FURNACE_MINECART, Items.FURNACE_MINECART), ++ Arguments.of(EntityType.SPAWNER_MINECART, Items.MINECART), ++ Arguments.of(EntityType.COMMAND_BLOCK_MINECART, Items.COMMAND_BLOCK_MINECART), ++ Arguments.of(EntityType.HOPPER_MINECART, Items.HOPPER_MINECART), ++ Arguments.of(EntityType.TNT_MINECART, Items.TNT_MINECART) ++ ); ++ ++ } ++ ++ @ParameterizedTest ++ @MethodSource("minecartTypesAsArguments") ++ void minecartEntityTypeToMaterial(EntityType type, Item material) { ++ ++ assertEquals(CraftMinecart.minecartEntityTypeToMaterial(type), material, "EntityType %s doesn't match the material %s.".formatted(type.toString(), material.toString())); ++ ++ } ++ ++} From 176218c10c8a78c7c048802b900a90f773386e85 Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 31 Oct 2024 13:05:31 +0100 Subject: [PATCH 2/6] Made test not hard-coded and added it to corresponding patch --- ...et-Material-from-Boats-and-Minecarts.patch | 48 ++++++++++++++++++ ....bukkit.craftbukkit.entity.CraftMine.patch | 50 ------------------- 2 files changed, 48 insertions(+), 50 deletions(-) delete mode 100644 patches/server/1058-Add-test-for-org.bukkit.craftbukkit.entity.CraftMine.patch diff --git a/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch b/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch index 4194a22c1987..9cc02a9f1fe4 100644 --- a/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch +++ b/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch @@ -61,3 +61,51 @@ index ee010d53f8c671d17d68f3f43dca9978e23ac8ab..d35c1a10e58932b19c8053c5dacdc25f @Override public AbstractMinecart getHandle() { return (AbstractMinecart) this.entity; +diff --git a/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java +new file mode 100644 +index 0000000000000000000000000000000000000000..7dd69b97918100aacaa91dcec604990094134b2a +--- /dev/null ++++ b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java +@@ -0,0 +1,42 @@ ++package org.bukkit.craftbukkit.entity; ++ ++import java.util.ArrayList; ++import java.util.List; ++import java.util.stream.Stream; ++import net.minecraft.core.registries.BuiltInRegistries; ++import net.minecraft.resources.ResourceLocation; ++import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.item.Item; ++import net.minecraft.world.item.Items; ++import org.junit.jupiter.params.ParameterizedTest; ++import org.junit.jupiter.params.provider.Arguments; ++import org.junit.jupiter.params.provider.MethodSource; ++ ++import static org.junit.jupiter.api.Assertions.*; ++ ++class CraftMinecartTest { ++ ++ private static Stream minecartTypesAsArguments() { ++ ++ List arguments = new ArrayList<>(); ++ ++ BuiltInRegistries.ENTITY_TYPE.forEach(type -> { ++ if (type.toShortString().contains("minecart")) { ++ if (type == EntityType.SPAWNER_MINECART) arguments.add(Arguments.of(type, Items.MINECART)); ++ else arguments.add(Arguments.of(type, BuiltInRegistries.ITEM.get(ResourceLocation.fromNamespaceAndPath("minecraft", type.toShortString())).get().value())); ++ } ++ }); ++ ++ return arguments.stream(); ++ ++ } ++ ++ @ParameterizedTest ++ @MethodSource("minecartTypesAsArguments") ++ void minecartEntityTypeToMaterial(EntityType type, Item material) { ++ ++ assertEquals(CraftMinecart.minecartEntityTypeToMaterial(type), material, "EntityType %s doesn't match the material %s.".formatted(type.toString(), material.toString())); ++ ++ } ++ ++} diff --git a/patches/server/1058-Add-test-for-org.bukkit.craftbukkit.entity.CraftMine.patch b/patches/server/1058-Add-test-for-org.bukkit.craftbukkit.entity.CraftMine.patch deleted file mode 100644 index 1b3fe8c527c4..000000000000 --- a/patches/server/1058-Add-test-for-org.bukkit.craftbukkit.entity.CraftMine.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Abel -Date: Wed, 30 Oct 2024 23:29:26 +0100 -Subject: [PATCH] Add test for - org.bukkit.craftbukkit.entity.CraftMinecart#minecartEntityTypeToMaterial - - -diff --git a/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java -new file mode 100644 -index 0000000000000000000000000000000000000000..ea7c81ecc5deedc198dc2c3618d5c4a06d656e84 ---- /dev/null -+++ b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java -@@ -0,0 +1,37 @@ -+package org.bukkit.craftbukkit.entity; -+ -+import java.util.stream.Stream; -+import net.minecraft.world.entity.EntityType; -+import net.minecraft.world.item.Item; -+import net.minecraft.world.item.Items; -+import org.junit.jupiter.params.ParameterizedTest; -+import org.junit.jupiter.params.provider.Arguments; -+import org.junit.jupiter.params.provider.MethodSource; -+ -+import static org.junit.jupiter.api.Assertions.*; -+ -+class CraftMinecartTest { -+ -+ private static Stream minecartTypesAsArguments() { -+ -+ return Stream.of( -+ Arguments.of(EntityType.MINECART, Items.MINECART), -+ Arguments.of(EntityType.CHEST_MINECART, Items.CHEST_MINECART), -+ Arguments.of(EntityType.FURNACE_MINECART, Items.FURNACE_MINECART), -+ Arguments.of(EntityType.SPAWNER_MINECART, Items.MINECART), -+ Arguments.of(EntityType.COMMAND_BLOCK_MINECART, Items.COMMAND_BLOCK_MINECART), -+ Arguments.of(EntityType.HOPPER_MINECART, Items.HOPPER_MINECART), -+ Arguments.of(EntityType.TNT_MINECART, Items.TNT_MINECART) -+ ); -+ -+ } -+ -+ @ParameterizedTest -+ @MethodSource("minecartTypesAsArguments") -+ void minecartEntityTypeToMaterial(EntityType type, Item material) { -+ -+ assertEquals(CraftMinecart.minecartEntityTypeToMaterial(type), material, "EntityType %s doesn't match the material %s.".formatted(type.toString(), material.toString())); -+ -+ } -+ -+} From 5943982992ace5a093773e236ad64ea1c6dfa85e Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 31 Oct 2024 13:24:22 +0100 Subject: [PATCH 3/6] Add @AllFeatures --- .../0448-API-to-get-Material-from-Boats-and-Minecarts.patch | 6 ++++-- { | 0 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 { diff --git a/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch b/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch index 9cc02a9f1fe4..a26f4eaf2d10 100644 --- a/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch +++ b/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch @@ -63,10 +63,10 @@ index ee010d53f8c671d17d68f3f43dca9978e23ac8ab..d35c1a10e58932b19c8053c5dacdc25f return (AbstractMinecart) this.entity; diff --git a/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..7dd69b97918100aacaa91dcec604990094134b2a +index 0000000000000000000000000000000000000000..b05d9ea494cc2518fe2ce1d9107d19b4f50a46a5 --- /dev/null +++ b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java -@@ -0,0 +1,42 @@ +@@ -0,0 +1,44 @@ +package org.bukkit.craftbukkit.entity; + +import java.util.ArrayList; @@ -77,6 +77,7 @@ index 0000000000000000000000000000000000000000..7dd69b97918100aacaa91dcec6049900 +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; ++import org.bukkit.support.environment.AllFeatures; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; @@ -100,6 +101,7 @@ index 0000000000000000000000000000000000000000..7dd69b97918100aacaa91dcec6049900 + + } + ++ @AllFeatures + @ParameterizedTest + @MethodSource("minecartTypesAsArguments") + void minecartEntityTypeToMaterial(EntityType type, Item material) { diff --git a/{ b/{ new file mode 100644 index 000000000000..e69de29bb2d1 From 1c83e3cf0ca898dcda5ad7b858fc9d74497c73d9 Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 31 Oct 2024 13:24:56 +0100 Subject: [PATCH 4/6] Deleted random file --- { | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 { diff --git a/{ b/{ deleted file mode 100644 index e69de29bb2d1..000000000000 From b1482454b7709acf1014ee39ce857ac2ececa245 Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 31 Oct 2024 14:31:42 +0100 Subject: [PATCH 5/6] removed empty lines --- ...o-get-Material-from-Boats-and-Minecarts.patch | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch b/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch index a26f4eaf2d10..32dc1c0a6f2e 100644 --- a/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch +++ b/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch @@ -63,12 +63,11 @@ index ee010d53f8c671d17d68f3f43dca9978e23ac8ab..d35c1a10e58932b19c8053c5dacdc25f return (AbstractMinecart) this.entity; diff --git a/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..b05d9ea494cc2518fe2ce1d9107d19b4f50a46a5 +index 0000000000000000000000000000000000000000..43e3263ffedc29db8df117d7c716c2f80db91715 --- /dev/null +++ b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java -@@ -0,0 +1,44 @@ +@@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.entity; -+ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; @@ -81,33 +80,22 @@ index 0000000000000000000000000000000000000000..b05d9ea494cc2518fe2ce1d9107d19b4 +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -+ +import static org.junit.jupiter.api.Assertions.*; -+ +class CraftMinecartTest { -+ + private static Stream minecartTypesAsArguments() { -+ + List arguments = new ArrayList<>(); -+ + BuiltInRegistries.ENTITY_TYPE.forEach(type -> { + if (type.toShortString().contains("minecart")) { + if (type == EntityType.SPAWNER_MINECART) arguments.add(Arguments.of(type, Items.MINECART)); + else arguments.add(Arguments.of(type, BuiltInRegistries.ITEM.get(ResourceLocation.fromNamespaceAndPath("minecraft", type.toShortString())).get().value())); + } + }); -+ + return arguments.stream(); -+ + } -+ + @AllFeatures + @ParameterizedTest + @MethodSource("minecartTypesAsArguments") + void minecartEntityTypeToMaterial(EntityType type, Item material) { -+ + assertEquals(CraftMinecart.minecartEntityTypeToMaterial(type), material, "EntityType %s doesn't match the material %s.".formatted(type.toString(), material.toString())); -+ + } -+ +} From 4ad6b3810bf72bef76200e80c0cf4517c58a4f5b Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 31 Oct 2024 14:49:16 +0100 Subject: [PATCH 6/6] Revert "removed empty lines" This reverts commit b1482454b7709acf1014ee39ce857ac2ececa245. --- ...o-get-Material-from-Boats-and-Minecarts.patch | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch b/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch index 32dc1c0a6f2e..a26f4eaf2d10 100644 --- a/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch +++ b/patches/server/0448-API-to-get-Material-from-Boats-and-Minecarts.patch @@ -63,11 +63,12 @@ index ee010d53f8c671d17d68f3f43dca9978e23ac8ab..d35c1a10e58932b19c8053c5dacdc25f return (AbstractMinecart) this.entity; diff --git a/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java new file mode 100644 -index 0000000000000000000000000000000000000000..43e3263ffedc29db8df117d7c716c2f80db91715 +index 0000000000000000000000000000000000000000..b05d9ea494cc2518fe2ce1d9107d19b4f50a46a5 --- /dev/null +++ b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java -@@ -0,0 +1,32 @@ +@@ -0,0 +1,44 @@ +package org.bukkit.craftbukkit.entity; ++ +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; @@ -80,22 +81,33 @@ index 0000000000000000000000000000000000000000..43e3263ffedc29db8df117d7c716c2f8 +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; ++ +import static org.junit.jupiter.api.Assertions.*; ++ +class CraftMinecartTest { ++ + private static Stream minecartTypesAsArguments() { ++ + List arguments = new ArrayList<>(); ++ + BuiltInRegistries.ENTITY_TYPE.forEach(type -> { + if (type.toShortString().contains("minecart")) { + if (type == EntityType.SPAWNER_MINECART) arguments.add(Arguments.of(type, Items.MINECART)); + else arguments.add(Arguments.of(type, BuiltInRegistries.ITEM.get(ResourceLocation.fromNamespaceAndPath("minecraft", type.toShortString())).get().value())); + } + }); ++ + return arguments.stream(); ++ + } ++ + @AllFeatures + @ParameterizedTest + @MethodSource("minecartTypesAsArguments") + void minecartEntityTypeToMaterial(EntityType type, Item material) { ++ + assertEquals(CraftMinecart.minecartEntityTypeToMaterial(type), material, "EntityType %s doesn't match the material %s.".formatted(type.toString(), material.toString())); ++ + } ++ +}