Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for org.bukkit.craftbukkit.entity.CraftMinecart#minecartEntityTypeToMaterial #11536

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,53 @@ 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..b05d9ea494cc2518fe2ce1d9107d19b4f50a46a5
--- /dev/null
+++ b/src/test/java/org/bukkit/craftbukkit/entity/CraftMinecartTest.java
@@ -0,0 +1,44 @@
+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.bukkit.support.environment.AllFeatures;
+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<Arguments> minecartTypesAsArguments() {
+
+ List<Arguments> 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) {
+
lynxplay marked this conversation as resolved.
Show resolved Hide resolved
+ assertEquals(CraftMinecart.minecartEntityTypeToMaterial(type), material, "EntityType %s doesn't match the material %s.".formatted(type.toString(), material.toString()));
+
+ }
+
+}
Loading