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()); }
private void assertISBNKnownWithEntries(String isbn, int numberOfCopiesExpected) { assertEquals(3, mockInMemoryMediaGateway.mediaCount()); assertEquals(numberOfCopiesExpected, mockInMemoryMediaGateway.findAllCopies(isbn).size()); }