*/
@Test
public final void testTeleportActionToValidZone() {
final StendhalRPZone zoneTo = new StendhalRPZone("zoneTo");
final Player pl = PlayerTestHelper.createPlayer("player");
MockStendhalRPRuleProcessor.get().addPlayer(pl);
PlayerTestHelper.generatePlayerRPClasses();
final Player bob = new Player(new RPObject()) {
@Override
public boolean teleport(final StendhalRPZone zone, final int x, final int y,
final Direction dir, final Player teleporter) {
assertEquals("zoneTo", zone.getName());
setName("hugo");
return true;
}
};
bob.setName("bob");
PlayerTestHelper.addEmptySlots(bob);
MockStendhalRPRuleProcessor.get().addPlayer(bob);
MockStendlRPWorld.get().addRPZone(zoneTo);
pl.setAdminLevel(5000);
final RPAction action = new RPAction();
action.put("type", "teleport");
action.put("text", "huhu");
action.put("target", "bob");
action.put("zone", "zoneTo");
action.put("x", "0");
action.put("y", "0");
assertTrue(action.has("target") && action.has("zone")
&& action.has("x"));
assertThat(bob.getName(), not(is("hugo")));
CommandCenter.execute(pl, action);
assertEquals("name must have changed, if action was executed", "hugo", bob.getName());
}