예제 #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"));
   }
 }