Search in sources :

Example 1 with Greeting

use of com.google.appengine.samples.angularjs_guestbook.domain.Greeting in project appengine-angular-guestbook-java by googlearchive.

the class GuestbookResourceTest method testSignGuestbook.

@Test
public void testSignGuestbook() throws ServletException, IOException {
    HttpServletRequest request = getMockedJsonRequest("{content:\"Test message\"}");
    final StringBuffer resultBuffer = new StringBuffer();
    HttpServletResponse response = getMockedServletResponse(resultBuffer);
    servletContainer.service(URI.create("http://localhost/"), URI.create("/guestbook/default"), request, response);
    logger.fine(resultBuffer.toString().trim());
    Gson gson = new GsonBuilder().create();
    GuestbookResponse result = gson.fromJson(resultBuffer.toString().trim(), GuestbookResponse.class);
    assertThat(result.getGuestbookName(), is("default"));
    assertThat(result.getGreetings().size(), is(1));
    Greeting greeting = result.getGreetings().get(0);
    assertThat(greeting.getContent(), is("Test message"));
    assertThat(greeting.getAuthor(), is("test@example.com"));
    assertThat(greeting.getDate(), instanceOf(Date.class));
    assertThat(result.getUserServiceInfo(), nullValue());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Greeting(com.google.appengine.samples.angularjs_guestbook.domain.Greeting) GsonBuilder(com.google.gson.GsonBuilder) GuestbookResponse(com.google.appengine.samples.angularjs_guestbook.domain.GuestbookResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) Gson(com.google.gson.Gson) Test(org.junit.Test)

Aggregations

Greeting (com.google.appengine.samples.angularjs_guestbook.domain.Greeting)1 GuestbookResponse (com.google.appengine.samples.angularjs_guestbook.domain.GuestbookResponse)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Test (org.junit.Test)1