Fix issues with Recipe API
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package io.papermc.paper.inventory.recipe;
|
||||
|
||||
import java.util.Iterator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.support.environment.AllFeatures;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@AllFeatures
|
||||
class TestRecipeChoice {
|
||||
|
||||
@Test
|
||||
void testRecipeChoices() {
|
||||
final Iterator<Recipe> iter = Bukkit.recipeIterator();
|
||||
boolean foundRecipes = false;
|
||||
while (iter.hasNext()) {
|
||||
foundRecipes = true;
|
||||
assertDoesNotThrow(iter::next, "Failed to convert a recipe to Bukkit recipe!");
|
||||
}
|
||||
assertTrue(foundRecipes, "No recipes found!");
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,15 @@ public final class DummyServerHelper {
|
||||
// Paper end - testing additions
|
||||
|
||||
io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(); // Paper - configuration files - setup global configuration test base
|
||||
|
||||
// Paper start - add test for recipe conversion
|
||||
when(instance.recipeIterator()).thenAnswer(ignored ->
|
||||
com.google.common.collect.Iterators.transform(
|
||||
RegistryHelper.getDataPack().getRecipeManager().recipes.byType.entries().iterator(),
|
||||
input -> input.getValue().toBukkitRecipe()
|
||||
)
|
||||
);
|
||||
// Paper end - add test for recipe conversion
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user