@Test
 public void shouldCreateNewGameWhenNotAllowed() {
   Table table = tableWithPhase(GameFinished, 6L);
   when(wallet.getTable()).thenReturn(table);
   GameInitialiser.GameInitialisationContext context = defaultEventContext();
   context.setAllowedToMoveToNextGame(false);
   underTest.initialiseGame(context);
   assertEquals(Long.valueOf(6), table.getGameId());
 }
 private GameInitialiser.GameInitialisationContext defaultEventContext() {
   GameInitialiser.GameInitialisationContext initialisationContext =
       new GameInitialiser.GameInitialisationContext(
           new com.yazino.game.api.ScheduledEvent(
               0, 100, "", "", Collections.<String, String>emptyMap(), true),
           wallet,
           externalGameService,
           gameRules);
   initialisationContext.setAllowedToMoveToNextGame(false);
   return initialisationContext;
 }
  @Test
  public void shouldntRunPostProcessorsWhenDisabledAndNextGameCreated() {
    Table table = tableWithPhase(GameFinished, 6L);
    when(wallet.getTable()).thenReturn(table);
    GameInitialiser.GameInitialisationContext context = defaultEventContext();
    context.setAllowedToMoveToNextGame(true);
    context.setRunPostProcessors(false);
    when(gameRules.isComplete(table.getCurrentGame())).thenReturn(true);
    underTest.setPostInitialisationProcessors(toList(postprocessor));

    underTest.initialiseGame(context);

    assertEquals(Long.valueOf(7), table.getGameId());
    verifyZeroInteractions(postprocessor);
  }
  @Test
  public void shouldIncrementGameIdWhenCreatedNextGameAndNotifyPostProcessors() {
    Table table = tableWithPhase(GameFinished, 6L);
    when(wallet.getTable()).thenReturn(table);
    GameInitialiser.GameInitialisationContext context = defaultEventContext();
    context.setAllowedToMoveToNextGame(true);
    when(gameRules.isComplete(table.getCurrentGame())).thenReturn(true);
    underTest.setPostInitialisationProcessors(toList(postprocessor));

    underTest.initialiseGame(context);

    assertEquals(Long.valueOf(7), table.getGameId());
    verify(postprocessor)
        .postProcess(
            any(com.yazino.game.api.ExecutionResult.class),
            any(com.yazino.game.api.Command.class),
            eq(table),
            anyString(),
            anyList(),
            eq(context.getPlayerId()));
  }