@@ -0,0 +1,2620 @@
+package com.uxxu.konashi.lib.action;%0A%0Aimport android.bluetooth.BluetoothGattCharacteristic;%0Aimport android.bluetooth.BluetoothGattService;%0A%0Aimport com.uxxu.konashi.lib.KonashiErrorType;%0Aimport com.uxxu.konashi.lib.KonashiUUID;%0Aimport com.uxxu.konashi.lib.test.TestKonashiWriteCharacteristicAction;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0Aimport org.mockito.MockitoAnnotations;%0A%0Aimport java.util.UUID;%0A%0Aimport info.izumin.android.bletia.wrapper.BluetoothGattWrapper;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.mockito.Mockito.doReturn;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0Aimport static org.mockito.Mockito.spy;%0A%0A/**%0A * Created by e10dokup on 2016/01/18%0A **/%0Apublic class KonashiWriteCharacteristicActionTest %7B%0A    private static final String TAG = KonashiWriteCharacteristicActionTest.class.getSimpleName();%0A    private final KonashiWriteCharacteristicActionTest self = this;%0A%0A    @Mock private BluetoothGattService mService;%0A    @Mock private BluetoothGattCharacteristic mCharacteristic;%0A    @Mock private BluetoothGattWrapper mWrapper;%0A%0A    private TestKonashiWriteCharacteristicAction mAction;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        MockitoAnnotations.initMocks(this);%0A        when(mCharacteristic.getService()).thenReturn(mService);%0A        when(mCharacteristic.getUuid()).thenReturn(KonashiUUID.I2C_WRITE_UUID);%0A    %7D%0A%0A    @Test%0A    public void execute_withUnsupportedCharacteristic() throws Exception %7B%0A        mAction = new TestKonashiWriteCharacteristicAction(mService, null);%0A        assertThat(mAction.execute(mWrapper)).isEqualTo(false);%0A    %7D%0A%0A    @Test%0A    public void execute_withValidateReturnError() throws Exception %7B%0A        mAction = new TestKonashiWriteCharacteristicAction(mService, null);%0A        mAction = spy(mAction);%0A        doReturn(KonashiErrorType.INVALID_CONDITION).when(mAction).validate();%0A        doReturn(mCharacteristic).when(mAction).getCharacteristic();%0A        assertThat(mAction.execute(mWrapper)).isEqualTo(false);%0A        verify(mAction).validate();%0A    %7D%0A%0A    @Test%0A    public void execute_withValidateReturnNoError() throws Exception %7B%0A        mAction = new TestKonashiWriteCharacteristicAction(mService, null);%0A        mAction = spy(mAction);%0A        doReturn(KonashiErrorType.NO_ERROR).when(mAction).validate();%0A        doReturn(mCharacteristic).when(mAction).getCharacteristic();%0A        mAction.execute(mWrapper);%0A        verify(mAction).validate();%0A        verify(mAction).setValue();%0A    %7D%0A%0A%0A%7D

Create Test of execute()