コード例 #1
0
 protected void setUp() throws Exception {
   super.setUp();
   gateway = new MockMediaGateway();
   copy1 = gateway.addCopy(new Book("isbn", "War and Peace", "Tolstoy"));
   id1 = copy1.getId();
   copy2 = gateway.addCopy(new Book("isbn", "War and Peace", "Tolstoy"));
   id2 = copy2.getId();
 }
コード例 #2
0
 public void testGetAllISBNsAndTitles() {
   gateway.addCopy(new Book("isbn2", "Peace and War", "Toy Story")).getId();
   gateway.addCopy(new Book("isbn3", "Son of Peace and War", "Toy Story II")).getId();
   Map isbnsTitles = gateway.findAllISBNsAndTitles();
   assertEquals(3, isbnsTitles.size());
   Iterator iter = isbnsTitles.entrySet().iterator();
   while (iter.hasNext()) {
     Entry entry = (Entry) iter.next();
     assertTrue(((String) entry.getKey()).startsWith("isbn"));
     assertTrue(((String) entry.getValue()).contains("Peace"));
   }
 }
コード例 #3
0
 public void testFindAvailableCopyReturnsNullWhenCopyIsBorrowed() throws Exception {
   gateway.addCopy(new Book("isbn2", "Peace and War", "Toy Story")).getId();
   List copies = gateway.findAllCopies("isbn2");
   MediaCopy copy = (MediaCopy) copies.get(0);
   copy.setLoaned(new LoanReceipt(new Patron(DateUtil.dateFromString("1/1/2000"))));
   assertEquals(null, gateway.findAvailableCopy("isbn2"));
 }
コード例 #4
0
 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()) {
     String isbn = (String) iter.next();
     assertTrue(isbn, isbn.startsWith("isbn"));
   }
 }