@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 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()); }
@Override public long getItemId(int position) { return paymentDatabase.getPaymentIdByPosition(position); }