<commit_before>package org.gsc.test;

import org.gsc.automa.Automa;
import org.gsc.automa.AutomaEvent;
import org.gsc.automa.AutomaState;
import org.gsc.automa.config.AutomaConfiguration;
import org.gsc.automa.config.AutomaServiceDiscovery;
import org.gsc.test.utils.FakeAutomaExecutorService;
import org.junit.Test;

import static org.gsc.automa.StateConnector.from;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
 * Created with IntelliJ IDEA.
 * User: gianluca
 * Date: 24/06/13
 * Time: 11.29
 * To change this template use File | Settings | File Templates.
 */
public class TestConfiguration {
    private boolean actionExecuted = false;

    /**
     * Questo test verifica la corretta configurazione dell'automa
     * quando .setThreading(false) l'automa eseguirà le azioni in modo sincrono
     */
    @Test
    public void shouldTestConfiguration() {
        AutomaConfiguration.setThreading(false);
        AutomaState startState = new AutomaState("StartState");
        AutomaEvent evt = new AutomaEvent("Evt");


        Runnable myAction = new Runnable() {
            @Override
            public void run() {
                actionExecuted = true;
            }
        };

        from(startState).stay().when(evt).andDo(myAction);

        Automa automa = new Automa(startState);

        automa.signalEvent(evt);
        assertTrue(actionExecuted);
    }

    @Test
    public void shouldTestConfigurationThreadingPool() {
        int num = 4;
        AutomaConfiguration.setThreading(true);
        AutomaConfiguration.setThreadsNumber(num);

        Runnable myAction = new Runnable() {
            @Override
            public void run() {
                actionExecuted = true;
            }
        };

        FakeAutomaExecutorService executorService = new FakeAutomaExecutorService();
        AutomaServiceDiscovery.setExecutorService(executorService);

        AutomaState startState = new AutomaState("StartState");
        AutomaEvent evt = new AutomaEvent("Evt");
        from(startState).stay().when(evt).andDo(myAction);

        Automa automa = new Automa(startState);
        automa.signalEvent(evt);

        assertEquals(num, executorService.getThreadsNumber());
        assertEquals(1, executorService.getSubmittedJobs());
    }
}<commit_msg>Aggiunto test per la verifica dell'esecuzione sincrona<commit_after>package org.gsc.test;

import org.gsc.automa.Automa;
import org.gsc.automa.AutomaEvent;
import org.gsc.automa.AutomaState;
import org.gsc.automa.config.AutomaConfiguration;
import org.gsc.automa.config.AutomaServiceDiscovery;
import org.gsc.test.utils.FakeAutomaExecutorService;
import org.junit.Before;
import org.junit.Test;

import static org.gsc.automa.StateConnector.from;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
 * Created with IntelliJ IDEA.
 * User: gianluca
 * Date: 24/06/13
 * Time: 11.29
 * To change this template use File | Settings | File Templates.
 */
public class TestConfiguration {
    private boolean actionExecuted = false;

    Runnable myAction = new Runnable() {
        @Override
        public void run() {
            actionExecuted = true;
        }
    };

    @Before
    public void before() {
        actionExecuted = false;
    }

    /**
     * Questo test verifica la corretta configurazione dell'automa
     * quando .setThreading(false) l'automa eseguirà le azioni in modo sincrono
     */
    @Test
    public void shouldTestConfiguration() {
        AutomaConfiguration.setThreading(false);
        AutomaState startState = new AutomaState("StartState");
        AutomaEvent evt = new AutomaEvent("Evt");

        from(startState).stay().when(evt).andDo(myAction);

        Automa automa = new Automa(startState);

        automa.signalEvent(evt);
        assertTrue(actionExecuted);
    }

    @Test
    public void shouldTestConfigurationThreadingPool() {
        int num = 4;
        AutomaConfiguration.setThreading(true);
        AutomaConfiguration.setThreadsNumber(num);

        FakeAutomaExecutorService executorService = new FakeAutomaExecutorService();
        AutomaServiceDiscovery.setExecutorService(executorService);

        AutomaState startState = new AutomaState("StartState");
        AutomaEvent evt = new AutomaEvent("Evt");
        from(startState).stay().when(evt).andDo(myAction);

        Automa automa = new Automa(startState);
        automa.signalEvent(evt);

        assertEquals(num, executorService.getThreadsNumber());
        assertEquals(1, executorService.getSubmittedJobs());
    }

    @Test
    public void shouldVerifyNoThreads() {
        AutomaConfiguration.setThreading(false);

        FakeAutomaExecutorService executorService = new FakeAutomaExecutorService();
        AutomaServiceDiscovery.setExecutorService(executorService);

        AutomaState startState = new AutomaState("StartState");
        AutomaEvent evt = new AutomaEvent("Evt");
        from(startState).stay().when(evt).andDo(myAction);

        Automa automa = new Automa(startState);
        automa.signalEvent(evt);
        assertEquals(0, executorService.getSubmittedJobs());
    }
}
{'fraction_non_alphanumeric': 0.09679907443116081, 'fraction_numerical': 0.004820671037408407, 'mean_word_length': 3.169614147909968, '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': '928773', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1500, 'n_words': 308}