@Test
 public void testIfDeletingWorks() throws Exception {
   long id = paymentDatabase.addPaymentAndReturnItsId(paymentInstance);
   int numberOfRows = paymentDatabase.getPaymentsNumber();
   paymentDatabase.deletePaymentByItsId(id);
   assertEquals(numberOfRows - 1, paymentDatabase.getPaymentsNumber());
 }
 @Test
 public void getPaymentIdByPositionTest() throws Exception {
   Long id = paymentDatabase.addPaymentAndReturnItsId(paymentInstance);
   int position = paymentDatabase.getPaymentsNumber() - 1;
   Long paymentId = paymentDatabase.getPaymentIdByPosition(position);
   assertEquals(id, paymentId);
 }
 @Test
 public void getPaymentByIdTest() throws Exception {
   long id = paymentDatabase.addPaymentAndReturnItsId(paymentInstance);
   Payment payment = paymentDatabase.getPaymentById(id);
   assertEquals(paymentInstance.getDate(), payment.getDate());
   assertEquals(paymentInstance.getDescription(), payment.getDescription());
   assertEquals(paymentInstance.getName(), payment.getName());
   assertEquals(paymentInstance.getPrice(), payment.getPrice());
 }
 @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());
 }
 @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());
 }
 @Test
 public void testIfDeletingAllWorks() throws Exception {
   paymentDatabase.deleteAllPayments();
   assertEquals(0, paymentDatabase.getPaymentsNumber());
 }
 @Test
 public void testIfAddingPaymentWorks() throws Exception {
   int numberOfRows = paymentDatabase.getPaymentsNumber();
   paymentDatabase.addPaymentAndReturnItsId(paymentInstance);
   assertEquals(numberOfRows + 1, paymentDatabase.getPaymentsNumber());
 }
 @Override
 public Payment getItem(int position) {
   Payment payment = paymentDatabase.getPaymentByPosition(position);
   return payment;
 }
 public void deletePaymentByPosition(int position) {
   paymentDatabase.deletePaymentByItsId(getItemId(position));
 }
 @Override
 public long getItemId(int position) {
   return paymentDatabase.getPaymentIdByPosition(position);
 }
 @Override
 public int getCount() {
   return paymentDatabase.getPaymentsNumber();
 }
 public void updatePaymentInDatabase(Payment payment, int position) {
   paymentDatabase.updatePayment(payment, getItemId(position));
 }