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