<commit_before>package com.ffxivcensus.gatherer.task;

import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.concurrent.ThreadPoolExecutor;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import com.ffxivcensus.gatherer.player.CharacterStatus;
import com.ffxivcensus.gatherer.player.PlayerBean;
import com.ffxivcensus.gatherer.player.PlayerBeanRepository;

public class GatheringLimiterTaskTest {

    @Mock
    private ThreadPoolExecutor mockExecutor;
    @Mock
    private PlayerBeanRepository mockRepository;
    private GatheringLimiterTask instance;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        instance = new GatheringLimiterTask(mockExecutor, mockRepository);
    }
    
    @After
    public void tearDown() {
        instance = null;
    }

    @Test
    public void testNothingGathered() {
        when(mockRepository.findTopByOrderByIdDesc()).thenReturn(null);
        when(mockRepository.findTopByCharacterStatusNotOrderByIdDesc(Mockito.any(CharacterStatus.class))).thenReturn(null);
        
        instance.run();
        
        verify(mockExecutor).shutdownNow();
    }
    
    @Test
    public void testContinueCondition() {
        PlayerBean topId = new PlayerBean();
        topId.setId(150);
        PlayerBean topValid = new PlayerBean();
        topValid.setId(100);
        
        when(mockRepository.findTopByOrderByIdDesc()).thenReturn(topId);
        when(mockRepository.findTopByCharacterStatusNotOrderByIdDesc(Mockito.any(CharacterStatus.class))).thenReturn(topValid);
        
        instance.run();
        
        verify(mockExecutor, never()).shutdownNow();
    }
    
    @Test
    public void testContinueAtMarginCondition() {
        PlayerBean topId = new PlayerBean();
        topId.setId(5100);
        PlayerBean topValid = new PlayerBean();
        topValid.setId(100);
        
        when(mockRepository.findTopByOrderByIdDesc()).thenReturn(topId);
        when(mockRepository.findTopByCharacterStatusNotOrderByIdDesc(Mockito.any(CharacterStatus.class))).thenReturn(topValid);
        
        instance.run();
        
        verify(mockExecutor, never()).shutdownNow();
    }
    
    @Test
    public void testStopCondition() {
        PlayerBean topId = new PlayerBean();
        topId.setId(5101);
        PlayerBean topValid = new PlayerBean();
        topValid.setId(100);
        
        when(mockRepository.findTopByOrderByIdDesc()).thenReturn(topId);
        when(mockRepository.findTopByCharacterStatusNotOrderByIdDesc(Mockito.any(CharacterStatus.class))).thenReturn(topValid);
        
        instance.run();
        
        verify(mockExecutor).shutdownNow();
    }

}<commit_msg>Update tests to support increase of GATHERING_VALID_GAP_MAX to 50,000<commit_after>package com.ffxivcensus.gatherer.task;

import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.concurrent.ThreadPoolExecutor;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import com.ffxivcensus.gatherer.player.CharacterStatus;
import com.ffxivcensus.gatherer.player.PlayerBean;
import com.ffxivcensus.gatherer.player.PlayerBeanRepository;

public class GatheringLimiterTaskTest {

    @Mock
    private ThreadPoolExecutor mockExecutor;
    @Mock
    private PlayerBeanRepository mockRepository;
    private GatheringLimiterTask instance;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        instance = new GatheringLimiterTask(mockExecutor, mockRepository);
    }
    
    @After
    public void tearDown() {
        instance = null;
    }

    @Test
    public void testNothingGathered() {
        when(mockRepository.findTopByOrderByIdDesc()).thenReturn(null);
        when(mockRepository.findTopByCharacterStatusNotOrderByIdDesc(Mockito.any(CharacterStatus.class))).thenReturn(null);
        
        instance.run();
        
        verify(mockExecutor).shutdownNow();
    }
    
    @Test
    public void testContinueCondition() {
        PlayerBean topId = new PlayerBean();
        topId.setId(150);
        PlayerBean topValid = new PlayerBean();
        topValid.setId(100);
        
        when(mockRepository.findTopByOrderByIdDesc()).thenReturn(topId);
        when(mockRepository.findTopByCharacterStatusNotOrderByIdDesc(Mockito.any(CharacterStatus.class))).thenReturn(topValid);
        
        instance.run();
        
        verify(mockExecutor, never()).shutdownNow();
    }
    
    @Test
    public void testContinueAtMarginCondition() {
        PlayerBean topId = new PlayerBean();
        topId.setId(50100);
        PlayerBean topValid = new PlayerBean();
        topValid.setId(100);
        
        when(mockRepository.findTopByOrderByIdDesc()).thenReturn(topId);
        when(mockRepository.findTopByCharacterStatusNotOrderByIdDesc(Mockito.any(CharacterStatus.class))).thenReturn(topValid);
        
        instance.run();
        
        verify(mockExecutor, never()).shutdownNow();
    }
    
    @Test
    public void testStopCondition() {
        PlayerBean topId = new PlayerBean();
        topId.setId(50101);
        PlayerBean topValid = new PlayerBean();
        topValid.setId(100);
        
        when(mockRepository.findTopByOrderByIdDesc()).thenReturn(topId);
        when(mockRepository.findTopByCharacterStatusNotOrderByIdDesc(Mockito.any(CharacterStatus.class))).thenReturn(topValid);
        
        instance.run();
        
        verify(mockExecutor).shutdownNow();
    }

}
{'fraction_non_alphanumeric': 0.09791524265208476, 'fraction_numerical': 0.008031442241968558, 'mean_word_length': 3.2138228941684663, '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': '1920574', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1647, 'n_words': 256}