PanelPreferences.java

1
package com.jsql.view.swing.panel;
2
3
import com.jsql.util.I18nUtil;
4
import com.jsql.view.swing.panel.preferences.*;
5
import com.jsql.view.swing.panel.preferences.listener.ActionListenerSave;
6
import com.jsql.view.swing.util.MediatorHelper;
7
import com.jsql.view.swing.util.UiUtil;
8
import org.apache.commons.text.WordUtils;
9
10
import javax.swing.*;
11
import java.awt.*;
12
import java.awt.event.ActionListener;
13
import java.util.Arrays;
14
15
public class PanelPreferences extends JPanel {
16
17
    public static final String LIST_CATEGORIES_PREFERENCE = "listCategoriesPreference";
18
19
    private final transient ActionListener actionListenerSave = new ActionListenerSave(this);
20
    
21
    private final PanelConnection panelConnection = new PanelConnection(this);
22
    private final PanelStrategies panelStrategies = new PanelStrategies(this);
23
    private final PanelInjection panelInjection = new PanelInjection(this);
24
    private final PanelTampering panelTampering = new PanelTampering(this);
25
    private final PanelUserAgent panelUserAgent = new PanelUserAgent(this);
26
    private final PanelAuthentication panelAuthentication = new PanelAuthentication(this);
27
    private final PanelProxy panelProxy = new PanelProxy(this);
28
    private final PanelGeneral panelGeneral = new PanelGeneral(this);
29
30
    private enum CategoryPreference {
31
        CONNECTION,
32
        STRATEGIES,
33
        INJECTION,
34
        TAMPERING,
35
        EXPLOIT,
36
        USER_AGENT,
37
        AUTHENTICATION,
38
        PROXY,
39
        GENERAL;
40
41
        @Override
42
        public String toString() {
43 1 1. toString : replaced return value with "" for com/jsql/view/swing/panel/PanelPreferences$CategoryPreference::toString → NO_COVERAGE
            return "  "+ WordUtils.capitalizeFully(this.name()).replace('_', ' ') +"  ";
44
        }
45
    }
46
    
47
    public PanelPreferences() {
48 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::setLayout → NO_COVERAGE
        this.setLayout(new BorderLayout());
49 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::setBorder → NO_COVERAGE
        this.setBorder(UiUtil.BORDER_5PX);
50
51
        var cards = new JPanel(new CardLayout());
52 1 1. <init> : removed call to javax/swing/JPanel::setMinimumSize → NO_COVERAGE
        cards.setMinimumSize(new Dimension(0, 0));  // required
53
54
        JList<CategoryPreference> categories = PanelPreferences.getCategories(cards);
55 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::add → NO_COVERAGE
        this.add(categories, BorderLayout.LINE_START);
56
57 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE
        this.addToCard(cards, this.panelConnection, CategoryPreference.CONNECTION);
58 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE
        this.addToCard(cards, this.panelStrategies, CategoryPreference.STRATEGIES);
59 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE
        this.addToCard(cards, this.panelInjection, CategoryPreference.INJECTION);
60 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE
        this.addToCard(cards, this.panelTampering, CategoryPreference.TAMPERING);
61 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE
        this.addToCard(cards, new PanelExploit(), CategoryPreference.EXPLOIT);
62 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE
        this.addToCard(cards, this.panelUserAgent, CategoryPreference.USER_AGENT);
63 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE
        this.addToCard(cards, this.panelAuthentication, CategoryPreference.AUTHENTICATION);
64 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE
        this.addToCard(cards, this.panelProxy, CategoryPreference.PROXY);
65 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE
        this.addToCard(cards, this.panelGeneral, CategoryPreference.GENERAL);
66 1 1. <init> : removed call to com/jsql/view/swing/panel/PanelPreferences::add → NO_COVERAGE
        this.add(cards, BorderLayout.CENTER);
67
68 2 1. <init> : removed call to javax/swing/SwingUtilities::invokeLater → NO_COVERAGE
2. lambda$new$0 : removed call to com/jsql/view/swing/menubar/AppMenubar::switchLocale → NO_COVERAGE
        SwingUtilities.invokeLater(() -> MediatorHelper.menubar().switchLocale(I18nUtil.getCurrentLocale()));  // required for arabic
69
    }
70
71
    private static JList<CategoryPreference> getCategories(JPanel cards) {
72
        JList<CategoryPreference> categories = new JList<>(CategoryPreference.values());
73 1 1. getCategories : removed call to javax/swing/JList::setMinimumSize → NO_COVERAGE
        categories.setMinimumSize(new Dimension(0, 0));
74 1 1. getCategories : removed call to javax/swing/JList::setName → NO_COVERAGE
        categories.setName(PanelPreferences.LIST_CATEGORIES_PREFERENCE);
75 1 1. getCategories : removed call to javax/swing/JList::setSelectionMode → NO_COVERAGE
        categories.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
76 1 1. getCategories : removed call to javax/swing/JList::setSelectedIndex → NO_COVERAGE
        categories.setSelectedIndex(0);
77 1 1. getCategories : removed call to javax/swing/JList::addListSelectionListener → NO_COVERAGE
        categories.addListSelectionListener(e -> {
78
            CardLayout cardLayout = (CardLayout) cards.getLayout();
79 1 1. lambda$getCategories$1 : removed call to java/awt/CardLayout::show → NO_COVERAGE
            cardLayout.show(cards, categories.getSelectedValue().name());
80
        });
81 1 1. getCategories : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getCategories → NO_COVERAGE
        return categories;
82
    }
83
84
    private void addToCard(JPanel cards, JPanel panel, CategoryPreference category) {
85 1 1. addToCard : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE
        panel.setBorder(BorderFactory.createEmptyBorder(10, 15, 10, 15));
86 1 1. addToCard : negated conditional → NO_COVERAGE
        if (Arrays.asList(CategoryPreference.USER_AGENT, CategoryPreference.EXPLOIT).contains(category)) {
87 1 1. addToCard : removed call to javax/swing/JPanel::add → NO_COVERAGE
            cards.add(panel, category.name());
88
        } else {
89
            var scrollPane = new JScrollPane(panel);
90 1 1. addToCard : removed call to javax/swing/JScrollPane::setBorder → NO_COVERAGE
            scrollPane.setBorder(BorderFactory.createEmptyBorder());  // required to hide border
91 1 1. addToCard : removed call to javax/swing/JScrollBar::setUnitIncrement → NO_COVERAGE
            scrollPane.getVerticalScrollBar().setUnitIncrement(16);
92 1 1. addToCard : removed call to javax/swing/JScrollBar::setUnitIncrement → NO_COVERAGE
            scrollPane.getHorizontalScrollBar().setUnitIncrement(16);
93 1 1. addToCard : removed call to javax/swing/JPanel::add → NO_COVERAGE
            cards.add(scrollPane, category.name());
94
        }
95
    }
96
97
    
98
    // Getter and setter
99
100
    public PanelAuthentication getPanelAuthentication() {
101 1 1. getPanelAuthentication : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelAuthentication → NO_COVERAGE
        return this.panelAuthentication;
102
    }
103
104
    public PanelProxy getPanelProxy() {
105 1 1. getPanelProxy : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelProxy → NO_COVERAGE
        return this.panelProxy;
106
    }
107
108
    public PanelInjection getPanelInjection() {
109 1 1. getPanelInjection : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelInjection → NO_COVERAGE
        return this.panelInjection;
110
    }
111
112
    public PanelTampering getPanelTampering() {
113 1 1. getPanelTampering : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelTampering → NO_COVERAGE
        return this.panelTampering;
114
    }
115
116
    public PanelGeneral getPanelGeneral() {
117 1 1. getPanelGeneral : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelGeneral → NO_COVERAGE
        return this.panelGeneral;
118
    }
119
    
120
    public PanelConnection getPanelConnection() {
121 1 1. getPanelConnection : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelConnection → NO_COVERAGE
        return this.panelConnection;
122
    }
123
124
    public PanelStrategies getPanelStrategies() {
125 1 1. getPanelStrategies : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelStrategies → NO_COVERAGE
        return this.panelStrategies;
126
    }
127
128
    public PanelUserAgent getPanelUserAgent() {
129 1 1. getPanelUserAgent : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelUserAgent → NO_COVERAGE
        return this.panelUserAgent;
130
    }
131
132
    public ActionListener getActionListenerSave() {
133 1 1. getActionListenerSave : replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getActionListenerSave → NO_COVERAGE
        return this.actionListenerSave;
134
    }
135
}

