package com.basgeekball.awesomevalidation.validators;

import android.content.Context;
import android.widget.EditText;

import com.basgeekball.awesomevalidation.ValidationHolder;
import com.basgeekball.awesomevalidation.utility.ViewsInfo;

import junit.framework.TestCase;

import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.api.support.membermodification.MemberModifier;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.ArrayList;

import static org.mockito.Mockito.RETURNS_MOCKS;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(PowerMockRunner.class)
public class UnderlabelValidatorTest extends TestCase {

    private UnderlabelValidator mSpiedUnderlabelValidator;
    private ValidationHolder mMockedValidationHolder;
    private Context mMockedContext;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mSpiedUnderlabelValidator = PowerMockito.spy(new UnderlabelValidator());
        mMockedValidationHolder = mock(ValidationHolder.class);
        mMockedContext = mock(Context.class, RETURNS_MOCKS);
        mSpiedUnderlabelValidator.mValidationHolderList.add(mMockedValidationHolder);
    }

    public void testHalt() throws IllegalAccessException {
        ViewsInfo mockedViewsInfo = mock(ViewsInfo.class);
        ArrayList<ViewsInfo> viewsInfos = new ArrayList<>();
        viewsInfos.add(mockedViewsInfo);
        EditText mockedEditText = mock(EditText.class);
        MemberModifier.field(UnderlabelValidator.class, "mViewsInfos").set(mSpiedUnderlabelValidator, viewsInfos);
        doNothing().when(mockedViewsInfo).restoreViews();
        when(mMockedValidationHolder.getEditText()).thenReturn(mockedEditText);
        when(mockedEditText.requestFocus()).thenReturn(true);
        mSpiedUnderlabelValidator.halt();
        assertTrue(viewsInfos.isEmpty());
    }

}

@@ -52,40 +52,8 @@
 s;%0A%0A
-import android.content.Context;%0A
 impo
@@ -80,16 +80,16 @@
 itText;%0A
+
 %0Aimport 
@@ -470,57 +470,8 @@
 t;%0A%0A
-import static org.mockito.Mockito.RETURNS_MOCKS;%0A
 impo
@@ -797,44 +797,8 @@
 der;
-%0A    private Context mMockedContext;
 %0A%0A  
@@ -955,24 +955,24 @@
 lidator());%0A
+
         mMoc
@@ -1027,69 +1027,8 @@
 s);%0A
-        mMockedContext = mock(Context.class, RETURNS_MOCKS);%0A
     

Remove unused mock