Пример #1
0
 public void testPostSetDateRendersWelcome() throws Exception {
   makeRequest("POST", "setDate");
   request.setParameter("date", "1/1/2005");
   controller.handle(request);
   assertTrue(helper.shouldRender("welcome.jsp"));
   assertEquals(DateUtil.dateFromString("1/1/2005"), TimeSource.time());
 }
  public void testDeleteCopiesForUnknownIsbnDoesNothing() throws Exception {
    int mediaCount = mockInMemoryMediaGateway.copyCount();
    request.setParameter("delete_100", "on");
    assertEquals(mediaCount, mockInMemoryMediaGateway.copyCount());
    ActionResult result = booksController.handle(request);

    assertEquals("", result.getInfoMessage());
    assertEquals("", result.getWarningMessage());
    assertEquals("", result.getErrorMessage());
  }
  public void testDeleteThreeCopiesForValidIsbn() throws Exception {
    assertISBNKnownWithEntries("3", 3);
    assertEquals(6, mockInMemoryMediaGateway.copyCount());
    List copies = mockInMemoryMediaGateway.findAllCopies("3");
    for (Iterator iter = copies.iterator(); iter.hasNext(); ) {
      MediaCopy copy = (MediaCopy) iter.next();
      String id = copy.getId();
      request.setParameter("delete_" + id, "on");
    }

    ActionResult result = booksController.handle(request);
    assertTrue(mockInMemoryMediaGateway.contains("3"));
    assertISBNKnownWithEntries("3", 0);
    assertEquals(3, mockInMemoryMediaGateway.copyCount());

    assertTrue(result.getInfoMessage().length() > 0);
    assertEquals("", result.getWarningMessage());
    assertEquals("", result.getErrorMessage());
  }