@Test
public void createWithScriptException() throws Exception {

    // Create transform objects
    TransformRequest request = new TransformRequest();
    request.setScript("sqlContext.sql(\"SELECT * FROM invalid\")");
    TransformService transformService = Mockito.mock(TransformService.class);
    Mockito.when(transformService.execute(request)).thenThrow(new ScriptException("Invalid script"));
    // Test script exception
    SparkShellTransformController controller = new SparkShellTransformController();
    controller.transformService = transformService;
    Response response = controller.create(request);
    Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR, response.getStatusInfo());
    TransformResponse entity = (TransformResponse) response.getEntity();
    Assert.assertEquals("Invalid script", entity.getMessage());
    Assert.assertEquals(TransformResponse.Status.ERROR, entity.getStatus());
}