Update Loan.java and LoanTest.java

develop
@Territory91 5 years ago
parent c0b79722a9
commit 0850c9f730
  1. 11
      mivan/src/main/java/mivan/model/Loan.java
  2. 14
      mivan/src/test/java/mivan/LoanTest.java

@ -1,12 +1,18 @@
package mivan.model; package mivan.model;
import java.io.Serializable;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; 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; private static final long serialVersionUID = -5124436115031696628L;
@ -35,6 +41,9 @@ public class Loan {
@JoinColumn(name = "user") @JoinColumn(name = "user")
private User user; private User user;
public Loan() {
}
public Loan(long date_start, long date_end, String state, Item item, Staff staff, User user) { public Loan(long date_start, long date_end, String state, Item item, Staff staff, User user) {
this.date_start = date_start; this.date_start = date_start;
this.date_end = date_end; this.date_end = date_end;

@ -59,9 +59,9 @@ public class LoanTest {
String update_state = "returned"; String update_state = "returned";
loanRepository.updateLoan(1L,update_state); loanRepository.updateLoan(0L,update_state);
Optional<Loan> opt_loan = loanRepository.findById(1L); Optional<Loan> opt_loan = loanRepository.findById(0L);
Loan loan2 = opt_loan.get(); Loan loan2 = opt_loan.get();
assertTrue(update_state.equals(loan2.getState())); assertTrue(update_state.equals(loan2.getState()));
@ -72,9 +72,9 @@ public class LoanTest {
@Order(3) @Order(3)
void testDeleteLoan() { void testDeleteLoan() {
int start_size = loanRepository.getSize();
long date_start = 1234; long date_start = 1876;
long date_end = 2345; long date_end = 9876;
String state = "loaning"; String state = "loaning";
Item item = null; Item item = null;
@ -85,12 +85,12 @@ public class LoanTest {
loanRepository.addLoan(loan); loanRepository.addLoan(loan);
Optional<Loan> opt_loan2 = loanRepository.findById(1L); Optional<Loan> opt_loan2 = loanRepository.findById(0L);
Loan book2 = opt_loan2.get(); Loan book2 = opt_loan2.get();
long ID = book2.getId(); long ID = book2.getId();
int start_size = loanRepository.getSize();
loanRepository.deleteLoanById(ID); loanRepository.deleteLoanById(ID);
int size = loanRepository.getSize(); int size = loanRepository.getSize();

Loading…
Cancel
Save