package com.sparcs.casino.roulette;

import static org.junit.Assert.*;
//import static org.mockito.Matchers.*;
import static org.mockito.Mockito.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.sparcs.casino.BaseTest;
import com.sparcs.casino.game.Spectator;
import com.sparcs.casino.roulette.internal.RouletteCroupierImpl;

/**
 * Tests of RouletteCroupier behaviour
 * @author Lee Newfeld
 *
 */
public class RouletteCroupierTest extends BaseTest {

	private static final Logger log = LoggerFactory.getLogger(RouletteCroupierTest.class);

	@Mock
	RouletteRoom room;
	
	@Mock
	Spectator spectator;

	List<Spectator> spectators;
	
	@Autowired
	private RouletteCroupierImpl croupier;

	@Before
	public void beforeTest() {

		super.beforeTest();

		spectators = new ArrayList<>();

        // Create mocks
        room = Mockito.mock(RouletteRoom.class);
        spectator = Mockito.mock(Spectator.class);
        
        // Add mock functionality
        when(room.getGameManager()).thenReturn(croupier);
        when(room.getSpectators()).thenReturn(spectators);
        when(spectator.toString()).thenReturn("Lee");
        when(spectator.getCustomer()).thenReturn(lee);

		log.trace("Feature under test: {}", croupier);
	}
	
	@Test
	public void gameShouldRunWhenSpectatorEntersRoom() {

		log.trace("+todo");

		// Fired when someone walks into the empty room
		spectators.add(spectator);
		croupier.initialise(room);
		
		// Spectator stays for a while...
		for( int i=0; i<50; i++ ) {
			
			assertTrue("Game should never end", croupier.update(room) );
		}

		// Spectator leaves
		croupier.shutdown(room);

		log.trace("-todo");
	}
}

@@ -68,237 +68,55 @@
 .*;%0A
-//import static org.mockito.Matchers.*;%0Aimport static org.mockito.Mockito.*;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0Aimport org.mockito.Mockito
+%0Aimport org.junit.Before;%0Aimport org.junit.Test
 ;%0Aim
@@ -273,49 +273,8 @@
 st;%0A
-import com.sparcs.casino.game.Spectator;%0A
 impo
@@ -333,16 +333,77 @@
 ierImpl;
+%0Aimport com.sparcs.casino.roulette.internal.RouletteRoomImpl;
 %0A%0A/**%0A *
@@ -614,22 +614,35 @@
 ss);%0A%0A%09@
-Mock%0A%09
+Autowired%0A%09private 
 Roulette
@@ -645,16 +645,20 @@
 etteRoom
+Impl
  room;%0A%09
@@ -663,120 +663,87 @@
 %0A%09%0A%09
-@Mock%0A%09Spectator spectator;%0A%0A%09List%3CSpectator%3E spectators;%0A%09%0A%09@Autowired%0A%09private RouletteCroupierImpl croupie
+private RouletteCroupierImpl croupier;%0A%0A%09private RouletteSpectator spectato
 r;%0A
+%09
 %0A%09@B
@@ -802,25 +802,28 @@
 t();%0A%0A%09%09
-s
+// S
 pectator
 s = new 
@@ -818,479 +818,501 @@
 ator
-s = new ArrayList%3C%3E();%0A%0A        // Create mocks%0A        room = Mockito.mock(RouletteRoom.class);%0A        spectator = Mockito.mock(Spectator.class);%0A        %0A        // Add mock functionality%0A        when(room.getGameManager()).thenReturn(croupier);%0A        when(room.getSpectators()).thenReturn(spectators);%0A        when(spectator.toString()).thenReturn(%22Lee%22);%0A        when(spectator.getCustomer()).thenReturn(lee);%0A%0A%09%09log.trace(%22Feature under test: %7B%7D%22, croupier
+ enters the room%0A%09%09spectator = (RouletteSpectator)room.enter(lee);%0A%09%09croupier = (RouletteCroupierImpl)room.getGameManager();%0A%0A%09%09log.trace(%22Feature under test: %7B%7D%22, croupier);%0A%09%7D%0A%09%0A%09@Test%0A%09public void gameShouldRunWhenSpectatorEntersRoom() %7B%0A%0A%09%09log.trace(%22+gameShouldRunWhenSpectatorEntersRoom%22);%0A%0A%09%09// Spectator stays for a while...%0A%09%09for( int i=0; i%3C50; i++ ) %7B%0A%09%09%09%0A%09%09%09assertTrue(%22Game should never end%22, croupier.update(room) );%0A%09%09%7D%0A%0A%09%09log.trace(%22-gameShouldRunWhenSpectatorEntersRoom%22
 );%0A%09%7D%0A
-%09
 %0A%09@T
@@ -1345,35 +1345,33 @@
 dRunWhen
-SpectatorEntersRoom
+PlayerMakesNoBets
 () %7B%0A%0A%09%09
@@ -1386,127 +1386,103 @@
 e(%22+
-todo%22);%0A%0A%09%09// Fired when someone walks into the empty room%0A%09%09spectators.add(spectator);
+gameShouldRunWhenPlayerMakesNoBets%22);%0A%09%09%0A%09%09// Spectator joins game
 %0A%09%09
-c
 ro
-upier.initialise(room
+om.joinGame(spectator
 );%0A
-%09%09
 %0A%09%09/
@@ -1623,74 +1623,54 @@
 %0A%0A%09%09
-// Spectator leaves%0A%09%09croupier.shutdown(room);%0A%0A%09%09log.trace(%22-todo
+log.trace(%22-gameShouldRunWhenPlayerMakesNoBets
 %22);%0A

Replace mocks with real objects