// Path: src/main/java/com/hantsylabs/restexample/springmvc/model/PostForm.java
// @Data
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class PostForm implements Serializable {
// 
//     /**
//      *
//      */
//     private static final long serialVersionUID = 1L;
// 
//     @NotNull
//     @NotEmpty
//     private String title;
// 
//     @NotNull
//     @NotEmpty
//     private String content;
// 
// }
// 
// Path: src/main/java/com/hantsylabs/restexample/springmvc/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long>,//
//         JpaSpecificationExecutor<Post>{
// 
// }
// 
// Path: src/test/java/com/hantsylabs/restexample/springmvc/test/WebIntegrationTestBase.java
// public class WebIntegrationTestBase extends IntegrationTestBase {
// 
//     @LocalServerPort
//     protected int port;
// 
//     @Before
//     public void setup() {
//         clearData();
//         initData();
//     }
// 
// }


import com.hantsylabs.restexample.springmvc.model.PostForm;
import com.hantsylabs.restexample.springmvc.repository.PostRepository;
import com.hantsylabs.restexample.springmvc.test.WebIntegrationTestBase;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.http.ContentType;
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
import com.jayway.restassured.response.Response;
import javax.inject.Inject;
import static org.hamcrest.CoreMatchers.containsString;
import static com.jayway.restassured.RestAssured.given;
import lombok.extern.slf4j.Slf4j;
import static org.hamcrest.CoreMatchers.is;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
                .body(form)
                .contentType(ContentType.JSON)
                .when()
                .post("/api/posts")
                .then()
                .assertThat()
                .statusCode(HttpStatus.SC_CREATED)
                .and()
                .header("Location", containsString("/api/posts/"))
                .extract().response();

        String location = response.header("Location");

        log.debug("header location value @" + location);

        given().auth().basic(USER_NAME, PASSWORD)
                .contentType(ContentType.JSON)
                .when()
                .get(location)
                .then()
                .assertThat()
                .body("title", is("test title"))
                .body("content", is("test content"));

        PostForm updateForm = new PostForm();
        updateForm.setTitle("test udpate title");
        updateForm.setContent("test update content");

        given()
                .auth().basic(USER_NAME, PASSWORD)
// Path: src/main/java/com/hantsylabs/restexample/springmvc/model/PostForm.java
// @Data
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public class PostForm implements Serializable {
// 
//     /**
//      *
//      */
//     private static final long serialVersionUID = 1L;
// 
//     @NotNull
//     @NotEmpty
//     private String title;
// 
//     @NotNull
//     @NotEmpty
//     private String content;
// 
// }
// 
// Path: src/main/java/com/hantsylabs/restexample/springmvc/repository/PostRepository.java
// public interface PostRepository extends JpaRepository<Post, Long>,//
//         JpaSpecificationExecutor<Post>{
// 
// }
// 
// Path: src/test/java/com/hantsylabs/restexample/springmvc/test/WebIntegrationTestBase.java
// public class WebIntegrationTestBase extends IntegrationTestBase {
// 
//     @LocalServerPort
//     protected int port;
// 
//     @Before
//     public void setup() {
//         clearData();
//         initData();
//     }
// 
// }


// Path: src/test/java/com/hantsylabs/restexample/springmvc/test/testassured/RestAssuredApplicationTest.java
import com.hantsylabs.restexample.springmvc.model.PostForm;
import com.hantsylabs.restexample.springmvc.repository.PostRepository;
import com.hantsylabs.restexample.springmvc.test.WebIntegrationTestBase;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.http.ContentType;
import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
import com.jayway.restassured.response.Response;
import javax.inject.Inject;
import static org.hamcrest.CoreMatchers.containsString;
import static com.jayway.restassured.RestAssured.given;
import lombok.extern.slf4j.Slf4j;
import static org.hamcrest.CoreMatchers.is;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;

                .body(form)
                .contentType(ContentType.JSON)
                .when()
                .post("/api/posts")
                .then()
                .assertThat()
                .statusCode(HttpStatus.SC_CREATED)
                .and()
                .header("Location", containsString("/api/posts/"))
                .extract().response();

        String location = response.header("Location");

        log.debug("header location value @" + location);

        given().auth().basic(USER_NAME, PASSWORD)
                .contentType(ContentType.JSON)
                .when()
                .get(location)
                .then()
                .assertThat()
                .body("title", is("test title"))
                .body("content", is("test content"));

        PostForm updateForm = new PostForm();
        updateForm.setTitle("test udpate title");
        updateForm.setContent("test update content");

        given()
                .auth().basic(USER_NAME, PASSWORD)
                .body(updateForm)