コード例 #1
0
 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());
 }
コード例 #2
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"));
 }
コード例 #3
0
  public void testFindAvailableCopyReturnsCopyWhenOneCopyOfManyIsBorrowed() throws Exception {
    gateway.addCopies(new Book("isbn1", "Peace and War 1", "Toy Story"), 2);

    List copies = gateway.findAllCopies("isbn1");
    MediaCopy copy = (MediaCopy) copies.get(0);
    copy.setLoaned(new LoanReceipt(new Patron(DateUtil.dateFromString("1/1/2000"))));
    assertNotNull(gateway.findAvailableCopy("isbn1"));
  }
コード例 #4
0
 public void testCanFindMoreThanOneBook() throws Exception {
   List copies = gateway.findAllCopies("isbn");
   assertEquals(2, copies.size());
   assertTrue(copies.contains(copy1));
   assertTrue(copies.contains(copy2));
 }