  @Test
  public void should_Return400_When_ServiceMethodThrowsVaadinConnectExceptionSubclass()
      throws Exception {

    int inputValue = 222;
    String expectedMessage = "OOPS";

    class MyCustomException extends VaadinConnectException {
      public MyCustomException() {
        super(expectedMessage);
      }
    }

    Method serviceMethodMock = createServiceMethodMockThatThrows(inputValue,
        new InvocationTargetException(new MyCustomException()));

    VaadinConnectController controller = createVaadinController(TEST_SERVICE);
    controller.vaadinServices.get(TEST_SERVICE_NAME.toLowerCase()).methods
        .put(TEST_METHOD.getName().toLowerCase(), serviceMethodMock);

    ResponseEntity<String> response = controller.serveVaadinService(
        TEST_SERVICE_NAME, TEST_METHOD.getName(),
        createRequestParameters(String.format("{\"value\": %s}", inputValue)));

    assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
    String responseBody = response.getBody();
    assertTrue(String.format("Invalid response body: '%s'", responseBody),
        responseBody.contains(MyCustomException.class.getName()));
    assertTrue(String.format("Invalid response body: '%s'", responseBody),
        responseBody.contains(expectedMessage));

    verify(serviceMethodMock, times(1)).invoke(TEST_SERVICE, inputValue);
    verify(serviceMethodMock, times(1)).getParameters();
  }