Mutations

43

1.1
Location : toString
Killed by : none
replaced return value with "" for com/jsql/view/swing/panel/PanelPreferences$CategoryPreference::toString → NO_COVERAGE

48

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::setLayout → NO_COVERAGE

49

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::setBorder → NO_COVERAGE

52

1.1
Location : <init>
Killed by : none
removed call to javax/swing/JPanel::setMinimumSize → NO_COVERAGE

55

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::add → NO_COVERAGE

57

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE

58

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE

59

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE

60

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE

61

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE

62

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE

63

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE

64

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE

65

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::addToCard → NO_COVERAGE

66

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/panel/PanelPreferences::add → NO_COVERAGE

68

1.1
Location : <init>
Killed by : none
removed call to javax/swing/SwingUtilities::invokeLater → NO_COVERAGE

2.2
Location : lambda$new$0
Killed by : none
removed call to com/jsql/view/swing/menubar/AppMenubar::switchLocale → NO_COVERAGE

73

1.1
Location : getCategories
Killed by : none
removed call to javax/swing/JList::setMinimumSize → NO_COVERAGE

74

1.1
Location : getCategories
Killed by : none
removed call to javax/swing/JList::setName → NO_COVERAGE

75

1.1
Location : getCategories
Killed by : none
removed call to javax/swing/JList::setSelectionMode → NO_COVERAGE

