@@ -1,38 +1,30 @@
|
||||
package org.bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
/**
|
||||
* This test class ensures that all Blocks (as registered in BuiltInRegistries.BLOCK)
|
||||
* can be converted into their CraftBlockData equivalent.
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class BlockDataConversionTest extends AbstractTestingBase {
|
||||
|
||||
@Parameterized.Parameters(name = "{index}: {0}")
|
||||
public static List<Object[]> args() {
|
||||
List<Object[]> list = new ArrayList<>();
|
||||
for (Block block : (Iterable<Block>) BuiltInRegistries.BLOCK) {
|
||||
list.add(new Object[]{block.defaultBlockState()});
|
||||
}
|
||||
return list;
|
||||
public static Stream<Arguments> data() {
|
||||
return BuiltInRegistries.BLOCK.stream().map(Block::defaultBlockState).map(Arguments::of);
|
||||
}
|
||||
|
||||
@Parameterized.Parameter(0) public IBlockData data;
|
||||
|
||||
@Test
|
||||
public void testNotNull() {
|
||||
Assert.assertNotNull(data);
|
||||
Assert.assertNotNull(CraftBlockData.fromData(data));
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
public void testNotNull(IBlockData data) {
|
||||
assertNotNull(data);
|
||||
assertNotNull(CraftBlockData.fromData(data));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user