<commit_before>package br.net.mirante.singular.commons.base;

import static br.net.mirante.singular.commons.util.PropertiesUtils.*;

import java.nio.file.Paths;

import org.junit.Assert;
import org.junit.Test;

import br.net.mirante.singular.commons.util.TempFileUtils;

/**
 * Properties file is stored in /src/test/java/resources/singular.properties
 */
public class SingularPropertiesTest {

    static final String MOCK_PROPERTY_KEY             = "mock.property";
    static final String MOCK_PROPERTY_CLASSPATH_VALUE = "Mock Property";
    static final String MOCK_PROPERTY_FILE_VALUE      = "Mock Disck Property";

    @Test
    public void loadFromClasspath() throws Exception {
        SingularPropertiesImpl.Tester.runInSandbox(impl -> {
            impl.reload();
            Assert.assertEquals(MOCK_PROPERTY_CLASSPATH_VALUE, SingularProperties.get().getProperty(MOCK_PROPERTY_KEY));
        });
    }

    @Test
    public void loadFromFile() throws Exception {
        SingularPropertiesImpl.Tester.runInSandbox(impl -> {

            TempFileUtils.withFileInTempDir(Paths.get("conf", "singular.properties"), (baseDir, propertiesFile) -> {

                store(properties(MOCK_PROPERTY_KEY, MOCK_PROPERTY_FILE_VALUE), propertiesFile, "iso-8859-1");
                impl.setSingularServerHome(baseDir.getCanonicalPath());
                impl.reload();

                Assert.assertEquals(MOCK_PROPERTY_FILE_VALUE, SingularProperties.get().getProperty(MOCK_PROPERTY_KEY));

            });
        });
    }
}<commit_msg>[SINGULAR] - ajustando teste unitário para não depender da ordem de execução<commit_after>package br.net.mirante.singular.commons.base;

import static br.net.mirante.singular.commons.util.PropertiesUtils.*;

import java.nio.file.Paths;

import org.junit.Assert;
import org.junit.Test;

import br.net.mirante.singular.commons.util.TempFileUtils;

/**
 * Properties file is stored in /src/test/java/resources/singular.properties
 */
public class SingularPropertiesTest {

    static final String MOCK_PROPERTY_KEY             = "mock.property";
    static final String MOCK_PROPERTY_CLASSPATH_VALUE = "Mock Property";
    static final String MOCK_PROPERTY_FILE_VALUE      = "Mock Disck Property";

    @Test
    public void loadFromClasspath() throws Exception {
        SingularPropertiesImpl.Tester.runInSandbox(impl -> {
            impl.reload();
            Assert.assertEquals(MOCK_PROPERTY_CLASSPATH_VALUE, SingularProperties.get().getProperty(MOCK_PROPERTY_KEY));
        });
    }

    @Test
    public void loadFromFile() throws Exception {
        SingularPropertiesImpl.Tester.runInSandbox(impl -> {

            TempFileUtils.withFileInTempDir(Paths.get("conf", "singular.properties"), (baseDir, propertiesFile) -> {

                store(properties(MOCK_PROPERTY_KEY, MOCK_PROPERTY_FILE_VALUE), propertiesFile, "iso-8859-1");
                impl.setSingularServerHome(baseDir.getCanonicalPath());
                impl.reload();

                Assert.assertEquals(MOCK_PROPERTY_FILE_VALUE, SingularProperties.get().getProperty(MOCK_PROPERTY_KEY));

            });
        });
        SingularPropertiesImpl.get().setSingularServerHome(null);
        SingularPropertiesImpl.get().reload();

    }

}
{'fraction_non_alphanumeric': 0.1036923076923077, 'fraction_numerical': 0.003076923076923077, 'mean_word_length': 3.34045393858478, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1570498', 'n_tokens_mistral': 933, 'n_tokens_neox': 917, 'n_words': 150}