From 0850c9f730c15babc659ca771b7006959b280927 Mon Sep 17 00:00:00 2001 From: "@Territory91" Date: Mon, 13 Jan 2020 01:59:28 +0100 Subject: [PATCH] Update Loan.java and LoanTest.java --- mivan/src/main/java/mivan/model/Loan.java | 11 ++++++++++- mivan/src/test/java/mivan/LoanTest.java | 16 ++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/mivan/src/main/java/mivan/model/Loan.java b/mivan/src/main/java/mivan/model/Loan.java index 5c03d4b..8dfa84d 100644 --- a/mivan/src/main/java/mivan/model/Loan.java +++ b/mivan/src/main/java/mivan/model/Loan.java @@ -1,12 +1,18 @@ package mivan.model; +import java.io.Serializable; + import javax.persistence.Column; +import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.Table; -public class Loan { +@Entity +@Table(name = "loan") +public class Loan implements Serializable { private static final long serialVersionUID = -5124436115031696628L; @@ -35,6 +41,9 @@ public class Loan { @JoinColumn(name = "user") private User user; + public Loan() { + } + public Loan(long date_start, long date_end, String state, Item item, Staff staff, User user) { this.date_start = date_start; this.date_end = date_end; diff --git a/mivan/src/test/java/mivan/LoanTest.java b/mivan/src/test/java/mivan/LoanTest.java index 58552cf..af0ab4c 100644 --- a/mivan/src/test/java/mivan/LoanTest.java +++ b/mivan/src/test/java/mivan/LoanTest.java @@ -59,9 +59,9 @@ public class LoanTest { String update_state = "returned"; - loanRepository.updateLoan(1L,update_state); - - Optional opt_loan = loanRepository.findById(1L); + loanRepository.updateLoan(0L,update_state); + + Optional opt_loan = loanRepository.findById(0L); Loan loan2 = opt_loan.get(); assertTrue(update_state.equals(loan2.getState())); @@ -72,9 +72,9 @@ public class LoanTest { @Order(3) void testDeleteLoan() { - - long date_start = 1234; - long date_end = 2345; + int start_size = loanRepository.getSize(); + long date_start = 1876; + long date_end = 9876; String state = "loaning"; Item item = null; @@ -85,12 +85,12 @@ public class LoanTest { loanRepository.addLoan(loan); - Optional opt_loan2 = loanRepository.findById(1L); + Optional opt_loan2 = loanRepository.findById(0L); Loan book2 = opt_loan2.get(); long ID = book2.getId(); - int start_size = loanRepository.getSize(); + loanRepository.deleteLoanById(ID); int size = loanRepository.getSize();