diff --git a/mivan/src/main/java/mivan/model/User.java b/mivan/src/main/java/mivan/model/User.java index 3b4bdec..a153eab 100644 --- a/mivan/src/main/java/mivan/model/User.java +++ b/mivan/src/main/java/mivan/model/User.java @@ -1,6 +1,5 @@ package mivan.model; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; @@ -9,82 +8,58 @@ import javax.persistence.Table; @Table(name = "user") public class User extends Person { - private static final long serialVersionUID = -5124436115031696628L; - - @Column(name = "username", nullable=false,unique=true) - private String username; - - @Column(name = "email", nullable=false,unique=true) - private String email; - - @Column(name = "password", nullable=false) - private String password; - - - protected User() { - } - - - -public User(String firstName, String lastName, String city,String username, String email, String password) { - super(firstName,lastName,city); - this.username = username; - this.email = email; - this.password = password; -} - - - -public String getUsername() { - return username; -} - - - -public void setUsername(String username) { - this.username = username; -} - - - -public String getEmail() { - return email; -} - - - -public void setEmail(String email) { - this.email = email; -} - - - -public String getPassword() { - return password; -} + private static final long serialVersionUID = -5124436115031696628L; + @Column(name = "username", nullable = false, unique = true) + private String username; + @Column(name = "email", nullable = false, unique = true) + private String email; -public void setPassword(String password) { - this.password = password; -} + @Column(name = "password", nullable = false) + private String password; + protected User() { + } + public User(String firstName, String lastName, String city, String username, String email, String password) { + super(firstName, lastName, city); + this.username = username; + this.email = email; + this.password = password; + } -public static long getSerialversionuid() { - return serialVersionUID; -} + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public String getEmail() { + return email; + } -@Override -public String toString() { - return "User [username=" + username + ", email=" + email + ", password=" + password + "]"; -} + public void setEmail(String email) { + this.email = email; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public static long getSerialversionuid() { + return serialVersionUID; + } - + @Override + public String toString() { + return "User [username=" + username + ", email=" + email + ", password=" + password + "]"; + } } diff --git a/mivan/src/test/java/mivan/LocationTest.java b/mivan/src/test/java/mivan/LocationTest.java index 4202fa8..77b0f92 100644 --- a/mivan/src/test/java/mivan/LocationTest.java +++ b/mivan/src/test/java/mivan/LocationTest.java @@ -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 = 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); } } diff --git a/mivan/src/test/java/mivan/StaffTest.java b/mivan/src/test/java/mivan/StaffTest.java index 5920453..1a4fcaa 100644 --- a/mivan/src/test/java/mivan/StaffTest.java +++ b/mivan/src/test/java/mivan/StaffTest.java @@ -26,14 +26,14 @@ public class StaffTest { @Order(1) void testAddStaff() { - String firstname = "Ivan"; - String lastname = "Donati"; - String city = "Milano"; - String idka = "lihwelhqluchwlir8"; - String ruolo = "frontoffice"; - - String lname = "Library bria 2"; - String ladress = "via chissa dove"; + String firstname = "test_add_staff_name"; + String lastname = "test_add_staff_lastname"; + String city = "test_add_staff_city"; + String idka = "test_add_staff_idka"; + String ruolo = "test_add_staff_role"; + + String lname = "test_add_staff_loc_name"; + String ladress = "test_add_staff_loc_adress"; Location location = new Location(lname, ladress); locationRepository.addLocation(location); @@ -55,13 +55,13 @@ public class StaffTest { void testUpdateStaff() { // creo una locazione - String lname = "Library cosa 2"; - String ladress = "via chissa dove"; + String lname = "test_update_staff_loc_name"; + String ladress = "test_update_staff_loc_adress"; Location location = new Location(lname, ladress); // creo una seconda locazione - String newlName = "Library destra 5"; - String newlAdress = "via prossima stella"; + String newlName = "test_update_staff_loc_newname"; + String newlAdress = "test_update_staff_loc_newname"; Location newlocation = new Location(newlName, newlAdress); int losize = locationRepository.getSize(); @@ -73,12 +73,13 @@ public class StaffTest { assertEquals(newlosize, losize + 2); // ci sono 2 locazioni aggunte - // creo un membro dello staff - String firstname = "Maccio"; - String lastname = "Donati"; - String city = "Milano"; - String idka = "lihwelhqluchwlir8"; - String ruolo = "frontoffice"; + // creo un membro dello staff + String firstname = "test_update_staff_name"; + String lastname = "test_update_staff_lastname"; + String city = "test_update_staff_city"; + String idka = "test_update_staff_idka"; + String ruolo = "test_update_staff_role"; + Staff newstaff = new Staff(firstname, lastname, city, idka, ruolo); int size = staffRepository.getSize(); @@ -92,11 +93,11 @@ public class StaffTest { Staff editStaff = staffRepository.searchStaffByidka(idka); long id = editStaff.getId(); - String newfirstname = "Ivans"; - String newlastname = "Donatis"; - String newcity = "Milanos"; - String newidka = "lihwelhkluchwlir5"; - String newruolo = "spazzino"; + String newfirstname = "test_update_staff_newname"; + String newlastname = "test_update_staff_newlastname"; + String newcity = "test_update_staff_newcity"; + String newidka = "test_update_staff_newidka"; + String newruolo = "test_update_staff_newrole"; staffRepository.updateStaff(id, newfirstname, newlastname, newcity, newidka, newruolo, newlocation); @@ -117,14 +118,14 @@ public class StaffTest { @Order(3) void testDeleteStaff() { - String firstname = "John"; - String lastname = "Donati"; - String city = "Milano"; - String idka = "lihwelhsfghhwlir8"; - String ruolo = "manager"; + String firstname = "test_delete_staff_name"; + String lastname = "test_delete_staff_lastname"; + String city = "test_delete_staff_city"; + String idka = "test_delete_staff_idka"; + String ruolo = "test_delete_staff_role"; - String lname = "Library siniz 2"; - String ladress = "via sassa dove"; + String lname = "test_delete_staff_loc_name"; + String ladress = "test_delete_staff_loc_adress"; Location location = new Location(lname, ladress); locationRepository.addLocation(location); diff --git a/mivan/src/test/java/mivan/UserTest.java b/mivan/src/test/java/mivan/UserTest.java index d7efa13..efc8f40 100644 --- a/mivan/src/test/java/mivan/UserTest.java +++ b/mivan/src/test/java/mivan/UserTest.java @@ -23,12 +23,12 @@ class UserTest { @Order(1) void testAddUser() { - String firstname = "Ivan"; - String lastname = "Donati"; - String city = "Milano"; - String username = "p.donati"; - String email = "p.donati@campus.unimib.it"; - String password = "pdonatipassword"; + String firstname = "test_add_user_name"; + String lastname = "test_add_user_lastname"; + String city = "test_add_user_city"; + String username = "test_add_user_username"; + String email = "test_add_user_email"; + String password = "test_add_user_password"; User user = new User(firstname, lastname, city, username, email, password); int size = userRepository.getSize(); @@ -44,12 +44,12 @@ class UserTest { @Order(2) void testUpdateCompany() { - String firstname = "Simone"; - String lastname = "Donati"; - String city = "Milano"; - String username = "i.donati"; - String email = "i.donati@campus.unimib.it"; - String password = "passwordsicura"; + String firstname = "test_update_user_name"; + String lastname = "test_update_user_lastname"; + String city = "test_update_user_city"; + String username = "test_update_user_username"; + String email = "test_update_user_email"; + String password = "test_update_user_password"; User newuser = new User(firstname, lastname, city, username, email, password); @@ -59,12 +59,12 @@ class UserTest { long id = editUser.getId(); - String newfirstname = "Ivans"; - String newlastname = "Donatis"; - String newcity = "Milanos"; - String newusername = "asd.donati1s"; - String newemail = "asd.donati@campus.unimib.com"; - String newpassword = "newpdonatipassword"; + String newfirstname = "test_update_user_newname"; + String newlastname = "test_update_user_newlastname"; + String newcity = "test_update_user_newcity"; + String newusername = "test_update_user_newusername"; + String newemail = "test_update_user_newemail"; + String newpassword = "test_update_user_newpassword"; userRepository.updateUser(id, newfirstname, newlastname, newcity, newusername, newemail, newpassword); @@ -84,12 +84,12 @@ class UserTest { @Order(3) void testDeleteUser() { - String firstname = "Rossi"; - String lastname = "Donati"; - String city = "Milano"; - String username = "r.donati"; - String email = "r.donati@campus.unimib.it"; - String password = "rdonatipassword"; + String firstname = "test_delete_user_name"; + String lastname = "test_delete_user_lastname"; + String city = "test_delete_user_city"; + String username = "test_delete_user_username"; + String email = "test_delete_user_email"; + String password = "test_delete_user_password"; User newuser = new User(firstname, lastname, city, username, email, password);