redrield
09/30/2017, 3:08 AM@test
fun testEntityDeath() {
val world = mock(World::class.java)
val mockEvent = mock(EntityDeathEvent::class.java)
val mockEntity = mock(LivingEntity::class.java)
`when`(mockEntity.world).thenReturn(world)
`when`(mockEntity.location).thenReturn(Location(world, 0.0, 64.0, 0.0))
val drops = mutableListOf(ItemStack(Material.BONE, 3), ItemStack(Material.BOW))
`when`(mockEvent.entity).thenReturn(mockEntity)
`when`(mockEvent.drops).thenReturn(drops)
val listener = MobDeathListener(plugin)
listener.onMobDeath(mockEvent)
val expected = mutableListOf(ItemStack(Material.BOW), ItemStack(Material.DIAMOND))
drops.forEach {
it.itemMeta = null
}
Assert.assertEquals(drops, expected)
}