### Question:
EntityListener implements Listener { @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onAttack(EntityDamageByEntityEvent event) { if (listenerService.shouldCancelEvent(event.getDamager())) { event.setCancelled(true); } } @Inject  EntityListener(ListenerService listenerService); @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) void onDamage(EntityDamageEvent event); @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) void onAttack(EntityDamageByEntityEvent event); @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) void onEntityTarget(EntityTargetEvent event); @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) void onFoodLevelChange(FoodLevelChangeEvent event); @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) void entityRegainHealthEvent(EntityRegainHealthEvent event); @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) void onEntityInteract(EntityInteractEvent event); @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) void onLowestEntityInteract(EntityInteractEvent event); @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) void onProjectileLaunch(ProjectileLaunchEvent event); @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) void onShoot(EntityShootBowEvent event);  }### Answer:
@Test public void shouldCancelEntityDamageByEntityEvent() { EntityDamageByEntityEvent event = mock(EntityDamageByEntityEvent.class); Entity player = mock(Player.class); given(event.getDamager()).willReturn(player); given(listenerService.shouldCancelEvent(player)).willReturn(true); listener.onAttack(event); verify(listenerService).shouldCancelEvent(player); verify(event).setCancelled(true); }
@Test public void shouldNotCancelEntityDamageByEntityEvent() { EntityDamageByEntityEvent event = mock(EntityDamageByEntityEvent.class); Entity player = mock(Player.class); given(event.getDamager()).willReturn(player); given(listenerService.shouldCancelEvent(player)).willReturn(false); listener.onAttack(event); verify(listenerService).shouldCancelEvent(player); verify(event, only()).getDamager(); }