webidor/src/test/java/cz/xelfi/quoridor/webidor/QuoridorTest.java
changeset 46 71e4cf307c93
parent 41 c94f68ddef59
child 48 69e897fe8140
     1.1 --- a/webidor/src/test/java/cz/xelfi/quoridor/webidor/QuoridorTest.java	Tue Aug 11 14:26:49 2009 +0200
     1.2 +++ b/webidor/src/test/java/cz/xelfi/quoridor/webidor/QuoridorTest.java	Sat Aug 29 15:55:53 2009 +0200
     1.3 @@ -38,6 +38,9 @@
     1.4  import java.io.FileReader;
     1.5  import java.io.IOException;
     1.6  import java.util.List;
     1.7 +import java.util.Map;
     1.8 +import javax.ws.rs.core.MediaType;
     1.9 +import org.codehaus.jettison.json.JSONObject;
    1.10  import org.junit.Test;
    1.11  import static org.junit.Assert.*;
    1.12  
    1.13 @@ -146,6 +149,17 @@
    1.14          assertEquals(7, board.getPlayers().get(1).getRow());
    1.15          assertEquals(Move.NORTH, read.getGames().get(0).getMoves().get(0));
    1.16          assertEquals(Move.SOUTH, read.getGames().get(0).getMoves().get(1));
    1.17 +
    1.18 +        class GMap extends GenericType<Map<String,Object>>{}
    1.19 +        JSONObject map = webResource.path("games").path(s.getId()).accept(MediaType.APPLICATION_JSON).get(JSONObject.class);
    1.20 +        assertNotNull("Map really returned", map);
    1.21 +        String txtBoard = (String) map.get("board");
    1.22 +        assertNotNull("Contains its textual form", txtBoard);
    1.23 +        assertEquals("It is same as text of our game", board.toString(), txtBoard);
    1.24 +
    1.25 +        Object og = map.getJSONObject("game");
    1.26 +        assertTrue("Instance of JSON: " + og, og instanceof JSONObject);
    1.27 +        JSONObject jg = (JSONObject)og;
    1.28      }
    1.29  
    1.30  }