package com.uxxu.konashi.lib.action;

import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;

import com.uxxu.konashi.lib.Konashi;

import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.lang.reflect.Method;
import java.util.UUID;

import info.izumin.android.bletia.BletiaException;
import info.izumin.android.bletia.wrapper.BluetoothGattWrapper;

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

/**
 * Created by e10dokup on 2015/10/04
 **/
public class AioAnalogReadActionTest {

    @Mock private BluetoothGattService mService;
    @Mock private BluetoothGattWrapper mGattWrapper;

    private AioAnalogReadAction mAction;

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void actionCharacteristic_InvalidPinNumber() throws Exception{
        mAction = new AioAnalogReadAction(mService, 5);
        assertThat(mAction.getCharacteristic()).isNull();
    }

    @Test
    public void actionCharacteristic_ValidPinNumber() throws Exception{
        mAction = new AioAnalogReadAction(mService, Konashi.AIO0);
        assertThat(mAction.getCharacteristic()).isEqualTo(notNull());
    }
}
@@ -169,16 +169,57 @@
 Konashi;
+%0Aimport com.uxxu.konashi.lib.KonashiUUID;
 %0A%0Aimport
@@ -662,232 +662,19 @@
 to.M
-atchers.isNull;%0Aimport static org.mockito.Matchers.notNull;%0Aimport static org.mockito.Mockito.times;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0Aimport static org.mockito.Mockito.doThrow
+ockito.when
 ;%0A%0A/
@@ -807,16 +807,79 @@
 ervice;%0A
+    @Mock private BluetoothGattCharacteristic mCharacteristic;%0A
     @Moc
@@ -1065,16 +1065,117 @@
 (this);%0A
+        when(mService.getCharacteristic(KonashiUUID.ANALOG_READ0_UUID)).thenReturn(mCharacteristic);%0A
     %7D%0A%0A 
@@ -1363,17 +1363,32 @@
 ic()
-).isNull(
+ == null).isEqualTo(true
 );%0A 
@@ -1588,16 +1588,24 @@
 ristic()
+ == null
 ).isEqua
@@ -1612,17 +1612,13 @@
 lTo(
-notNull()
+false
 );%0A 

Fix AioAnalogReadActionTest