Registrazione.java

1
package control.utente;
2
3
import model.utente.UtenteBean;
4
import model.utente.UtenteDAO;
5
6
import javax.servlet.ServletException;
7
import javax.servlet.annotation.WebServlet;
8
import javax.servlet.http.HttpServlet;
9
import javax.servlet.http.HttpServletRequest;
10
import javax.servlet.http.HttpServletResponse;
11
import java.io.IOException;
12
import java.sql.SQLException;
13
import java.time.LocalDate;
14
15
@WebServlet("/Registrazione")
16
public class Registrazione extends HttpServlet {
17
    @Override
18
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
19
        String username = req.getParameter("usernameReg");
20
        String password = req.getParameter("passwordReg");
21
        String nome = req.getParameter("nomeReg");
22
        String cognome = req.getParameter("cognomeReg");
23
        String email = req.getParameter("emailReg");
24
        String tipo = req.getParameter("tipo");
25
        LocalDate dataNascita;
26
        try {
27
            dataNascita = LocalDate.parse(req.getParameter("dataNascitaReg"));
28
        } catch (Exception ex) {
29 1 1. doPost : removed call to javax/servlet/RequestDispatcher::forward → KILLED
            req.getRequestDispatcher("/pages/errorpage.jsp").forward(req, resp);
30
            return;
31
        }
32
33
        UtenteDAO utenteDAO = new UtenteDAO();
34
35
        try {
36 1 1. doPost : negated conditional → KILLED
            if (utenteDAO.doRetrieveByKey(username) != null ||
37 1 1. doPost : negated conditional → KILLED
                    utenteDAO.doRetrieveByEmail(email) != null) {
38 1 1. doPost : removed call to javax/servlet/http/HttpSession::setAttribute → KILLED
                req.getSession().setAttribute("utentePresente", true);
39
            } else {
40 1 1. doPost : removed call to javax/servlet/http/HttpSession::setAttribute → KILLED
                req.getSession().setAttribute("utentePresente", false);
41
                UtenteBean utenteBean = new UtenteBean();
42 1 1. doPost : removed call to model/utente/UtenteBean::setUsername → KILLED
                utenteBean.setUsername(username);
43 1 1. doPost : removed call to model/utente/UtenteBean::setPwd → KILLED
                utenteBean.setPwd(password);
44 1 1. doPost : removed call to model/utente/UtenteBean::setNome → KILLED
                utenteBean.setNome(nome);
45 1 1. doPost : removed call to model/utente/UtenteBean::setCognome → KILLED
                utenteBean.setCognome(cognome);
46 1 1. doPost : removed call to model/utente/UtenteBean::setEmail → KILLED
                utenteBean.setEmail(email);
47 1 1. doPost : removed call to model/utente/UtenteBean::setDataNascita → KILLED
                utenteBean.setDataNascita(dataNascita);
48 1 1. doPost : removed call to model/utente/UtenteBean::setTipo → KILLED
                utenteBean.setTipo(tipo);
49
50 1 1. doPost : removed call to model/utente/UtenteDAO::doSave → KILLED
                utenteDAO.doSave(utenteBean);
51
            }
52
        } catch (SQLException e) {
53 1 1. doPost : removed call to javax/servlet/RequestDispatcher::forward → KILLED
            req.getRequestDispatcher("/pages/errorpage.jsp").forward(req, resp);
54
            return;
55
        }
56
57 1 1. doPost : removed call to javax/servlet/http/HttpServletResponse::sendRedirect → KILLED
        resp.sendRedirect("pages/login.jsp");
58
    }
59
60
    @Override
61
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
62 1 1. doGet : removed call to control/utente/Registrazione::doPost → KILLED
       doPost(req,resp);
63
    }
64
}

Mutations

29

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_dataNull_forwardError_noRedirect_noDAO()]
removed call to javax/servlet/RequestDispatcher::forward → KILLED

36

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_usernamePresente_setTrue_noSave_noEmailLookup_redirect()]
negated conditional → KILLED

37

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_emailPresente_setTrue_noSave_redirect()]
negated conditional → KILLED

38

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_usernamePresente_setTrue_noSave_noEmailLookup_redirect()]
removed call to javax/servlet/http/HttpSession::setAttribute → KILLED

40

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_sqlException_inSave_forwardError_noRedirect()]
removed call to javax/servlet/http/HttpSession::setAttribute → KILLED

42

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_userNonPresente_salva_eRedirect()]
removed call to model/utente/UtenteBean::setUsername → KILLED

43

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_userNonPresente_salva_eRedirect()]
removed call to model/utente/UtenteBean::setPwd → KILLED

44

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_userNonPresente_salva_eRedirect()]
removed call to model/utente/UtenteBean::setNome → KILLED

45

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_userNonPresente_salva_eRedirect()]
removed call to model/utente/UtenteBean::setCognome → KILLED

46

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_userNonPresente_salva_eRedirect()]
removed call to model/utente/UtenteBean::setEmail → KILLED

47

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_userNonPresente_salva_eRedirect()]
removed call to model/utente/UtenteBean::setDataNascita → KILLED

48

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_adminNonPresente_salva_eRedirect()]
removed call to model/utente/UtenteBean::setTipo → KILLED

50

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doGet_delegaDoPost()]
removed call to model/utente/UtenteDAO::doSave → KILLED

53

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_sqlException_inRetrieve_forwardError_noRedirect()]
removed call to javax/servlet/RequestDispatcher::forward → KILLED

57

1.1
Location : doPost
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doPost_usernamePresente_setTrue_noSave_noEmailLookup_redirect()]
removed call to javax/servlet/http/HttpServletResponse::sendRedirect → KILLED

62

1.1
Location : doGet
Killed by : control.utente.RegistrazioneTest.[engine:junit-jupiter]/[class:control.utente.RegistrazioneTest]/[method:doGet_delegaDoPost()]
removed call to control/utente/Registrazione::doPost → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.0