use of be.seeseemelk.mockbukkit.inventory.HopperInventoryMock in project Slimefun4 by Slimefun.
the class TestItemPickupListener method testNoPickupFlagForInventories.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void testNoPickupFlagForInventories(boolean flag) {
Inventory inventory = new HopperInventoryMock(null);
Item item = new ItemEntityMock(server, UUID.randomUUID(), new ItemStack(Material.COMPASS));
if (flag) {
SlimefunUtils.markAsNoPickup(item, "Unit Test");
}
InventoryPickupItemEvent event = new InventoryPickupItemEvent(inventory, item);
listener.onHopperPickup(event);
Assertions.assertEquals(flag, event.isCancelled());
}
use of be.seeseemelk.mockbukkit.inventory.HopperInventoryMock in project Slimefun4 by Slimefun.
the class TestItemPickupListener method testAltarProbeForInventories.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void testAltarProbeForInventories(boolean flag) {
Inventory inventory = new HopperInventoryMock(null);
ItemStack stack;
if (flag) {
stack = new CustomItemStack(Material.DIAMOND, AncientPedestal.ITEM_PREFIX + System.nanoTime());
} else {
stack = new CustomItemStack(Material.DIAMOND, "&5Just a normal named diamond");
}
AtomicBoolean removed = new AtomicBoolean(false);
Item item = new ItemEntityMock(server, UUID.randomUUID(), stack) {
@Override
public void remove() {
removed.set(true);
}
};
InventoryPickupItemEvent event = new InventoryPickupItemEvent(inventory, item);
listener.onHopperPickup(event);
Assertions.assertEquals(flag, event.isCancelled());
Assertions.assertEquals(flag, removed.get());
}
Aggregations