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