class SaveBmiService extends IntentService {

    @Override
    protected void onHandleIntent(Intent intent) {
        if (intent == null) {
            return;
        }

        Serializable extra = intent.getSerializableExtra(PARAM_KEY_BMI_VALUE);
        if (extra == null || !(extra instanceof BmiValue)) {
            return;
        }

        BmiValue bmiValue = (BmiValue)extra;
        boolean result = saveToRemoteServer(bmiValue);
        sendLocalBroadcast(result);
    }

}

class SaveBmiServiceTest {

    @Test
    public void onHandleIntentにBmiValue型以外のデータが入ったIntentを渡したら何もしない() {

        Intent intent = mock(Intent.class);
        when(intent.getSerializableExtra(SaveBmiService.PARAM_KEY_BMI_VALUE)).thenReturn("hoge");

        SaveBmiService service = spy(new SaveBmiService());
        service.onHandleIntent(intent);
        verify(service, never()).sendLocalBroadcast(anyBoolean());
        verify(service, never()).saveToRemoteServer((BmiValue)any());
    }

}