@Test public void testPersistence() throws Exception { Game game = GameTest.createSimpleGame(); Player playerA = game.getPlayers().get(0); Wizard wizard = playerA.getWizards().get(0); Army army = playerA.getActiveArmies().get(0); wizard.setBase(army); UnlimitedTeleportArmy oldOrder = new UnlimitedTeleportArmy(wizard, new Tuple(2, 2)); String jsonOrder = Game.GSON.toJson(oldOrder); LOG.debug(jsonOrder); UnlimitedTeleportArmy newOrder = Game.GSON.fromJson(jsonOrder, UnlimitedTeleportArmy.class); doEqualsTest(oldOrder, newOrder); }
@Test public void testTeleport() { Game game = GameTest.createSimpleGame(); Player playerA = game.getPlayers().get(0); Wizard wizard = playerA.getWizards().get(0); Army army = playerA.getActiveArmies().get(0); wizard.setBase(army); wizard.setLevel(7); while (army.getUnits().size() <= wizard.getLevel()) { army.addUnit(new ArmyUnit(TroopType.LEVY)); } assertTrue(army.getUnits().size() > wizard.getLevel()); UnlimitedTeleportArmy order = new UnlimitedTeleportArmy(wizard, new Tuple(2, 2)); assertFalse(army.getLocation().getCoord().equals(new Tuple(2, 2))); order.execute(game); assertTrue(order.wasExecuted()); assertEquals(army.getLocation().getCoord(), new Tuple(2, 2)); }