Aggiornamento test Book e Author

develop
Meliurwen 5 years ago
parent 708184146f
commit a62040d5f7
  1. 2
      mivan/src/main/java/mivan/model/Book.java
  2. 7
      mivan/src/test/java/mivan/AuthorTest.java
  3. 49
      mivan/src/test/java/mivan/BookTest.java

@ -50,7 +50,7 @@ public class Book implements Serializable {
return isbn;
}
public String getTitolo() {
public String getTitle() {
return title;
}

@ -57,7 +57,8 @@ public class AuthorTest {
@Test
@Order(3)
void testDeleteUser() {
String name = "ivan";
int size = authorRepository.getSize();
String name = "gollum";
Author author = new Author(name);
@ -69,8 +70,8 @@ public class AuthorTest {
authorRepository.deleteAuthorById(ID);
int size = authorRepository.getSize();
assertEquals(size, 0);
int end_size = authorRepository.getSize();
assertEquals(end_size, size);
}

@ -1,6 +1,11 @@
package mivan;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Optional;
import javax.validation.constraints.AssertTrue;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@ -21,7 +26,7 @@ public class BookTest {
@Order(1)
void testAddBook() {
int isbn = 1234;
long isbn = 1234;
String title = "illiade";
Book prequel = null;
@ -36,6 +41,48 @@ public class BookTest {
}
@Test
@Order(2)
void testUpdateBook(){
long isbn = 12348;
String title = "odissea";
Book prequel = null;
Book book = new Book(isbn, title, prequel);
bookRepository.addBook(book);
String update_title = "eneide";
bookRepository.updateBook(isbn, update_title, prequel);
Optional<Book> opt_book2 = bookRepository.findById(isbn);
Book book2 = opt_book2.get();
assertTrue(update_title.equals(book2.getTitle()));
}
@Test
@Order(3)
void testDeleteBook() {
int start_size = bookRepository.getSize();
long isbn = 12345;
String title = "illiade";
Book prequel = null;
Book book = new Book(isbn, title, prequel);
bookRepository.addBook(book);
Optional<Book> opt_book2 = bookRepository.findById(isbn);
Book book2 = opt_book2.get();
long ID = book2.getIsbn();
bookRepository.deleteBookById(ID);
int size = bookRepository.getSize();
assertEquals(start_size,size);
}
}

Loading…
Cancel
Save