package com.episode6.hackit.mockspresso.mockito;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.Spy;

import static com.episode6.hackit.mockspresso.mockito.Conditions.mockCondition;
import static com.episode6.hackit.mockspresso.mockito.Conditions.spyCondition;
import static org.fest.assertions.api.Assertions.assertThat;

/**
 * Tests {@link MockitoFieldPreparer}
 */
@RunWith(JUnit4.class)
public class MockitoFieldPreparerTest {

  private MockitoFieldPreparer mFieldPreparer;

  @Mock Runnable mMockRunnable;
  @Spy Runnable mSpyRunnable = new Runnable() {
    @Override
    public void run() {

    }
  };

  @Before
  public void setup() {
    mFieldPreparer = new MockitoFieldPreparer();
  }

  @Test
  public void testMocksOnThisClass() {
    mFieldPreparer.prepareFields(this);

    assertThat(mMockRunnable)
        .isNotNull()
        .is(mockCondition());
    assertThat(mSpyRunnable)
        .isNotNull()
        .is(spyCondition());
  }

}

@@ -715,16 +715,47 @@
   %7D%0A  %7D;
+%0A  @Spy Runnable mSpyRunnable2;
 %0A%0A  @Bef
@@ -1084,15 +1084,95 @@
 ion());%0A
+    assertThat(mSpyRunnable2)%0A        .isNotNull()%0A        .is(spyCondition());%0A
   %7D%0A%0A%7D%0A

update MockitoFieldPreparerTest to also gen a spy