|
|
|
@ -28,8 +28,8 @@ public class LocationTest { |
|
|
|
|
@Order(1) |
|
|
|
|
void testAddLocation() { |
|
|
|
|
|
|
|
|
|
String lname = "Library bria 2"; |
|
|
|
|
String ladress = "via chissa dove2"; |
|
|
|
|
String lname = "test_add_location_name"; |
|
|
|
|
String ladress = "test_add_location_adress"; |
|
|
|
|
Location location = new Location(lname, ladress); |
|
|
|
|
|
|
|
|
|
int size = locationRepository.getSize(); |
|
|
|
@ -46,18 +46,18 @@ public class LocationTest { |
|
|
|
|
void testUpdateLocation() { |
|
|
|
|
|
|
|
|
|
// creo nuovo menìmbro dello staff
|
|
|
|
|
String firstname = "Ivan"; |
|
|
|
|
String lastname = "Donati"; |
|
|
|
|
String city = "Milano"; |
|
|
|
|
String idka = "lihwelhqluchwlir8"; |
|
|
|
|
String ruolo = "frontoffice"; |
|
|
|
|
Staff newstaff1 = new Staff(firstname, lastname, city, idka, ruolo); |
|
|
|
|
|
|
|
|
|
String firstname2 = "Rossi"; |
|
|
|
|
String lastname2 = "Donati"; |
|
|
|
|
String city2 = "Milano"; |
|
|
|
|
String idka2 = "lihwelhsfgdghhwlir8"; |
|
|
|
|
String ruolo2 = "manager"; |
|
|
|
|
String firstname1 = "test_update_location_name1"; |
|
|
|
|
String lastname1 = "test_update_location_lastname1"; |
|
|
|
|
String city1 = "test_update_location_city1"; |
|
|
|
|
String idka1 = "test_update_location_idka1"; |
|
|
|
|
String ruolo1 = "test_update_location_role1"; |
|
|
|
|
Staff newstaff1 = new Staff(firstname1, lastname1, city1, idka1, ruolo1); |
|
|
|
|
|
|
|
|
|
String firstname2 = "test_update_location_name2"; |
|
|
|
|
String lastname2 = "test_update_location_lastname2"; |
|
|
|
|
String city2 = "test_update_location_city2"; |
|
|
|
|
String idka2 = "test_update_location_idka2"; |
|
|
|
|
String ruolo2 = "test_update_location_role2"; |
|
|
|
|
Staff newstaff2 = new Staff(firstname2, lastname2, city2, idka2, ruolo2); |
|
|
|
|
|
|
|
|
|
staffRepository.addStaff(newstaff1); |
|
|
|
@ -68,8 +68,8 @@ public class LocationTest { |
|
|
|
|
staffs.add(newstaff2); |
|
|
|
|
|
|
|
|
|
// creo una locazione
|
|
|
|
|
String lname = "Library cosa 2"; |
|
|
|
|
String ladress = "via chissa dove"; |
|
|
|
|
String lname = "test_update_location_name"; |
|
|
|
|
String ladress = "test_update_location_adress"; |
|
|
|
|
Location newlocation = new Location(lname, ladress); |
|
|
|
|
locationRepository.addLocation(newlocation); |
|
|
|
|
|
|
|
|
@ -77,16 +77,16 @@ public class LocationTest { |
|
|
|
|
|
|
|
|
|
long id = editLocation.getId(); |
|
|
|
|
// nuovi dati per modificare i vecchi
|
|
|
|
|
String newlName = "Library bria 5"; |
|
|
|
|
String newlAdress = "via prossima stella"; |
|
|
|
|
String newlname = "test_update_location_newname"; |
|
|
|
|
String newladress = "test_update_location_newadress"; |
|
|
|
|
|
|
|
|
|
// aggungo i membri dello staff / modifico i dati della location
|
|
|
|
|
locationRepository.updateLocation(id, newlName, newlAdress, staffs); |
|
|
|
|
locationRepository.updateLocation(id, newlname, newladress, staffs); |
|
|
|
|
|
|
|
|
|
Optional<Location> location = locationRepository.findById(id); |
|
|
|
|
location.ifPresent(a -> { |
|
|
|
|
assertEquals(a.getName(), newlName); |
|
|
|
|
assertEquals(a.getAdress(), newlAdress); |
|
|
|
|
assertEquals(a.getName(), newlname); |
|
|
|
|
assertEquals(a.getAdress(), newladress); |
|
|
|
|
assertEquals(a.getStaffs(), staffs); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -95,8 +95,8 @@ public class LocationTest { |
|
|
|
|
@Order(3) |
|
|
|
|
void testDeleteLocation() { |
|
|
|
|
|
|
|
|
|
String lname = "Library bria 9"; |
|
|
|
|
String ladress = "via chissa dove9"; |
|
|
|
|
String lname = "test_delete_location_name"; |
|
|
|
|
String ladress = "test_delete_location_adress"; |
|
|
|
|
Location location = new Location(lname, ladress); |
|
|
|
|
locationRepository.addLocation(location); |
|
|
|
|
|
|
|
|
@ -110,7 +110,7 @@ public class LocationTest { |
|
|
|
|
|
|
|
|
|
int newsize = locationRepository.getSize(); |
|
|
|
|
|
|
|
|
|
assertEquals(newsize, size -1); |
|
|
|
|
assertEquals(newsize, size - 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|