package fi.hsl.parkandride.itest;

import static com.jayway.restassured.RestAssured.when;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.is;

import org.junit.Test;
import org.springframework.http.HttpStatus;

import com.jayway.restassured.http.ContentType;

public class ErrorHandlingITest extends AbstractIntegrationTest {
    @Test
    public void notFound() {
        when()
            .get("api/v1/facilities/42")
        .then()
            .statusCode(HttpStatus.NOT_FOUND.value())
            .body(is(""))
        ;
    }


    // validationException
    // bindException
    // jsonException
    // methodNotSupportedException
    // exception
}

@@ -28,16 +28,72 @@
 itest;%0A%0A
+import static com.jayway.restassured.RestAssured.given;%0A
 import s
@@ -135,24 +135,24 @@
 sured.when;%0A
-
 import stati
@@ -222,24 +222,79 @@
 tchers.is;%0A%0A
+import java.io.Serializable;%0A%0Aimport org.junit.Ignore;%0A
 import org.j
@@ -398,16 +398,65 @@
 tType;%0A%0A
+import fi.hsl.parkandride.core.domain.Facility;%0A%0A
 public c
@@ -725,35 +725,464 @@
  %7D%0A%0A
-%0A    // validationException
+    @Test%0A    public void validationException() %7B%0A        given()%0A            .header(%22Content-Type%22, %22application/json;charset=UTF-8%22)%0A            .body(new Facility())%0A        .when()%0A            .post(%22/api/v1/facilities%22)%0A        .then()%0A            .statusCode(HttpStatus.BAD_REQUEST.value())%0A            .body(%22status%22, is(HttpStatus.BAD_REQUEST.value()))%0A            .body(%22message%22, is(%22Invalid data. See violations for details.%22))%0A        ;%0A    %7D%0A
 %0A   

test error handling, validation exception