public class GamePlayersTest {
@Test//TODO add description here
public final void testProcessRequest() throws Exception{
final GameEngine engine = GameEngine.instance();
final MockParametersMap map = new MockParametersMap();
BoardMap boardMap = BoardMapImpl.getNewInstance("pnth");
boardMap.prepareMap("web/maps/pnth.xml");
User user = UserImpl.getNewInstance("Hussain", "hussain@game.com");
Game game = GameImpl.getNewInstance("new game", user,boardMap);
Detective detective = new Detective(user);
game.addDetective(detective);
game.setPlayerPosition(detective.getEmail(), boardMap.getCoordinates().iterator().next().getLabel());
GamePlayersJsonContainer container = new GamePlayersJsonContainer(game);
assertNull(
"mr x has not been initialized",
container.mrx
);
assertNotNull(
"check if the container has been initialized correctly",
container.detectives
);
assertEquals(
"testing if the container contains one detective",
1,
container.detectives.size()
);
//System.out.println(container.toJson());
map.put("gameId", game.getIdentifier());
final String json = (String)new GamePlayers().processRequest(map, engine);
final GamePlayersJsonContainer gpjc = new GamePlayersJsonContainer().fromJson(json);
assertEquals(gpjc.detectives.size(),1);
}