76

1.1
Location : getCategories
Killed by : none
removed call to javax/swing/JList::setSelectedIndex → NO_COVERAGE

77

1.1
Location : getCategories
Killed by : none
removed call to javax/swing/JList::addListSelectionListener → NO_COVERAGE

79

1.1
Location : lambda$getCategories$1
Killed by : none
removed call to java/awt/CardLayout::show → NO_COVERAGE

81

1.1
Location : getCategories
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getCategories → NO_COVERAGE

85

1.1
Location : addToCard
Killed by : none
removed call to javax/swing/JPanel::setBorder → NO_COVERAGE

86

1.1
Location : addToCard
Killed by : none
negated conditional → NO_COVERAGE

87

1.1
Location : addToCard
Killed by : none
removed call to javax/swing/JPanel::add → NO_COVERAGE

90

1.1
Location : addToCard
Killed by : none
removed call to javax/swing/JScrollPane::setBorder → NO_COVERAGE

91

1.1
Location : addToCard
Killed by : none
removed call to javax/swing/JScrollBar::setUnitIncrement → NO_COVERAGE

92

1.1
Location : addToCard
Killed by : none
removed call to javax/swing/JScrollBar::setUnitIncrement → NO_COVERAGE

93

1.1
Location : addToCard
Killed by : none
removed call to javax/swing/JPanel::add → NO_COVERAGE

101

1.1
Location : getPanelAuthentication
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelAuthentication → NO_COVERAGE

105

1.1
Location : getPanelProxy
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelProxy → NO_COVERAGE

109

1.1
Location : getPanelInjection
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelInjection → NO_COVERAGE

113

1.1
Location : getPanelTampering
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelTampering → NO_COVERAGE

117

1.1
Location : getPanelGeneral
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelGeneral → NO_COVERAGE

121

1.1
Location : getPanelConnection
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelConnection → NO_COVERAGE

125

1.1
Location : getPanelStrategies
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelStrategies → NO_COVERAGE

129

1.1
Location : getPanelUserAgent
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getPanelUserAgent → NO_COVERAGE

133

1.1
Location : getActionListenerSave
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/PanelPreferences::getActionListenerSave → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.22.1