package com.episode6.hackit.chop;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(ChopTestTestRunner.class)
public class DefaultTaggerTest {

  @Mock Chop.Tree mTree;

  @Before
  public void setUp() {
    when(mTree.supportsLevel(any(Chop.Level.class)))
        .thenReturn(true);

    Chop.plantTree(mTree);
  }

  @Test
  public void testOuterClass() {
    String expectedTag = DefaultTaggerTest.class.getSimpleName();

    Chop.d("Test Message");

    verify(mTree).chopLog(
        any(Chop.Level.class),
        eq(expectedTag),
        anyString()
    );
  }

  @Test
  public void testAnonymousClass() {
    String expectedTag = DefaultTaggerTest.class.getSimpleName();

    new Runnable() {

      @Override
      public void run() {
        Chop.d("Test message");
      }
    }.run();

    verify(mTree).chopLog(
        any(Chop.Level.class),
        eq(expectedTag),
        anyString()
    );
  }

  @After
  public void cleanUp() {
    ChopInternals.TREE_FARM.digUpTree(mTree);
  }
}

@@ -760,105 +760,31 @@
 rify
-(mTree).chopLog(%0A        any(Chop.Level.class),%0A        eq(expectedTag),%0A        anyString()%0A    
+ExpectedTag(expectedTag
 );%0A 
@@ -1031,105 +1031,271 @@
 rify
-(mTree).chopLog(%0A        any(Chop.Level.class),%0A        eq(expectedTag),%0A        anyStrin
+ExpectedTag(expectedTag);%0A  %7D%0A%0A  @Test%0A  public void testInnerClass() %7B%0A    String expectedTag = DefaultTaggerTest.class.getSimpleName() + %22$%22 +%0A        InnerTestClass.class.getSimpleName();%0A%0A    new InnerTestClass().printLo
 g()
+;%0A
 %0A    
+verifyExpectedTag(expectedTag
 );%0A 
@@ -1382,11 +1382,279 @@
 ee);%0A  %7D
+%0A%0A  private void verifyExpectedTag(String expectedTag) %7B%0A    verify(mTree).chopLog(%0A        any(Chop.Level.class),%0A        eq(expectedTag),%0A        anyString());%0A  %7D%0A%0A  private class InnerTestClass %7B%0A    public void printLog() %7B%0A      Chop.d(%22Test Message%22);%0A    %7D%0A  %7D
 %0A%7D%0A

Add a test for inner class tags