### Question:
InstanceBasedAutomationResultBuilder implements AutomationResultBuilder { @Override public AutomationResult buildAutomationResult(Throwable throwable) { if (throwable instanceof AssertionError) { return AutomationResult.ASSERTION_ERROR; } else if (throwable instanceof TimeoutException) { return AutomationResult.TIMEOUT; } else if (throwable instanceof InterruptedException) { return AutomationResult.INTERRUPTED; } else if (throwable instanceof org.openqa.selenium.TimeoutException) { return AutomationResult.TIMEOUT; } else if (throwable instanceof WebDriverActionExecutionException) { return buildAutomationResult(throwable.getCause()); } return AutomationResult.UNRECOGNIZED_EXCEPTION; }  @Override AutomationResult buildAutomationResult(Throwable throwable);  }### Answer:
@Test public void correctlyCreatesAssertionError() { Throwable throwable = new AssertionError(); AutomationResultBuilder automationResultBuilder = new InstanceBasedAutomationResultBuilder(); AutomationResult automationResult = automationResultBuilder.buildAutomationResult(throwable); assertEquals(automationResult, AutomationResult.ASSERTION_ERROR); }
@Test public void correctlyCreatesTimeoutExceptionSelenium() { Throwable throwable = new TimeoutException(); AutomationResultBuilder automationResultBuilder = new InstanceBasedAutomationResultBuilder(); AutomationResult automationResult = automationResultBuilder.buildAutomationResult(throwable); assertEquals(automationResult, AutomationResult.TIMEOUT); }
@Test public void correctlyCreatesTimeoutExceptionThread() { Throwable throwable = new java.util.concurrent.TimeoutException(); AutomationResultBuilder automationResultBuilder = new InstanceBasedAutomationResultBuilder(); AutomationResult automationResult = automationResultBuilder.buildAutomationResult(throwable); assertEquals(automationResult, AutomationResult.TIMEOUT); }
@Test public void correctlyCreatesInterruptedExceptionThread() { Throwable throwable = new InterruptedException(); AutomationResultBuilder automationResultBuilder = new InstanceBasedAutomationResultBuilder(); AutomationResult automationResult = automationResultBuilder.buildAutomationResult(throwable); assertEquals(automationResult, AutomationResult.INTERRUPTED); }
@Test public void correctlyCreatesUnrecognizedException() { Throwable throwable = new NullPointerException(); AutomationResultBuilder automationResultBuilder = new InstanceBasedAutomationResultBuilder(); AutomationResult automationResult = automationResultBuilder.buildAutomationResult(throwable); assertEquals(automationResult, AutomationResult.UNRECOGNIZED_EXCEPTION); }
@Test public void correctlyCreatesExceptionWhenWeAreInterestedInTheCause() { Throwable interrupted = new InterruptedException(); Throwable throwable = new WebDriverActionExecutionException("Something happened!", interrupted, mock(AutomationResultBuilder.class)); AutomationResultBuilder automationResultBuilder = new InstanceBasedAutomationResultBuilder(); AutomationResult automationResult = automationResultBuilder.buildAutomationResult(throwable); assertEquals(automationResult, AutomationResult.INTERRUPTED); }