// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
//         super(missingCommandMessage(methodName, targetClass, arguments));
//     }
// 
//     public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
//         super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
//     }
// 
//     private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
//         return String.format("The %s%s method was not found on %s.",
//                 methodName,
//                 stringFor(arguments),
//                 targetClass.getName());
//     }
// 
//     private static String stringFor(Class<?>[] arguments) {
//         if (arguments.length == 0) {
//             return "()";
//         }
// 
//         final StringBuilder messageBuilder = new StringBuilder();
//         messageBuilder.append("(");
//         for (final Class<?> argumentType : arguments) {
//             messageBuilder.append(argumentType.getName() + ", ");
//         }
// 
//         messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
//         return messageBuilder.toString();
//     }
// 
//     private static int last(final StringBuilder messageBuilder, int count) {
//         return messageBuilder.length() - count;
//     }
// }
// 
// Path: driver/src/com/leandog/brazenhead/json/ExceptionSerializer.java
// public class ExceptionSummary {
// 
//     public final String exception;
//     public final String errorMessage;
// 
//     public final ExceptionSummary theCause;
// 
//     public ExceptionSummary(final Throwable exception) {
//         this.exception = exception.getClass().getName();
//         this.errorMessage = exception.getMessage();
//         this.theCause = theCause(exception);
//     }
// 
//     private ExceptionSummary theCause(final Throwable exception) {
//         Throwable cause = exception.getCause();
//         if (null == cause) {
//             return null;
//         }
// 
//         return new ExceptionSummary(exception.getCause());
//     }
// 
// }
// 
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
// 
//     public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
//         super(testClass, new File("../driver"));
//     }
//     
//     @Override
//     public Object createTest() throws Exception {
//         Object theTest = super.createTest();
//         MockitoAnnotations.initMocks(theTest);
//         return theTest;
//     }
//     
//     @Override
//     public void beforeTest(Method method) {
//         bindShadowClass(ShadowInstrumentationTestCase.class);
//     }
// 
// }


import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import java.io.*;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mortbay.jetty.*;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.*;
import com.google.brazenhead.gson.Gson;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
import com.leandog.brazenhead.json.ExceptionSerializer.ExceptionSummary;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.Solo;
        
        assertIsJson(jsonArg);
        assertHasFields(jsonArg.getValue(), "hasDrawable");
    }

    @Test
    public void itCanInvokeCommandsWithIntegers() throws Exception {
        post(new Command("clickInList", 7));
        verify(solo).clickInList(7);
    }

    @Test
    public void itCanInvokeCommandsWithFloats() throws Exception {
        post(new Command("clickLongOnScreen", 1.23f, 4.56f));
        verify(solo).clickLongOnScreen(1.23f, 4.56f);
    }

    @Test
    public void itCanInvokeCommandsWithStrings() throws Exception {
        post(new Command("clickOnMenuItem", "something"));
        verify(solo).clickOnMenuItem("something");
    }

    @Test
    public void itCanHandleErrorsThrownFromCommands() throws Exception {
        post(new Command("shouldNotExist"));

        ArgumentCaptor<String> responseArg = ArgumentCaptor.forClass(String.class);
        verify(responseWriter).print(responseArg.capture());

// Path: driver/src/com/leandog/brazenhead/exceptions/CommandNotFoundException.java
// public class CommandNotFoundException extends Exception {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public CommandNotFoundException(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
//         super(missingCommandMessage(methodName, targetClass, arguments));
//     }
// 
//     public CommandNotFoundException(final Command command, final Object theTarget, final Class<?>... arguments) {
//         super(missingCommandMessage(command.getName(), theTarget.getClass(), arguments));
//     }
// 
//     private static String missingCommandMessage(final String methodName, final Class<?> targetClass, final Class<?>... arguments) {
//         return String.format("The %s%s method was not found on %s.",
//                 methodName,
//                 stringFor(arguments),
//                 targetClass.getName());
//     }
// 
//     private static String stringFor(Class<?>[] arguments) {
//         if (arguments.length == 0) {
//             return "()";
//         }
// 
//         final StringBuilder messageBuilder = new StringBuilder();
//         messageBuilder.append("(");
//         for (final Class<?> argumentType : arguments) {
//             messageBuilder.append(argumentType.getName() + ", ");
//         }
// 
//         messageBuilder.replace(last(messageBuilder, 2), last(messageBuilder, 0), ")");
//         return messageBuilder.toString();
//     }
// 
//     private static int last(final StringBuilder messageBuilder, int count) {
//         return messageBuilder.length() - count;
//     }
// }
// 
// Path: driver/src/com/leandog/brazenhead/json/ExceptionSerializer.java
// public class ExceptionSummary {
// 
//     public final String exception;
//     public final String errorMessage;
// 
//     public final ExceptionSummary theCause;
// 
//     public ExceptionSummary(final Throwable exception) {
//         this.exception = exception.getClass().getName();
//         this.errorMessage = exception.getMessage();
//         this.theCause = theCause(exception);
//     }
// 
//     private ExceptionSummary theCause(final Throwable exception) {
//         Throwable cause = exception.getCause();
//         if (null == cause) {
//             return null;
//         }
// 
//         return new ExceptionSummary(exception.getCause());
//     }
// 
// }
// 
// Path: units/src/com/leandog/brazenhead/test/BrazenheadTestRunner.java
// public class BrazenheadTestRunner extends RobolectricTestRunner {
// 
//     public BrazenheadTestRunner(Class<?> testClass) throws InitializationError {
//         super(testClass, new File("../driver"));
//     }
//     
//     @Override
//     public Object createTest() throws Exception {
//         Object theTest = super.createTest();
//         MockitoAnnotations.initMocks(theTest);
//         return theTest;
//     }
//     
//     @Override
//     public void beforeTest(Method method) {
//         bindShadowClass(ShadowInstrumentationTestCase.class);
//     }
// 
// }


// Path: units/src/com/leandog/brazenhead/BrazenheadRequestHandlerTest.java
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.*;
import java.io.*;
import org.junit.*;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mortbay.jetty.*;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.*;
import com.google.brazenhead.gson.Gson;
import com.leandog.brazenhead.commands.*;
import com.leandog.brazenhead.exceptions.CommandNotFoundException;
import com.leandog.brazenhead.json.ExceptionSerializer.ExceptionSummary;
import com.leandog.brazenhead.test.BrazenheadTestRunner;
import com.robotium.solo.Solo;

        
        assertIsJson(jsonArg);
        assertHasFields(jsonArg.getValue(), "hasDrawable");
    }

    @Test
    public void itCanInvokeCommandsWithIntegers() throws Exception {
        post(new Command("clickInList", 7));
        verify(solo).clickInList(7);
    }

    @Test
    public void itCanInvokeCommandsWithFloats() throws Exception {
        post(new Command("clickLongOnScreen", 1.23f, 4.56f));
        verify(solo).clickLongOnScreen(1.23f, 4.56f);
    }

    @Test
    public void itCanInvokeCommandsWithStrings() throws Exception {
        post(new Command("clickOnMenuItem", "something"));
        verify(solo).clickOnMenuItem("something");
    }

    @Test
    public void itCanHandleErrorsThrownFromCommands() throws Exception {
        post(new Command("shouldNotExist"));

        ArgumentCaptor<String> responseArg = ArgumentCaptor.forClass(String.class);
        verify(responseWriter).print(responseArg.capture());

        final ExceptionSummary summary = new Gson().fromJson(responseArg.getValue(), ExceptionSummary.class);