AggiungiMaglietta.java

1
package control.maglietta;
2
3
import model.CarrelloModel;
4
5
import javax.servlet.annotation.WebServlet;
6
import javax.servlet.http.HttpServlet;
7
import javax.servlet.http.HttpServletRequest;
8
import javax.servlet.http.HttpServletResponse;
9
import javax.servlet.http.HttpSession;
10
import java.io.IOException;
11
12
@WebServlet("/AggiungiMaglietta")
13
public class AggiungiMaglietta extends HttpServlet {
14
    @Override
15
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
16
            throws IOException {
17
18
        HttpSession session = req.getSession();
19
        CarrelloModel carrello;
20
21
        synchronized (session) {
22
            carrello = (CarrelloModel) session.getAttribute("carrello");
23 1 1. doPost : negated conditional → KILLED
            if (carrello == null) {
24
                carrello = new CarrelloModel();
25 1 1. doPost : removed call to javax/servlet/http/HttpSession::setAttribute → KILLED
                session.setAttribute("carrello", carrello);
26
            }
27
        }
28
29
        try {
30
            int id = Integer.parseInt(req.getParameter("ID"));
31
            String quantita = req.getParameter("quantita");
32
            String taglia = req.getParameter("taglia");
33
34 1 1. doPost : negated conditional → KILLED
            if (quantita == null) {
35 1 1. doPost : removed call to model/CarrelloModel::aggiungi → KILLED
                carrello.aggiungi(id, taglia);
36 1 1. doPost : removed call to javax/servlet/http/HttpServletResponse::sendRedirect → KILLED
                resp.sendRedirect("pages/carrello.jsp");
37
            } else {
38 1 1. doPost : removed call to model/CarrelloModel::setQuantita → KILLED
                carrello.setQuantita(id, Integer.parseInt(quantita), taglia);
39
            }
40
41
        } catch (NumberFormatException | IOException e) {
42 1 1. doPost : removed call to javax/servlet/http/HttpServletResponse::sendRedirect → KILLED
            resp.sendRedirect("pages/errorpage.jsp");
43
        }
44
    }
45
}

Mutations

23

1.1
Location : doPost
Killed by : control.maglietta.AggiungiMagliettaTest.[engine:junit-jupiter]/[class:control.maglietta.AggiungiMagliettaTest]/[method:doPost_carrelloNull_quantitaNull()]
negated conditional → KILLED

25

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

34

1.1
Location : doPost
Killed by : control.maglietta.AggiungiMagliettaTest.[engine:junit-jupiter]/[class:control.maglietta.AggiungiMagliettaTest]/[method:doPost_carrelloNull_quantitaNull()]
negated conditional → KILLED

35

1.1
Location : doPost
Killed by : control.maglietta.AggiungiMagliettaTest.[engine:junit-jupiter]/[class:control.maglietta.AggiungiMagliettaTest]/[method:doPost_carrelloNull_quantitaNull()]
removed call to model/CarrelloModel::aggiungi → KILLED

36

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

38

1.1
Location : doPost
Killed by : control.maglietta.AggiungiMagliettaTest.[engine:junit-jupiter]/[class:control.maglietta.AggiungiMagliettaTest]/[method:doPost_carrelloPresente_quantitaPresente()]
removed call to model/CarrelloModel::setQuantita → KILLED

42

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

Active mutators

Tests examined


Report generated by PIT 1.22.0