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

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

Loading…
Cancel
Save