<commit_before>package pl.mkrystek.mkbot.pl.mkrystek.mkbot;

import static org.mockito.Mockito.inOrder;
import static java.awt.event.KeyEvent.*;
import static org.mockito.Mockito.verifyNoMoreInteractions;

import java.awt.*;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class KeyboardTest {

    @Mock
    private Robot robot;

    @InjectMocks
    private Keyboard keyboard;

    InOrder order;

    @Before
    public void setUp() {
        order = inOrder(robot);
    }

    @Test
    public void shouldPressProperKeys() {
        //given
        String sampleMessage = "AbC";

        //when
        keyboard.type(sampleMessage);

        //then
        verifySequencePressed(VK_SHIFT, VK_A);
        verifySequencePressed(VK_B);
        verifySequencePressed(VK_SHIFT, VK_C);
        verifyNoMoreInteractions(robot);
    }

    private void verifySequencePressed(int... sequence) {
        verifySequence(sequence);
    }

    private void verifySequence(int... keyCodes) {
        verifySequence(keyCodes, 0, keyCodes.length);
    }

    private void verifySequence(int[] keyCodes, int offset, int length) {
        if (length == 0) {
            return;
        }

        order.verify(robot).keyPress(keyCodes[offset]);
        verifySequence(keyCodes, offset + 1, length - 1);
        order.verify(robot).keyRelease(keyCodes[offset]);
    }
}<commit_msg>Improve keyboard test to cover more characters<commit_after>package pl.mkrystek.mkbot.pl.mkrystek.mkbot;

import static org.mockito.Mockito.inOrder;
import static java.awt.event.KeyEvent.*;
import static org.mockito.Mockito.verifyNoMoreInteractions;

import java.awt.*;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class KeyboardTest {

    @Mock
    private Robot robot;

    @InjectMocks
    private Keyboard keyboard;

    InOrder order;

    @Before
    public void setUp() {
        order = inOrder(robot);
    }

    @Test
    public void testTypingSmallLetters() {
        //given
        String messageWithSmallLetters = "abcdefghijklmnopqrstuvwxyz";

        //when
        keyboard.type(messageWithSmallLetters);

        //then
        for (int i = VK_A; i <= VK_Z; i++) {
            verifyCharacterTyped(i);
        }
        verifyNoMoreInteractions(robot);
    }

    @Test
    public void testTypingBigLetters() {
        //given
        String messageWithBigLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        //when
        keyboard.type(messageWithBigLetters);

        //then
        for (int i = VK_A; i <= VK_Z; i++) {
            verifyCharacterTypedWithShift(i);
        }
        verifyNoMoreInteractions(robot);
    }

    @Test
    public void testTypingNumbers() {
        //given
        String messageWithNumbers = "0123456789";

        //when
        keyboard.type(messageWithNumbers);

        //then
        for (int i = VK_0; i <= VK_9; i++) {
            verifyCharacterTyped(i);
        }
        verifyNoMoreInteractions(robot);
    }

    @Test
    public void testTypingSpecialCharactersUnderNumbers() {
        //given
        String messageWithSpecialCharacters = ")!@#$%^&*(";

        //when
        keyboard.type(messageWithSpecialCharacters);

        //then
        for (int i = VK_0; i <= VK_9; i++) {
            verifyCharacterTypedWithShift(i);
        }
        verifyNoMoreInteractions(robot);
    }

    private void verifyCharacterTypedWithShift(int keyCode) {
        verifyCharacterTyped(VK_SHIFT, keyCode);
    }

    private void verifyCharacterTyped(int... keyCodes) {
        for (int keyCode : keyCodes) {
            order.verify(robot).keyPress(keyCode);
        }

        for (int i = keyCodes.length - 1; i >= 0; i--) {
            order.verify(robot).keyRelease(keyCodes[i]);
        }
    }
}
{'fraction_non_alphanumeric': 0.10591073582629675, 'fraction_numerical': 0.0048250904704463205, 'mean_word_length': 2.5526992287917736, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '6126116', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1293, 'n_words': 251}