master
Meliurwen 5 years ago
parent d1527a3954
commit a0616f4a29
  1. 18
      mivan/src/test/java/mivan/AuthorTest.java
  2. 13
      mivan/src/test/java/mivan/LocationTest.java

@ -21,30 +21,20 @@ public class AuthorTest {
@Test @Test
@Order(1) @Order(1)
void testAddAuthor() { void testAddAuthor() {
String name = "Ivan"; String name = "Ivan";
Author author = new Author(name); Author author = new Author(name);
authorRepository.addAuthor(author); authorRepository.addAuthor(author);
int size = authorRepository.getSize(); int size = authorRepository.getSize();
assertEquals(size, 1); assertEquals(size, 1);
} }
@Test @Test
@Order(2) @Order(2)
void testUpdateAuthor() { void testUpdateAuthor() {
String name = "Ivan"; String name = "Ivan";
Author author = new Author(name); Author author = new Author(name);
authorRepository.addAuthor(author); authorRepository.addAuthor(author);
String updatedName = "Javoso"; String updatedName = "Javoso";
authorRepository.updateAuthor(author.getId(), updatedName); authorRepository.updateAuthor(author.getId(), updatedName);
Optional<Author> updated_author = authorRepository.findById(author.getId()); Optional<Author> updated_author = authorRepository.findById(author.getId());
updated_author.ifPresent(a -> { updated_author.ifPresent(a -> {
@ -55,20 +45,14 @@ public class AuthorTest {
@Test @Test
@Order(3) @Order(3)
void testDeleteUser() { void testDeleteAuthor() {
int size = authorRepository.getSize(); int size = authorRepository.getSize();
String name = "gollum"; String name = "gollum";
Author author = new Author(name); Author author = new Author(name);
authorRepository.addAuthor(author); authorRepository.addAuthor(author);
Author editAuthor = authorRepository.searchAuthorByName(name); Author editAuthor = authorRepository.searchAuthorByName(name);
long ID = editAuthor.getId(); long ID = editAuthor.getId();
authorRepository.deleteAuthorById(ID); authorRepository.deleteAuthorById(ID);
int end_size = authorRepository.getSize(); int end_size = authorRepository.getSize();
assertEquals(end_size, size); assertEquals(end_size, size);
} }

@ -31,20 +31,15 @@ public class LocationTest {
String lname = "test_add_location_name"; String lname = "test_add_location_name";
String ladress = "test_add_location_adress"; String ladress = "test_add_location_adress";
Location location = new Location(lname, ladress); Location location = new Location(lname, ladress);
int size = locationRepository.getSize(); int size = locationRepository.getSize();
locationRepository.addLocation(location); locationRepository.addLocation(location);
int newsize = locationRepository.getSize(); int newsize = locationRepository.getSize();
assertEquals(newsize, size + 1); assertEquals(newsize, size + 1);
} }
@Test @Test
@Order(2) @Order(2)
void testUpdateLocation() { void testUpdateLocation() {
// creo nuovo menìmbro dello staff // creo nuovo menìmbro dello staff
String firstname1 = "test_update_location_name1"; String firstname1 = "test_update_location_name1";
String lastname1 = "test_update_location_lastname1"; String lastname1 = "test_update_location_lastname1";
@ -87,29 +82,21 @@ public class LocationTest {
location.ifPresent(a -> { location.ifPresent(a -> {
assertEquals(a.getName(), newlname); assertEquals(a.getName(), newlname);
assertEquals(a.getAdress(), newladress); assertEquals(a.getAdress(), newladress);
assertEquals(a.getStaffs(), staffs);
}); });
} }
@Test @Test
@Order(3) @Order(3)
void testDeleteLocation() { void testDeleteLocation() {
String lname = "test_delete_location_name"; String lname = "test_delete_location_name";
String ladress = "test_delete_location_adress"; String ladress = "test_delete_location_adress";
Location location = new Location(lname, ladress); Location location = new Location(lname, ladress);
locationRepository.addLocation(location); locationRepository.addLocation(location);
Location removeLocation = locationRepository.searchLocationByName(lname); Location removeLocation = locationRepository.searchLocationByName(lname);
long ID = removeLocation.getId(); long ID = removeLocation.getId();
int size = locationRepository.getSize(); int size = locationRepository.getSize();
locationRepository.deleteLocationById(ID); locationRepository.deleteLocationById(ID);
int newsize = locationRepository.getSize(); int newsize = locationRepository.getSize();
assertEquals(newsize, size - 1); assertEquals(newsize, size - 1);
} }

Loading…
Cancel
Save