@Test
 public void shouldntRunPostProcessorsWhenDisabledAndNewGameCreated() {
   Table table = tableWithPhase(null, 100L);
   when(wallet.getTable()).thenReturn(table);
   GameInitialiser.GameInitialisationContext context = defaultEventContext();
   context.setRunPostProcessors(false);
   Postprocessor processor = mockPostProcessor();
   underTest.setPostInitialisationProcessors(toList(processor));
   underTest.initialiseGame(context);
   assertEquals(Long.valueOf(1), table.getGameId());
   verifyZeroInteractions(processor);
 }
  @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 shouldRunPostProcessorsWhenNewGameCreated() {
   Table table = tableWithPhase(null, 100L);
   when(wallet.getTable()).thenReturn(table);
   GameInitialiser.GameInitialisationContext context = defaultEventContext();
   Postprocessor processor = mockPostProcessor();
   underTest.setPostInitialisationProcessors(toList(processor));
   underTest.initialiseGame(context);
   verify(processor)
       .postProcess(
           any(com.yazino.game.api.ExecutionResult.class),
           any(com.yazino.game.api.Command.class),
           eq(table),
           eq("TEST"),
           anyList(),
           any(BigDecimal.class));
 }
 @SuppressWarnings({"unchecked"})
 @Test
 public void shouldUpdateGameIdWhenNewGameCreatedAndNotifyPostProcessors() {
   Table table = tableWithPhase(null, 100L);
   when(wallet.getTable()).thenReturn(table);
   GameInitialiser.GameInitialisationContext context = defaultEventContext();
   Postprocessor processor = mockPostProcessor();
   underTest.setPostInitialisationProcessors(toList(processor));
   underTest.initialiseGame(context);
   assertEquals(Long.valueOf(1), table.getGameId());
   verify(processor)
       .postProcess(
           any(com.yazino.game.api.ExecutionResult.class),
           any(com.yazino.game.api.Command.class),
           eq(table),
           anyString(),
           anyList(),
           eq(context.getPlayerId()));
 }
  @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()));
  }