<commit_before>package com.softartisans.timberwolf.exchange;

import com.softartisans.timberwolf.UserTimeUpdater;
import org.joda.time.DateTime;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;

public class TestConfiguration
{
    @Test
    public void testConstructingConfiguration()
    {
        Configuration config = new Configuration(100, 10);
        assertEquals(100, config.getFindItemPageSize());
        assertEquals(10, config.getGetItemPageSize());

        config = new Configuration(0, 0);
        assertEquals(1, config.getFindItemPageSize());
        assertEquals(1, config.getGetItemPageSize());
    }

    @Test
    public void testDefaultTimeUpdater()
    {
        Configuration config = new Configuration(1, 1);
        assertEquals(new DateTime(0), config.getLastUpdated("user"));
        config.setLastUpdated("user", new DateTime(1));
        assertEquals(new DateTime(0), config.getLastUpdated("user"));
    }

    @Test
    public void testCloningConfigurationWithNewTimeUpdater()
    {
        Configuration config = new Configuration(10, 5);
        Configuration clone = config.withTimeUpdater(null);
        assertEquals(10, clone.getFindItemPageSize());
        assertEquals(5, clone.getGetItemPageSize());
    }

    @Test
    public void testCloningConfigurationDoesNotAlterOriginal()
    {
        Configuration config = new Configuration(10, 5);
        config.withTimeUpdater(null); // Any calls to the new updater will throw null refs.
        assertEquals(new DateTime(0), config.getLastUpdated("user"));
        config.setLastUpdated("user", new DateTime(10));
    }

    @Test
    public void testUpdatingTime()
    {
        UserTimeUpdater mockUpdater = mock(UserTimeUpdater.class);
        Configuration config = new Configuration(1, 1);
        config = config.withTimeUpdater(mockUpdater);

        config.getLastUpdated("user");
        config.getLastUpdated("otheruser");
        config.setLastUpdated("user", new DateTime(5));
        config.setLastUpdated("otheruser", new DateTime(10));

        verify(mockUpdater).lastUpdated("user");
        verify(mockUpdater).lastUpdated("otheruser");
        verify(mockUpdater).setUpdateTime("user", new DateTime(5));
        verify(mockUpdater).setUpdateTime("otheruser", new DateTime(10));
    }
}
<commit_msg>Fixing checkstyle errors in new fixture.<commit_after>package com.softartisans.timberwolf.exchange;

import com.softartisans.timberwolf.UserTimeUpdater;
import org.joda.time.DateTime;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

/** Tests the Configuration class. */
public class TestConfiguration
{
    @Test
    public void testConstructingConfiguration()
    {
        final int findItemSize = 100;
        final int getItemSize = 10;
        Configuration config = new Configuration(findItemSize, getItemSize);
        assertEquals(findItemSize, config.getFindItemPageSize());
        assertEquals(getItemSize, config.getGetItemPageSize());

        config = new Configuration(0, 0);
        assertEquals(1, config.getFindItemPageSize());
        assertEquals(1, config.getGetItemPageSize());
    }

    @Test
    public void testDefaultTimeUpdater()
    {
        Configuration config = new Configuration(1, 1);
        assertEquals(new DateTime(0), config.getLastUpdated("user"));
        config.setLastUpdated("user", new DateTime(1));
        assertEquals(new DateTime(0), config.getLastUpdated("user"));
    }

    @Test
    public void testCloningConfigurationWithNewTimeUpdater()
    {
        final int findItemSize = 10;
        final int getItemSize = 5;
        Configuration config = new Configuration(findItemSize, getItemSize);
        Configuration clone = config.withTimeUpdater(null);
        assertEquals(findItemSize, clone.getFindItemPageSize());
        assertEquals(getItemSize, clone.getGetItemPageSize());
    }

    @Test
    public void testCloningConfigurationDoesNotAlterOriginal()
    {
        Configuration config = new Configuration(0, 0);
        config.withTimeUpdater(null); // Any calls to the new updater will throw null refs.
        assertEquals(new DateTime(0), config.getLastUpdated("user"));
        config.setLastUpdated("user", new DateTime(1));
    }

    @Test
    public void testUpdatingTime()
    {
        UserTimeUpdater mockUpdater = mock(UserTimeUpdater.class);
        Configuration config = new Configuration(1, 1);
        config = config.withTimeUpdater(mockUpdater);

        final int userTime = 5;
        final int otherUserTime = 10;

        config.getLastUpdated("user");
        config.getLastUpdated("otheruser");
        config.setLastUpdated("user", new DateTime(userTime));
        config.setLastUpdated("otheruser", new DateTime(otherUserTime));

        verify(mockUpdater).lastUpdated("user");
        verify(mockUpdater).lastUpdated("otheruser");
        verify(mockUpdater).setUpdateTime("user", new DateTime(userTime));
        verify(mockUpdater).setUpdateTime("otheruser", new DateTime(otherUserTime));
    }
}

{'fraction_non_alphanumeric': 0.10705104663973558, 'fraction_numerical': 0.011935365405802425, 'mean_word_length': 3.6515798462852262, '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': '831572', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1476, 'n_words': 313}