@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()); }
@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()); }
@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()); }
@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()); }