<commit_before>package fi.helsinki.cs.tmc.cli.tmcstuff;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

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

import java.io.File;
import java.util.Locale;

public class SettingsTest {

    private Settings settings;
    private File file;

    @Before
    public void setUp() {
        settings = new Settings("testserver", "testuser", "testpassword");
        file = new File(".");
    }

    @Test
    public void constructorInitializesFields() {
        assertEquals("testserver", settings.getServerAddress());
        assertEquals("testuser", settings.getUsername());
        assertEquals("testpassword", settings.getPassword());
    }

    @Test
    public void correctApiVersion() {
        assertEquals("7", settings.apiVersion());
    }

    @Test
    public void correctClientVersion() {
        assertEquals("0.1.0", settings.clientVersion());
    }

    @Test
    public void correctClientName() {
        assertEquals("", settings.clientName());
    }

    @Test
    public void userDataExistsIfUsernameAndPasswordAreSet() {
        assertTrue(settings.userDataExists());
    }

    @Test
    public void userDataDoesNotExistIfUsernameIsNotSet() {
        settings = new Settings("testserver", null, "testpassword");
        assertTrue(!settings.userDataExists());

        settings = new Settings("testserver", "", "testpassword");
        assertTrue(!settings.userDataExists());
    }

    @Test
    public void formattedUserDataIsCorrectIfSet() {
        assertEquals("testuser:testpassword", settings.getFormattedUserData());
    }
    
    @Test
    public void formattedUserDataIsCorrectIfNotSet() {
        settings = new Settings("testserver", null, "testpassword");
        assertEquals("", settings.getFormattedUserData());
    }

    @Test
    public void userDataDoesNotExistIfPasswordIsNotSet() {
        settings = new Settings("testserver", "testuser", null);
        assertTrue(!settings.userDataExists());

        settings = new Settings("testserver", "testuser", "");
        assertTrue(!settings.userDataExists());
    }

    @Test
    public void localeIsSetToEn() {
        assertTrue(new Locale("EN").equals(settings.getLocale()));
    }

    @Test
    public void tmcProjectDirectoryIsSetCorrectly() {
        assertTrue(file.getAbsolutePath().equals(
                settings.getTmcProjectDirectory().toString()));
    }

    @Test
    public void configRootIsSetCorrectly() {
        assertTrue(file.getAbsolutePath().equals(
                settings.getConfigRoot().toString()));

    }

    @Test
    public void noCourseIsSetByDefault() {
        assertTrue(!settings.getCurrentCourse().isPresent());
    }
    
    @Test
    public void noProxyByDefault() {
        assertEquals(null, settings.proxy());
    }
}<commit_msg>tests<commit_after>package fi.helsinki.cs.tmc.cli.tmcstuff;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

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

import java.io.File;
import java.util.Locale;

public class SettingsTest {

    private Settings settings;
    private File file;

    @Before
    public void setUp() {
        settings = new Settings("testserver", "testuser", "testpassword");
        file = new File(".");
    }

    @Test
    public void constructorInitializesFields() {
        assertEquals("testserver", settings.getServerAddress());
        assertEquals("testuser", settings.getUsername());
        assertEquals("testpassword", settings.getPassword());
    }

    @Test
    public void correctApiVersion() {
        assertEquals("7", settings.apiVersion());
    }

    @Test
    public void correctClientVersion() {
        assertEquals("0.1.0", settings.clientVersion());
    }

    @Test
    public void correctClientName() {
        assertEquals("", settings.clientName());
    }

    @Test
    public void userDataExistsIfUsernameAndPasswordAreSet() {
        assertTrue(settings.userDataExists());
    }

    @Test
    public void userDataDoesNotExistIfUsernameIsNotSet() {
        settings = new Settings("testserver", null, "testpassword");
        assertTrue(!settings.userDataExists());

        settings = new Settings("testserver", "", "testpassword");
        assertTrue(!settings.userDataExists());
    }

    @Test
    public void formattedUserDataIsCorrectIfSet() {
        assertEquals("testuser:testpassword", settings.getFormattedUserData());
    }
    
    @Test
    public void formattedUserDataIsCorrectIfNotSet() {
        settings = new Settings("testserver", null, "testpassword");
        assertEquals("", settings.getFormattedUserData());
    }

    @Test
    public void userDataDoesNotExistIfPasswordIsNotSet() {
        settings = new Settings("testserver", "testuser", null);
        assertTrue(!settings.userDataExists());

        settings = new Settings("testserver", "testuser", "");
        assertTrue(!settings.userDataExists());
    }

    @Test
    public void localeIsSetToEn() {
        assertTrue(new Locale("EN").equals(settings.getLocale()));
    }

    @Test
    public void tmcProjectDirectoryIsSetCorrectly() {
        assertTrue(file.getAbsolutePath().equals(
                settings.getTmcProjectDirectory().toString()));
    }

    @Test
    public void configRootIsSetCorrectly() {
        /*assertTrue("/tmp/tmc-cli".equals(
                settings.getConfigRoot().toString()));*/

    }

    @Test
    public void noCourseIsSetByDefault() {
        assertTrue(!settings.getCurrentCourse().isPresent());
    }
    
    @Test
    public void noProxyByDefault() {
        assertEquals(null, settings.proxy());
    }
}
{'fraction_non_alphanumeric': 0.12407732864674868, 'fraction_numerical': 0.00140597539543058, 'mean_word_length': 3.138909090909091, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4626466', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1498, 'n_words': 292}