<commit_before>package com.uxxu.konashi.lib;

import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.support.test.runner.AndroidJUnit4;
import android.test.AndroidTestCase;

import com.uxxu.konashi.lib.action.AioAnalogReadAction;
import com.uxxu.konashi.lib.action.BatteryLevelReadAction;
import com.uxxu.konashi.lib.action.HardwareResetAction;
import com.uxxu.konashi.lib.action.I2cModeAction;
import com.uxxu.konashi.lib.action.I2cReadAction;
import com.uxxu.konashi.lib.action.I2cSendConditionAction;
import com.uxxu.konashi.lib.action.I2cSetReadParamAction;
import com.uxxu.konashi.lib.action.I2cWriteAction;
import com.uxxu.konashi.lib.action.PioDigitalWriteAction;
import com.uxxu.konashi.lib.action.PioPinModeAction;
import com.uxxu.konashi.lib.action.PioPinPullupAction;
import com.uxxu.konashi.lib.action.PwmDutyAction;
import com.uxxu.konashi.lib.action.PwmLedDriveAction;
import com.uxxu.konashi.lib.action.PwmPeriodAction;
import com.uxxu.konashi.lib.action.PwmPinModeAction;
import com.uxxu.konashi.lib.action.UartBaudrateAction;
import com.uxxu.konashi.lib.action.UartModeAction;
import com.uxxu.konashi.lib.action.UartWriteAction;

import org.jdeferred.Deferred;
import org.jdeferred.Promise;
import org.jdeferred.impl.DeferredObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.internal.util.reflection.Whitebox;
import org.mockito.verification.VerificationMode;

import java.util.UUID;

import info.izumin.android.bletia.Bletia;
import info.izumin.android.bletia.BletiaException;
import info.izumin.android.bletia.action.Action;
import info.izumin.android.bletia.action.ReadRemoteRssiAction;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
 * Created by izumin on 7/31/15.
 */
@RunWith(AndroidJUnit4.class)
public class KonashiManagerTest extends AndroidTestCase {
    public static final String TAG = KonashiManagerTest.class.getSimpleName();

    @Mock private BluetoothGattService mService;
    @Mock private Bletia mBletia;
    @Spy private KonashiManager mKonashiManager;

    private Deferred<BluetoothGattCharacteristic, BletiaException, Object> mDeferred;
    private Promise<BluetoothGattCharacteristic, BletiaException, Object> mPromise;

    private ArgumentCaptor<Action> mActionCaptor;

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        mKonashiManager = new KonashiManager();
        mActionCaptor = ArgumentCaptor.forClass(Action.class);
        mDeferred = new DeferredObject<>();
        mPromise = mDeferred.promise();
        when(mBletia.getService(any(UUID.class))).thenReturn(mService);
        when(mBletia.execute(mActionCaptor.capture())).thenReturn(mPromise);
        Whitebox.setInternalState(mKonashiManager, "mBletia", mBletia);
    }

    @Test
    public void testPinMode() throws Exception {
        mKonashiManager.pinMode(0, 0);
        assertThat(mActionCaptor.getValue()).isInstanceOf(PioPinModeAction.class);
    }

    @Test<commit_msg>Fix broken test<commit_after>package com.uxxu.konashi.lib;

import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.support.test.runner.AndroidJUnit4;
import android.test.AndroidTestCase;

import com.uxxu.konashi.lib.action.AioAnalogReadAction;
import com.uxxu.konashi.lib.action.BatteryLevelReadAction;
import com.uxxu.konashi.lib.action.HardwareResetAction;
import com.uxxu.konashi.lib.action.I2cModeAction;
import com.uxxu.konashi.lib.action.I2cSendConditionAction;
import com.uxxu.konashi.lib.action.I2cSetReadParamAction;
import com.uxxu.konashi.lib.action.I2cWriteAction;
import com.uxxu.konashi.lib.action.PioDigitalWriteAction;
import com.uxxu.konashi.lib.action.PioPinModeAction;
import com.uxxu.konashi.lib.action.PioPinPullupAction;
import com.uxxu.konashi.lib.action.PwmDutyAction;
import com.uxxu.konashi.lib.action.PwmLedDriveAction;
import com.uxxu.konashi.lib.action.PwmPeriodAction;
import com.uxxu.konashi.lib.action.PwmPinModeAction;
import com.uxxu.konashi.lib.action.UartBaudrateAction;
import com.uxxu.konashi.lib.action.UartModeAction;
import com.uxxu.konashi.lib.action.UartWriteAction;

import org.jdeferred.Deferred;
import org.jdeferred.Promise;
import org.jdeferred.impl.DeferredObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.mockito.internal.util.reflection.Whitebox;

import java.util.UUID;

import info.izumin.android.bletia.Bletia;
import info.izumin.android.bletia.BletiaException;
import info.izumin.android.bletia.action.Action;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

/**
 * Created by izumin on 7/31/15.
 */
@RunWith(AndroidJUnit4.class)
public class KonashiManagerTest extends AndroidTestCase {
    public static final String TAG = KonashiManagerTest.class.getSimpleName();

    @Mock private BluetoothGattService mService;
    @Mock private BluetoothGattCharacteristic mCharacteristic;
    @Mock private Bletia mBletia;
    @Spy private KonashiManager mKonashiManager;

    private Deferred<BluetoothGattCharacteristic, BletiaException, Void> mDeferred;
    private Promise<BluetoothGattCharacteristic, BletiaException, Void> mPromise;

    @Captor private ArgumentCaptor<Action<BluetoothGattCharacteristic, UUID>> mActionCaptor;

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        mKonashiManager = new KonashiManager();
        mDeferred = new DeferredObject<>();
        mPromise = mDeferred.promise();
        when(mBletia.getService(any(UUID.class))).thenReturn(mService);
        when(mService.getCharacteristic(any(UUID.class))).thenReturn(mCharacteristic);
        when(mCharacteristic.getUuid()).thenReturn(UUID.randomUUID());
        when(mBletia.execute(mActionCaptor.capture())).thenReturn(mPromise);
        Whitebox.setInternalState(mKonashiManager, "mBletia", mBletia);
    }

    @Test
    public void testPinMode() throws Exception {
        mKonashiManager.pinMode(0, 0);
        assertThat(mActionCaptor.getValue()).isInstanceOf(PioPinModeAction.class);
    }

    @Test
{'fraction_non_alphanumeric': 0.10166249816095337, 'fraction_numerical': 0.00397234073856113, 'mean_word_length': 5.419263456090651, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '683652', 'n_tokens_mistral': 2293, 'n_tokens_neox': 2228, 'n_words': 341}