package com.uxxu.konashi.lib;

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

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

/**
 * Created by izumin on 8/4/15.
 */
@RunWith(Enclosed.class)
public class KonashiUtilsTest {
    public static final String TAG = KonashiUtilsTest.class.getSimpleName();

    @Mock private BluetoothGattCharacteristic mCharacteristic;
    @Rule public ExpectedException thrown = ExpectedException.none();

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

    @Test
    public void testGetAnaLogValueOnAIO0() {
        byte[] values = new byte[]{0x03, 0x48};
        Mockito.when(mCharacteristic.getValue()).thenReturn(values);
        assertThat(KonashiUtils.getAnalogValue(Konashi.AIO0, mCharacteristic), is(840));
    }

    @Test
    public void testGetAnaLogValueOnAIO1() {
        byte[] values = new byte[]{0x03, 0x48};
        Mockito.when(mCharacteristic.getValue()).thenReturn(values);
        assertThat(KonashiUtils.getAnalogValue(Konashi.AIO1, mCharacteristic), is(840));
    }

    @Test
    public void testGetAnaLogValueOnAIO2() {
        byte[] values = new byte[]{0x03, 0x48};
        Mockito.when(mCharacteristic.getValue()).thenReturn(values);
        assertThat(KonashiUtils.getAnalogValue(Konashi.AIO2, mCharacteristic), is(840));
    }

    @Test
    public void testGetAnaLogValueOnUnknownAIO() {
        byte[] values = new byte[]{0x03, 0x48};
        Mockito.when(mCharacteristic.getValue()).thenReturn(values);
        thrown.expect(IllegalArgumentException.class);
        KonashiUtils.getAnalogValue(9999, mCharacteristic);
    }

    @Test
    public void testGetBatteryLevel() {
        byte[] values = new byte[]{0x55};
        Mockito.when(mCharacteristic.getValue()).thenReturn(values);
        assertThat(KonashiUtils.getBatteryLevel(mCharacteristic), is(85));
    }
}

@@ -204,56 +204,8 @@
 st;%0A
-import org.junit.experimental.runners.Enclosed;%0A
 impo
@@ -242,16 +242,16 @@
 eption;%0A
+
 import o
@@ -390,64 +390,35 @@
 org.
-hamcrest.CoreMatchers.is;%0Aimport static org.junit
+assertj.core.api
 .Assert
+ions
 .ass
@@ -480,16 +480,21 @@
 ith(
-Enclosed
+AndroidJUnit4
 .cla
@@ -1075,34 +1075,40 @@
 racteristic)
-, is
+).isEqualTo
 (840)
-)
 ;%0A    %7D%0A%0A   
@@ -1349,34 +1349,40 @@
 racteristic)
-, is
+).isEqualTo
 (840)
-)
 ;%0A    %7D%0A%0A   
@@ -1631,18 +1631,24 @@
 tic)
-, is
+).isEqualTo
 (840)
-)
 ;%0A  
@@ -2181,17 +2181,23 @@
 tic)
-, is
+).isEqualTo
 (85)
-)
 ;%0A  

Use AssertJ on KonashiUtilsTest