<commit_before>package nl.joshuaslik.tudelft.SEM.utility;

import static org.junit.Assert.*;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

import org.junit.Before;
import org.junit.Test;

public class GameLogTest {
	StringWriter sw;
	PrintWriter pw;
	
	/**
	 * Setup the test.
	 */
	@Before
	public void setup() {
		sw = new StringWriter();
		pw = new PrintWriter(sw);
		GameLog.setPrintWriter(pw);
		GameLog.setInitialization(true);
	}
	
	/**
	 * Tests if the correct information is logged by the error logger.
	 */
	@Test
	public void testAddErrorLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addErrorLog(randomString);
		assertTrue(sw.toString().contains(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
		assertTrue(sw.toString().contains("[ERROR] "+randomString));
	}

	/**
	 * Tests if the correct information is logged by the warning logger.
	 */
	@Test
	public void testAddWarningLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addWarningLog(randomString);
		assertTrue(sw.toString().contains(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
		assertTrue(sw.toString().contains("[WARNING] "+randomString));
	}

	/**
	 * Tests if the correct information is logged by the information logger.
	 */
	@Test
	public void testAddInfoLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addInfoLog(randomString);
		assertTrue(sw.toString().contains(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
		assertTrue(sw.toString().contains("[INFO] "+randomString));	}

	/**
	 * Tests if the correct information is logged by the debug logger.
	 */
	@Test
	public void testAddDebugLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addDebugLog(randomString);
		assertTrue(sw.toString().contains(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
		assertTrue(sw.toString().contains("[DEBUG] "+randomString));
	}

	/**
	 * Tests if the correct information is logged by the trace logger.
	 */
	@Test
	public void testAddTraceLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addTraceLog(randomString);
		assertTrue(sw.toString().contains(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())));
		assertTrue(sw.toString().contains("[TRACE] "+randomString));
	}

}<commit_msg>Mocked getCurrentTime <Testing, Performance<commit_after>package nl.joshuaslik.tudelft.SEM.utility;

import static org.junit.Assert.*;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PrepareForTest(GameLog.class)
public class GameLogTest {
	StringWriter sw;
	PrintWriter pw;
	String date = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
	
	/**
	 * Setup the test.
	 * @throws Exception 
	 */
	@Before
	public void setup() throws Exception {
		sw = new StringWriter();
		pw = new PrintWriter(sw);
		GameLog.setPrintWriter(pw);
		GameLog.setInitialization(true);
		PowerMockito.spy(GameLog.class);
		PowerMockito.doReturn(date).when(GameLog.class, "getCurrentTime");
	}
	
	/**
	 * Tests if the correct information is logged by the error logger.
	 */
	@Test
	public void testAddErrorLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addErrorLog(randomString);
		assertTrue(sw.toString().contains(date));
		assertTrue(sw.toString().contains("[ERROR] "+randomString));
	}

	/**
	 * Tests if the correct information is logged by the warning logger.
	 */
	@Test
	public void testAddWarningLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addWarningLog(randomString);
		assertTrue(sw.toString().contains(date));
		assertTrue(sw.toString().contains("[WARNING] "+randomString));
	}

	/**
	 * Tests if the correct information is logged by the information logger.
	 */
	@Test
	public void testAddInfoLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addInfoLog(randomString);
		assertTrue(sw.toString().contains(date));
		assertTrue(sw.toString().contains("[INFO] "+randomString));	}

	/**
	 * Tests if the correct information is logged by the debug logger.
	 */
	@Test
	public void testAddDebugLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addDebugLog(randomString);
		assertTrue(sw.toString().contains(date));
		assertTrue(sw.toString().contains("[DEBUG] "+randomString));
	}

	/**
	 * Tests if the correct information is logged by the trace logger.
	 */
	@Test
	public void testAddTraceLog() {
		String randomString = UUID.randomUUID().toString();
		GameLog.addTraceLog(randomString);
		assertTrue(sw.toString().contains(date));
		assertTrue(sw.toString().contains("[TRACE] "+randomString));
	}

}
{'fraction_non_alphanumeric': 0.14299667903887478, 'fraction_numerical': 0.0001953506544246923, 'mean_word_length': 5.073546856465006, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '15435', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1584, 'n_words': 343}