@Test public void forceNewGameWillRestartTableAndStartNewGame() { Map<BigDecimal, BigDecimal> playerIdToAccountIdOverrides = new HashMap<>(); playerIdToAccountIdOverrides.put(PLAYER_ID, BigDecimal.valueOf(202020)); com.yazino.game.api.GameStatus status = new GameStatus(new PrintlnStatus()); com.yazino.game.api.ExecutionResult result = new com.yazino.game.api.ExecutionResult.Builder(gameRules, status).build(); when(gameRules.startNewGame(isA(com.yazino.game.api.GameCreationContext.class))) .thenReturn(result); when(auditor.newLabel()).thenReturn("X"); host = gameHost(new InMemoryGameRepository(gameRules)); table.setTableStatus(TableStatus.closed); table.setCurrentGame(null); Collection<com.yazino.game.api.PlayerAtTableInformation> playersAtTable = Arrays.asList( new com.yazino.game.api.PlayerAtTableInformation( new com.yazino.game.api.GamePlayer(PLAYER1_ID, null, "One"), Collections.<String, String>emptyMap()), new com.yazino.game.api.PlayerAtTableInformation( new com.yazino.game.api.GamePlayer(PLAYER2_ID, null, "Two"), Collections.<String, String>emptyMap())); host.forceNewGame(table, playersAtTable, playerIdToAccountIdOverrides); ArgumentCaptor<com.yazino.game.api.GameCreationContext> contextCaptor = ArgumentCaptor.forClass(com.yazino.game.api.GameCreationContext.class); verify(gameRules).startNewGame(contextCaptor.capture()); assertEquals(TableStatus.open, table.getTableStatus()); assertEquals(status, table.getCurrentGame()); assertEquals(playersAtTable, contextCaptor.getValue().getPlayersAtTableInformation()); }
private void whenGameStart() { com.yazino.game.api.GameStatus newStatus = new com.yazino.game.api.GameStatus(new HashMap<String, Object>()); final com.yazino.game.api.ExecutionResult r = new com.yazino.game.api.ExecutionResult.Builder(gameRules, newStatus).build(); when(gameRules.startNewGame(isA(com.yazino.game.api.GameCreationContext.class))).thenReturn(r); }