コード例 #1
0
  @Test
  public void makingAnBillPersistantMakesItFetchable() {
    mapper.add(b);

    Bill read = mapper.getById(b.getId());
    assertEquals("Expected Bill should have the same content", b.getId(), read.getId());
  }
コード例 #2
0
  @Test
  public void makingAnBillPersistantMakesItFetchableFromAnotherMapper() {
    mapper.add(b);

    JPABillMapper anotherMapper = new JPABillMapper();
    Bill read = anotherMapper.getById(b.getId());
    assertEquals("Expected Bill should have the same content", b.getId(), read.getId());
  }
コード例 #3
0
 @Test
 public void getAllBillTest() {
   List<Bill> bills = mapper.getAllBill();
   for (Bill bill : bills) {
     System.out.println(bill);
   }
 }
コード例 #4
0
  @Test
  public void makingAnBillPersistentUpdatesHisId() {
    int oldId = b.getId();
    System.out.println("The old id is" + oldId);
    mapper.add(b);

    assertNotSame("Expected id differs from 0", oldId, b.getId());
  }
コード例 #5
0
  @Test
  public void updateTest() {
    Bill bill = new Bill();
    bill.setBegintime(new Date());
    bill.setEndtime(null);
    bill.setTableid(99);
    mapper.add(bill);
    System.out.println("\n");
    System.out.println("Bill after being add to the db");
    System.out.println(bill);
    System.out.println("\n");
    Bill updatedBill = bill;
    updatedBill.setTableid(69);
    updatedBill.setEndtime(new Date());
    System.out.println("\n");
    System.out.println("Bill after being updated in the db");

    mapper.update(updatedBill);
    System.out.println(updatedBill);
    System.out.println(mapper.getById(bill.getId()));
    System.out.println("\n");
    assertEquals(updatedBill.toString(), mapper.getById(bill.getId()).toString());
  }