<commit_before>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 <NAME>
 *
 */
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");
	}
}<commit_msg>Replace mocks with real objects<commit_after>package com.sparcs.casino.roulette;

import static org.junit.Assert.*;

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

import com.sparcs.casino.BaseTest;
import com.sparcs.casino.roulette.internal.RouletteCroupierImpl;
import com.sparcs.casino.roulette.internal.RouletteRoomImpl;

/**
 * Tests of RouletteCroupier behaviour
 * @author <NAME>
 *
 */
public class RouletteCroupierTest extends BaseTest {

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

	@Autowired
	private RouletteRoomImpl room;
	
	private RouletteCroupierImpl croupier;

	private RouletteSpectator spectator;
	
	@Before
	public void beforeTest() {

		super.beforeTest();

		// Spectator enters the room
		spectator = (RouletteSpectator)room.enter(lee);
		croupier = (RouletteCroupierImpl)room.getGameManager();

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

		log.trace("+gameShouldRunWhenSpectatorEntersRoom");

		// Spectator stays for a while...
		for( int i=0; i<50; i++ ) {
			
			assertTrue("Game should never end", croupier.update(room) );
		}

		log.trace("-gameShouldRunWhenSpectatorEntersRoom");
	}

	@Test
	public void gameShouldRunWhenPlayerMakesNoBets() {

		log.trace("+gameShouldRunWhenPlayerMakesNoBets");
		
		// Spectator joins game
		room.joinGame(spectator);

		// Spectator stays for a while...
		for( int i=0; i<50; i++ ) {
			
			assertTrue("Game should never end", croupier.update(room) );
		}

		log.trace("-gameShouldRunWhenPlayerMakesNoBets");
	}
}
{'fraction_non_alphanumeric': 0.11902789284727976, 'fraction_numerical': 0.0035901684617508974, 'mean_word_length': 4.318649045521292, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5940369', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1177, 'n_words': 238}