コード例 #1
0
  /** Test if the updating throw a {@link NullPointerException} by passing an invalid ID argument */
  @Test(expected = NullPointerException.class)
  public void testUpdateWithInvalidId() {
    controller.edit(m, Long.MAX_VALUE);
    Map<String, Object> map = m.asMap();
    Client c = (Client) map.get("client");

    c.setName("Sun");
    controller.update(c, new MapBindingResult(Collections.emptyMap(), ""));
  }
コード例 #2
0
  /**
   * Test if the {@link Client} has been well updated. The following conditions are checked :<br>
   *
   * <ul>
   *   <li>The new value for the updated property can be read with the {@link ClientDAO}
   *   <li>The view is redirected to the client.html page
   * </ul>
   */
  @Test
  public void testUpdate() {
    controller.edit(m, clientId);
    Map<String, Object> map = m.asMap();
    Client c = (Client) map.get("client");

    c.setName("Sun");
    String view = controller.update(c, new MapBindingResult(Collections.emptyMap(), ""));

    assertEquals("Sun", clientDAO.findById(clientId).getName());
    assertEquals("redirect:/client.html", view);
  }