コード例 #1
0
 @Test
 public void testIfDeletingWorks() throws Exception {
   long id = paymentDatabase.addPaymentAndReturnItsId(paymentInstance);
   int numberOfRows = paymentDatabase.getPaymentsNumber();
   paymentDatabase.deletePaymentByItsId(id);
   assertEquals(numberOfRows - 1, paymentDatabase.getPaymentsNumber());
 }
コード例 #2
0
 @Test
 public void getPaymentIdByPositionTest() throws Exception {
   Long id = paymentDatabase.addPaymentAndReturnItsId(paymentInstance);
   int position = paymentDatabase.getPaymentsNumber() - 1;
   Long paymentId = paymentDatabase.getPaymentIdByPosition(position);
   assertEquals(id, paymentId);
 }
コード例 #3
0
 @Test
 public void getPaymentByPositionTest() throws Exception {
   paymentDatabase.addPaymentAndReturnItsId(paymentInstance);
   int position = paymentDatabase.getPaymentsNumber() - 1;
   Payment payment = paymentDatabase.getPaymentByPosition(position);
   assertEquals(paymentInstance.getDate(), payment.getDate());
   assertEquals(paymentInstance.getDescription(), payment.getDescription());
   assertEquals(paymentInstance.getName(), payment.getName());
   assertEquals(paymentInstance.getPrice(), payment.getPrice());
   assertEquals(paymentInstance.isOpen(), payment.isOpen());
 }
コード例 #4
0
 @Test
 public void updatePaymentTest() throws Exception {
   Payment paymentLocalInstance = new Payment("updateTest", new Date(), "updateTest", 12.222);
   assertEquals(false, paymentLocalInstance.isOpen());
   paymentDatabase.addPaymentAndReturnItsId(paymentLocalInstance);
   long id = paymentDatabase.getPaymentIdByPosition(paymentDatabase.getPaymentsNumber() - 1);
   paymentLocalInstance.setName("update test after update");
   paymentLocalInstance.setIsOpen(true);
   paymentDatabase.updatePayment(paymentLocalInstance, id);
   Payment payment = paymentDatabase.getPaymentById(id);
   assertEquals(paymentLocalInstance.getName(), payment.getName());
   assertEquals(paymentLocalInstance.isOpen(), payment.isOpen());
 }
コード例 #5
0
 @Test
 public void testIfDeletingAllWorks() throws Exception {
   paymentDatabase.deleteAllPayments();
   assertEquals(0, paymentDatabase.getPaymentsNumber());
 }
コード例 #6
0
 @Test
 public void testIfAddingPaymentWorks() throws Exception {
   int numberOfRows = paymentDatabase.getPaymentsNumber();
   paymentDatabase.addPaymentAndReturnItsId(paymentInstance);
   assertEquals(numberOfRows + 1, paymentDatabase.getPaymentsNumber());
 }
コード例 #7
0
 @Override
 public int getCount() {
   return paymentDatabase.getPaymentsNumber();
 }