1.1 --- a/webidor/src/test/java/cz/xelfi/quoridor/webidor/FinishedGameTest.java Sun Oct 18 15:48:47 2009 +0200
1.2 +++ b/webidor/src/test/java/cz/xelfi/quoridor/webidor/FinishedGameTest.java Sun Oct 18 21:33:27 2009 +0200
1.3 @@ -26,10 +26,12 @@
1.4
1.5 package cz.xelfi.quoridor.webidor;
1.6
1.7 +import com.sun.jersey.api.client.GenericType;
1.8 import com.sun.jersey.test.framework.JerseyTest;
1.9 import java.io.File;
1.10 import java.io.FileOutputStream;
1.11 import java.io.IOException;
1.12 +import java.util.List;
1.13 import javax.ws.rs.core.MediaType;
1.14 import org.junit.Test;
1.15 import static org.junit.Assert.*;
1.16 @@ -115,6 +117,11 @@
1.17 .queryParam("loginID", logJirka)
1.18 .queryParam("player", "Jirka").queryParam("move", "SS").put(GameId.class);
1.19
1.20 +
1.21 + GenericType<List<GameId>> gType = new GenericType<List<GameId>>() {};
1.22 + List<GameId> nothing = webResource.path("games/").queryParam("status", "blackWon").accept(MediaType.TEXT_XML).get(gType);
1.23 + assertTrue("Nothing has been finished yet: " + nothing, nothing.isEmpty());
1.24 +
1.25 for (int i = 0; i < 3; i++) {
1.26 webResource.path("games/" + s.getId())
1.27 .queryParam("loginID", logJarda)
1.28 @@ -124,8 +131,14 @@
1.29 .queryParam("player", "Jirka").queryParam("move", "S").put(GameId.class);
1.30 }
1.31
1.32 +
1.33 Game end = webResource.path("games/" + s.getId()).accept(MediaType.TEXT_XML).get(Game.class);
1.34 assertEquals("BlackWins", GameStatus.blackWon, end.getId().getStatus());
1.35 +
1.36 + List<GameId> something = webResource.path("games/").queryParam("status", "blackWon").accept(MediaType.TEXT_XML).get(gType);
1.37 +
1.38 + assertEquals("One game finished: " + something, 1, something.size());
1.39 + assertEquals("Id is OK", end.getId().getId(), something.get(0).getId());
1.40 }
1.41
1.42 @Test public void testResignAGame() throws Exception {