Beispiel #1
0
  @Test
  public void testCreatePetResponse() {
    Result result = callAction(routes.ref.Pets.list(), fakeRequest());
    JsonNode node = Json.parse(contentAsString(result));
    assertEquals(1l, node.get(0).get("id").asLong());
    assertEquals("Lassie", node.get(0).get("name").asText());

    ImmutableMap<String, String> data = ImmutableMap.of("petId", "1", "petResponse", "hello");
    FakeRequest request = fakeRequest().withFormUrlEncodedBody(data);
    result = callAction(routes.ref.Pets.createPetResponse(), request);
    assertEquals(HttpStatus.SC_OK, status(result));
    assertEquals("Lassie says hello", contentAsString(result));
  }
Beispiel #2
0
 @Test
 public void testGettingNonExistingPet() {
   Result result = callAction(routes.ref.Pets.show(99999), fakeRequest());
   assertEquals(HttpStatus.SC_NOT_FOUND, status(result));
 }