public void testGetAllISBNs() { gateway.addCopy(new Book("isbn2", "Peace and War", "Toy Story")).getId(); List isbns = gateway.findAllISBNs(); assertEquals(2, isbns.size()); Iterator iter = isbns.iterator(); while (iter.hasNext()) assertTrue(((String) iter.next()).startsWith("isbn")); }
public void testAddCopiesCreatesUniqueIds() throws Exception { List copies = gateway.addCopies(new Book("isbn", "War and Peace", "Tolstoy"), 3); assertEquals(3, copies.size()); assertEquals(5, gateway.findAllCopies("isbn").size()); Set ids = new HashSet(); for (Iterator iter = gateway.findAllCopies("isbn").iterator(); iter.hasNext(); ) ids.add(((MediaCopy) iter.next()).getId()); assertEquals(5, ids.size()); }
protected void setUp() throws Exception { super.setUp(); gateway = new MockMediaGateway(); id1 = gateway.addCopy(new Book("isbn", "War and Peace", "Tolstoy")).getId(); id2 = gateway.addCopy(new Book("isbn", "War and Peace", "Tolstoy")).getId(); }