PanelTrailingAddress.java

1
package com.jsql.view.swing.panel.address;
2
3
import com.jsql.model.injection.strategy.AbstractStrategy;
4
import com.jsql.model.injection.strategy.StrategyError;
5
import com.jsql.model.injection.vendor.model.Vendor;
6
import com.jsql.model.injection.vendor.model.yaml.Method;
7
import com.jsql.util.I18nUtil;
8
import com.jsql.util.LogLevelUtil;
9
import com.jsql.view.swing.panel.PanelAddressBar;
10
import com.jsql.view.swing.text.JToolTipI18n;
11
import com.jsql.view.swing.util.I18nViewUtil;
12
import com.jsql.view.swing.util.MediatorHelper;
13
import com.jsql.view.swing.util.UiUtil;
14
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.Logger;
16
17
import javax.swing.*;
18
import java.awt.*;
19
import java.awt.event.MouseAdapter;
20
import java.awt.event.MouseEvent;
21
import java.util.Arrays;
22
import java.util.Locale;
23
import java.util.concurrent.atomic.AtomicReference;
24
import java.util.stream.StreamSupport;
25
26
public class PanelTrailingAddress extends JPanel {
27
28
    private static final Logger LOGGER = LogManager.getRootLogger();
29
30
    private JMenu itemRadioStrategyError;
31
32
    private final JLabel labelVendor = new JLabel(UiUtil.ARROW_DOWN.getIcon(), SwingConstants.LEFT);
33
    private final JLabel labelStrategy = new JLabel(UiUtil.ARROW_DOWN.getIcon(), SwingConstants.LEFT);
34
    private final JPopupMenu popupMenuVendors = new JPopupMenu();
35
    private final JPopupMenu popupMenuStrategies = new JPopupMenu();
36
37
    private final ButtonGroup groupStrategy = new ButtonGroup();
38
    private static final String PREFIX_NAME_ERROR = "itemRadioError";
39
    private static final String I18N_TOOLTIP_STRATEGY = "STRATEGY_%s_TOOLTIP";
40
41
    /**
42
     * Loader displayed during injection.
43
     */
44
    private final JProgressBar loader;
45
46
    /**
47
     * Connection button.
48
     */
49
    public final ButtonStart buttonStart = new ButtonStart();
50
    
51
    public PanelTrailingAddress(PanelAddressBar panelAddressBar) {
52 1 1. <init> : removed call to com/jsql/view/swing/panel/address/ButtonStart::addActionListener → NO_COVERAGE
        this.buttonStart.addActionListener(new ActionStart(panelAddressBar));
53 1 1. <init> : removed call to com/jsql/view/swing/panel/address/PanelTrailingAddress::setOpaque → NO_COVERAGE
        this.setOpaque(false);
54 1 1. <init> : removed call to com/jsql/view/swing/panel/address/PanelTrailingAddress::setBorder → NO_COVERAGE
        this.setBorder(null);
55 1 1. <init> : removed call to javax/swing/JLabel::setText → NO_COVERAGE
        this.labelStrategy.setText("Strategy auto");
56 1 1. <init> : removed call to javax/swing/JLabel::setName → NO_COVERAGE
        this.labelStrategy.setName("menuStrategy");
57
58
        for (final AbstractStrategy strategy: MediatorHelper.model().getMediatorStrategy().getStrategies()) {
59
            var nameStrategy = strategy.getName().toUpperCase(Locale.ROOT);
60
            JMenuItem itemRadioStrategy;
61 1 1. <init> : negated conditional → NO_COVERAGE
            if (strategy == MediatorHelper.model().getMediatorStrategy().getError()) {
62
                itemRadioStrategy = new JMenu(strategy.toString());
63
                this.itemRadioStrategyError = (JMenu) itemRadioStrategy;
64 1 1. <init> : removed call to java/awt/Component::setName → NO_COVERAGE
                itemRadioStrategy.getComponent().setName("itemRadioStrategyError");
65
            } else {
66
                var atomicTooltip = new AtomicReference<>(new JToolTipI18n(
67
                    I18nUtil.valueByKey(String.format(PanelTrailingAddress.I18N_TOOLTIP_STRATEGY, nameStrategy))
68
                ));
69
                itemRadioStrategy = new JRadioButtonMenuItem(strategy.toString()) {
70
                    @Override
71
                    public JToolTip createToolTip() {
72 1 1. createToolTip : removed call to java/util/concurrent/atomic/AtomicReference::set → NO_COVERAGE
                        atomicTooltip.set(new JToolTipI18n(
73
                            I18nUtil.valueByKey(
74
                                String.format(PanelTrailingAddress.I18N_TOOLTIP_STRATEGY, nameStrategy)
75
                            )
76
                        ));
77 1 1. createToolTip : replaced return value with null for com/jsql/view/swing/panel/address/PanelTrailingAddress$1::createToolTip → NO_COVERAGE
                        return atomicTooltip.get();
78
                    }
79
                };
80 1 1. <init> : removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE
                I18nViewUtil.addComponentForKey(
81
                    String.format(PanelTrailingAddress.I18N_TOOLTIP_STRATEGY, nameStrategy),
82
                    atomicTooltip.get()
83
                );
84 1 1. <init> : removed call to java/awt/Component::setName → NO_COVERAGE
                itemRadioStrategy.getComponent().setName("itemRadioStrategy" + strategy);
85 1 1. <init> : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE
                itemRadioStrategy.addActionListener(actionEvent -> {
86 1 1. lambda$new$0 : removed call to javax/swing/JLabel::setText → NO_COVERAGE
                    this.labelStrategy.setText(strategy.toString());
87 1 1. lambda$new$0 : removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE
                    MediatorHelper.model().getMediatorStrategy().setStrategy(strategy);
88
                });
89 1 1. <init> : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE
                this.groupStrategy.add(itemRadioStrategy);
90
            }
91
92
            this.popupMenuStrategies.add(itemRadioStrategy);
93 1 1. <init> : removed call to javax/swing/JMenuItem::setToolTipText → NO_COVERAGE
            itemRadioStrategy.setToolTipText(
94
                I18nUtil.valueByKey(String.format(PanelTrailingAddress.I18N_TOOLTIP_STRATEGY, nameStrategy))
95
            );
96 1 1. <init> : removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE
            itemRadioStrategy.setEnabled(false);
97
        }
98
99 1 1. <init> : removed call to javax/swing/JLabel::setText → NO_COVERAGE
        this.labelVendor.setText(MediatorHelper.model().getMediatorVendor().getAuto().toString());
100 1 1. <init> : removed call to javax/swing/JLabel::setName → NO_COVERAGE
        this.labelVendor.setName("menuVendor");
101 1 1. <init> : removed call to javax/swing/JPopupMenu::setLayout → NO_COVERAGE
        this.popupMenuVendors.setLayout(UiUtil.getColumnLayout(MediatorHelper.model().getMediatorVendor().getVendors().size()));
102
        var groupVendor = new ButtonGroup();
103
        for (final Vendor vendor: MediatorHelper.model().getMediatorVendor().getVendors()) {
104 1 1. <init> : negated conditional → NO_COVERAGE
            JMenuItem itemRadioVendor = new JRadioButtonMenuItem(vendor.toString(), vendor == MediatorHelper.model().getMediatorVendor().getAuto());
105 1 1. <init> : removed call to javax/swing/JMenuItem::setName → NO_COVERAGE
            itemRadioVendor.setName("itemRadioVendor"+ vendor);
106 1 1. <init> : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE
            itemRadioVendor.addActionListener(actionEvent -> {
107 1 1. lambda$new$1 : removed call to javax/swing/JLabel::setText → NO_COVERAGE
                this.labelVendor.setText(vendor.toString());
108 1 1. lambda$new$1 : removed call to com/jsql/model/injection/vendor/MediatorVendor::setVendorByUser → NO_COVERAGE
                MediatorHelper.model().getMediatorVendor().setVendorByUser(vendor);
109
            });
110
            this.popupMenuVendors.add(itemRadioVendor);
111 1 1. <init> : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE
            groupVendor.add(itemRadioVendor);
112
        }
113
114
        this.loader = new JProgressBar();
115
        var dimension = UIManager.getDimension("ProgressBar.horizontalSize");
116 1 1. <init> : removed call to javax/swing/JProgressBar::setPreferredSize → NO_COVERAGE
        this.loader.setPreferredSize(new Dimension(32, dimension.height));
117 1 1. <init> : removed call to javax/swing/JProgressBar::setIndeterminate → NO_COVERAGE
        this.loader.setIndeterminate(true);
118
        this.add(this.loader);
119
120 1 1. <init> : removed call to javax/swing/JLabel::addMouseListener → NO_COVERAGE
        this.labelVendor.addMouseListener(new MouseAdapter() {
121
            @Override
122
            public void mousePressed(MouseEvent e) {
123
                Arrays.stream(PanelTrailingAddress.this.popupMenuVendors.getComponents())
124
                    .map(JComponent.class::cast)
125 1 1. mousePressed : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
                    .forEach(JComponent::updateUI);  // required: incorrect when dark/light mode switch
126 1 1. mousePressed : removed call to javax/swing/JPopupMenu::updateUI → NO_COVERAGE
                PanelTrailingAddress.this.popupMenuVendors.updateUI();  // required: incorrect when dark/light mode switch
127 3 1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
2. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
3. mousePressed : removed call to javax/swing/JPopupMenu::show → NO_COVERAGE
                PanelTrailingAddress.this.popupMenuVendors.show(e.getComponent(), e.getComponent().getX(),5 + e.getComponent().getY() + e.getComponent().getHeight());
128 3 1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
2. mousePressed : removed call to javax/swing/JPopupMenu::setLocation → NO_COVERAGE
3. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
                PanelTrailingAddress.this.popupMenuVendors.setLocation(e.getComponent().getLocationOnScreen().x,5 + e.getComponent().getLocationOnScreen().y + e.getComponent().getHeight());
129
            }
130
        });
131 1 1. <init> : removed call to javax/swing/JLabel::addMouseListener → NO_COVERAGE
        this.labelStrategy.addMouseListener(new MouseAdapter() {
132
            @Override
133
            public void mousePressed(MouseEvent e) {
134 2 1. lambda$mousePressed$0 : replaced return value with null for com/jsql/view/swing/panel/address/PanelTrailingAddress$3::lambda$mousePressed$0 → NO_COVERAGE
2. mousePressed : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
                Arrays.stream(PanelTrailingAddress.this.popupMenuStrategies.getComponents()).map(a -> (JComponent) a).forEach(JComponent::updateUI);  // required: incorrect when dark/light mode switch
135 2 1. mousePressed : negated conditional → NO_COVERAGE
2. mousePressed : changed conditional boundary → NO_COVERAGE
                for (var i = 0 ; i < PanelTrailingAddress.this.getMenuError().getItemCount() ; i++) {
136 1 1. mousePressed : removed call to javax/swing/JMenuItem::updateUI → NO_COVERAGE
                    PanelTrailingAddress.this.getMenuError().getItem(i).updateUI();  // required: incorrect when dark/light mode switch
137
                }
138 1 1. mousePressed : removed call to javax/swing/JPopupMenu::updateUI → NO_COVERAGE
                PanelTrailingAddress.this.popupMenuStrategies.updateUI();  // required: incorrect when dark/light mode switch
139 3 1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
2. mousePressed : removed call to javax/swing/JPopupMenu::show → NO_COVERAGE
3. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
                PanelTrailingAddress.this.popupMenuStrategies.show(e.getComponent(), e.getComponent().getX(),5 + e.getComponent().getY() + e.getComponent().getHeight());
140 3 1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
2. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE
3. mousePressed : removed call to javax/swing/JPopupMenu::setLocation → NO_COVERAGE
                PanelTrailingAddress.this.popupMenuStrategies.setLocation(e.getComponent().getLocationOnScreen().x,5 + e.getComponent().getLocationOnScreen().y + e.getComponent().getHeight());
141
            }
142
        });
143
144
        this.add(this.labelVendor);
145
        this.add(this.labelStrategy);
146
        this.add(this.buttonStart);
147 1 1. <init> : removed call to com/jsql/view/swing/panel/address/PanelTrailingAddress::setCursor → NO_COVERAGE
        this.setCursor(Cursor.getDefaultCursor());
148 1 1. <init> : removed call to javax/swing/JProgressBar::setVisible → NO_COVERAGE
        this.loader.setVisible(false);
149
    }
150
151
    public void endPreparation() {
152 1 1. endPreparation : removed call to com/jsql/view/swing/panel/address/ButtonStart::setToolTipText → NO_COVERAGE
        this.buttonStart.setToolTipText(I18nUtil.valueByKey("BUTTON_START_TOOLTIP"));
153 1 1. endPreparation : removed call to com/jsql/view/swing/panel/address/ButtonStart::setInjectionReady → NO_COVERAGE
        this.buttonStart.setInjectionReady();
154 1 1. endPreparation : removed call to javax/swing/JProgressBar::setVisible → NO_COVERAGE
        this.loader.setVisible(false);
155
    }
156
    
157
    public void reset() {
158 1 1. reset : removed call to javax/swing/JLabel::setText → NO_COVERAGE
        this.labelStrategy.setText("Strategy auto");
159 1 1. reset : negated conditional → NO_COVERAGE
        if (MediatorHelper.model().getMediatorVendor().getVendorByUser() == MediatorHelper.model().getMediatorVendor().getAuto()) {
160 1 1. reset : removed call to javax/swing/JLabel::setText → NO_COVERAGE
            this.labelVendor.setText(MediatorHelper.model().getMediatorVendor().getAuto().toString());
161
        }
162
        Arrays.stream(this.popupMenuStrategies.getComponents())
163 2 1. reset : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
2. lambda$reset$2 : removed call to java/awt/Component::setEnabled → NO_COVERAGE
            .forEach(component -> component.setEnabled(false));
164 1 1. reset : removed call to javax/swing/JMenu::removeAll → NO_COVERAGE
        this.getMenuError().removeAll();
165
166 1 1. reset : removed call to javax/swing/ButtonGroup::clearSelection → NO_COVERAGE
        this.groupStrategy.clearSelection();
167 1 1. lambda$reset$3 : replaced return value with null for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$reset$3 → NO_COVERAGE
        Iterable<AbstractButton> iterable = () -> this.groupStrategy.getElements().asIterator();
168
        StreamSupport.stream(iterable.spliterator(), false)
169 2 1. lambda$reset$4 : replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$reset$4 → NO_COVERAGE
2. lambda$reset$4 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$reset$4 → NO_COVERAGE
            .filter(abstractButton -> abstractButton.getName().startsWith(PanelTrailingAddress.PREFIX_NAME_ERROR))
170 1 1. reset : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
            .forEach(this.groupStrategy::remove);
171
    }
172
    
173
    public void setVendor(Vendor vendor) {
174 1 1. setVendor : removed call to javax/swing/JLabel::setText → NO_COVERAGE
        this.labelVendor.setText(vendor.toString());
175 1 1. setVendor : removed call to javax/swing/JMenu::removeAll → NO_COVERAGE
        this.itemRadioStrategyError.removeAll();
176
        var indexError = 0;
177
        if (
178 1 1. setVendor : negated conditional → NO_COVERAGE
            vendor != MediatorHelper.model().getMediatorVendor().getAuto()
179 1 1. setVendor : negated conditional → NO_COVERAGE
            && vendor.instance().getModelYaml().getStrategy().getError() != null
180
        ) {
181
            for (Method methodError: vendor.instance().getModelYaml().getStrategy().getError().getMethod()) {
182
                JMenuItem itemRadioError = new JRadioButtonMenuItem(methodError.getName());
183 1 1. setVendor : removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE
                itemRadioError.setEnabled(false);
184 1 1. setVendor : removed call to javax/swing/JMenuItem::setName → NO_COVERAGE
                itemRadioError.setName(PanelTrailingAddress.PREFIX_NAME_ERROR + methodError.getName());
185
                this.itemRadioStrategyError.add(itemRadioError);
186 1 1. setVendor : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE
                this.groupStrategy.add(itemRadioError);
187
                int indexErrorFinal = indexError;
188 1 1. setVendor : removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE
                itemRadioError.addActionListener(actionEvent -> {
189 1 1. lambda$setVendor$5 : removed call to javax/swing/JLabel::setText → NO_COVERAGE
                    this.labelStrategy.setText(methodError.getName());
190 1 1. lambda$setVendor$5 : removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE
                    MediatorHelper.model().getMediatorStrategy().setStrategy(MediatorHelper.model().getMediatorStrategy().getError());
191 1 1. lambda$setVendor$5 : removed call to com/jsql/model/injection/strategy/StrategyError::setIndexErrorStrategy → NO_COVERAGE
                    MediatorHelper.model().getMediatorStrategy().getError().setIndexErrorStrategy(indexErrorFinal);
192
                });
193 1 1. setVendor : Changed increment from 1 to -1 → NO_COVERAGE
                indexError++;
194
            }
195
        }
196
    }
197
    
198
    public void markStrategy(AbstractStrategy strategy) {
199 1 1. markStrategy : removed call to javax/swing/JLabel::setText → NO_COVERAGE
        this.labelStrategy.setText(strategy.toString());
200
        Arrays.stream(this.popupMenuStrategies.getComponents())
201
            .map(JMenuItem.class::cast)
202 2 1. lambda$markStrategy$6 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategy$6 → NO_COVERAGE
2. lambda$markStrategy$6 : replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategy$6 → NO_COVERAGE
            .filter(jMenuItem -> jMenuItem.getText().equals(strategy.toString()))
203 2 1. lambda$markStrategy$7 : removed call to javax/swing/JMenuItem::setSelected → NO_COVERAGE
2. markStrategy : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
            .forEach(jMenuItem -> jMenuItem.setSelected(true));
204
    }
205
    
206
    public void markStrategyInvulnerable(AbstractStrategy strategy) {
207
        Arrays.stream(this.popupMenuStrategies.getComponents())
208
            .map(JMenuItem.class::cast)
209 2 1. lambda$markStrategyInvulnerable$8 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategyInvulnerable$8 → NO_COVERAGE
2. lambda$markStrategyInvulnerable$8 : replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategyInvulnerable$8 → NO_COVERAGE
            .filter(jMenuItem -> jMenuItem.getText().equals(strategy.toString()))
210 2 1. lambda$markStrategyInvulnerable$9 : removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE
2. markStrategyInvulnerable : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
            .forEach(jMenuItem -> jMenuItem.setEnabled(false));
211
    }
212
    
213
    public void markErrorInvulnerable(int indexMethodError) {
214
        AbstractStrategy strategy = MediatorHelper.model().getMediatorStrategy().getError();
215
        Arrays.stream(this.popupMenuStrategies.getSubElements())
216
            .map(JMenuItem.class::cast)
217 2 1. lambda$markErrorInvulnerable$10 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$10 → NO_COVERAGE
2. lambda$markErrorInvulnerable$10 : replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$10 → NO_COVERAGE
            .filter(jMenuItem -> jMenuItem.getText().equals(strategy.toString()))
218
            .map(JMenu.class::cast)
219
            .filter(jMenuItem -> {
220
                var isNotNull = true;
221
                // Fix #36975: ArrayIndexOutOfBoundsException on getItem()
222
                // Fix #40352: NullPointerException on ?
223
                // Fix #95855: NPE on setEnabled()
224
                try {
225 1 1. lambda$markErrorInvulnerable$11 : negated conditional → NO_COVERAGE
                    isNotNull = jMenuItem.getItem(indexMethodError) != null;
226
                } catch (ArrayIndexOutOfBoundsException e) {
227
                    LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e);
228 1 1. lambda$markErrorInvulnerable$11 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$11 → NO_COVERAGE
                    return false;
229
                }
230 2 1. lambda$markErrorInvulnerable$11 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$11 → NO_COVERAGE
2. lambda$markErrorInvulnerable$11 : replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$11 → NO_COVERAGE
                return isNotNull;
231
            })
232 2 1. lambda$markErrorInvulnerable$12 : removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE
2. markErrorInvulnerable : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
            .forEach(jMenuItem -> jMenuItem.getItem(indexMethodError).setEnabled(false));
233
    }
234
    
235
    public void markError() {
236
        StrategyError strategy = MediatorHelper.model().getMediatorStrategy().getError();
237 1 1. markError : removed call to javax/swing/JLabel::setText → NO_COVERAGE
        this.labelStrategy.setText(strategy.toString());
238
        int indexError = strategy.getIndexErrorStrategy();
239
        String nameError = MediatorHelper.model().getMediatorVendor().getVendor().instance().getModelYaml().getStrategy().getError().getMethod().get(indexError).getName();
240
241
        Arrays.stream(this.getMenuError().getMenuComponents())
242
            .map(JRadioButtonMenuItem.class::cast)
243 2 1. lambda$markError$13 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markError$13 → NO_COVERAGE
2. lambda$markError$13 : replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markError$13 → NO_COVERAGE
            .filter(component -> component.getText().equals(nameError))
244 1 1. markError : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
            .forEach(jRadioButtonMenuItem -> {
245 1 1. lambda$markError$14 : removed call to javax/swing/JRadioButtonMenuItem::setSelected → NO_COVERAGE
                jRadioButtonMenuItem.setSelected(true);
246 1 1. lambda$markError$14 : removed call to javax/swing/JLabel::setText → NO_COVERAGE
                this.labelStrategy.setText(nameError);
247
            });
248
    }
249
250
    private JMenu getMenuError() {
251
        var nameError = MediatorHelper.model().getMediatorStrategy().getError().getName();
252 1 1. getMenuError : replaced return value with null for com/jsql/view/swing/panel/address/PanelTrailingAddress::getMenuError → NO_COVERAGE
        return (JMenu) Arrays.stream(this.popupMenuStrategies.getComponents())
253
            .map(JMenuItem.class::cast)
254 2 1. lambda$getMenuError$15 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$getMenuError$15 → NO_COVERAGE
2. lambda$getMenuError$15 : replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$getMenuError$15 → NO_COVERAGE
            .filter(jMenuItem -> jMenuItem.getText().equalsIgnoreCase(nameError))
255
            .findFirst()
256
            .orElse(new JMenuItem("Mock"));
257
    }
258
259
    public void markErrorVulnerable(int indexMethodError) {
260
        AbstractStrategy strategy = MediatorHelper.model().getMediatorStrategy().getError();
261
        // Fix #46578: ArrayIndexOutOfBoundsException on getItem()
262
        try {
263
            Arrays.stream(this.popupMenuStrategies.getComponents())
264
                .map(JMenuItem.class::cast)
265 2 1. lambda$markErrorVulnerable$16 : replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorVulnerable$16 → NO_COVERAGE
2. lambda$markErrorVulnerable$16 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorVulnerable$16 → NO_COVERAGE
                .filter(jMenuItem -> jMenuItem.getText().equals(strategy.toString()))
266
                .map(JMenu.class::cast)
267 2 1. lambda$markErrorVulnerable$17 : negated conditional → NO_COVERAGE
2. lambda$markErrorVulnerable$17 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorVulnerable$17 → NO_COVERAGE
                .filter(jMenuItem -> jMenuItem.getItem(indexMethodError) != null)
268 1 1. markErrorVulnerable : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
                .forEach(jMenuItem -> {
269 1 1. lambda$markErrorVulnerable$18 : removed call to javax/swing/JMenu::setEnabled → NO_COVERAGE
                    jMenuItem.setEnabled(true);
270 1 1. lambda$markErrorVulnerable$18 : removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE
                    jMenuItem.getItem(indexMethodError).setEnabled(true);
271
                });
272
        } catch (ArrayIndexOutOfBoundsException e) {
273
            LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e);
274
        }
275
    }
276
    
277
    public void markStrategyVulnerable(AbstractStrategy strategy) {
278
        Arrays.stream(this.popupMenuStrategies.getComponents())
279
            .map(JMenuItem.class::cast)
280 2 1. lambda$markStrategyVulnerable$19 : replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategyVulnerable$19 → NO_COVERAGE
2. lambda$markStrategyVulnerable$19 : replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategyVulnerable$19 → NO_COVERAGE
            .filter(jMenuItem -> jMenuItem.getText().equals(strategy.toString()))
281 2 1. markStrategyVulnerable : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
2. lambda$markStrategyVulnerable$20 : removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE
            .forEach(jMenuItem -> jMenuItem.setEnabled(true));
282
    }
283
    
284
    
285
    // Getter and setter
286
287
    public JComponent getLoader() {
288 1 1. getLoader : replaced return value with null for com/jsql/view/swing/panel/address/PanelTrailingAddress::getLoader → NO_COVERAGE
        return this.loader;
289
    }
290
291
    public ButtonStart getButtonStart() {
292 1 1. getButtonStart : replaced return value with null for com/jsql/view/swing/panel/address/PanelTrailingAddress::getButtonStart → NO_COVERAGE
        return this.buttonStart;
293
    }
294
}

Mutations

52

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

53

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

54

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

55

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

56

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

61

1.1
Location : <init>
Killed by : none
negated conditional → NO_COVERAGE

64

1.1
Location : <init>
Killed by : none
removed call to java/awt/Component::setName → NO_COVERAGE

72

1.1
Location : createToolTip
Killed by : none
removed call to java/util/concurrent/atomic/AtomicReference::set → NO_COVERAGE

77

1.1
Location : createToolTip
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/address/PanelTrailingAddress$1::createToolTip → NO_COVERAGE

80

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/util/I18nViewUtil::addComponentForKey → NO_COVERAGE

84

1.1
Location : <init>
Killed by : none
removed call to java/awt/Component::setName → NO_COVERAGE

85

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

86

1.1
Location : lambda$new$0
Killed by : none
removed call to javax/swing/JLabel::setText → NO_COVERAGE

87

1.1
Location : lambda$new$0
Killed by : none
removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE

89

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

93

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

96

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

99

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

100

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

101

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

104

1.1
Location : <init>
Killed by : none
negated conditional → NO_COVERAGE

105

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

106

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

107

1.1
Location : lambda$new$1
Killed by : none
removed call to javax/swing/JLabel::setText → NO_COVERAGE

108

1.1
Location : lambda$new$1
Killed by : none
removed call to com/jsql/model/injection/vendor/MediatorVendor::setVendorByUser → NO_COVERAGE

111

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

116

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

117

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

120

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

125

1.1
Location : mousePressed
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

126

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::updateUI → NO_COVERAGE

127

1.1
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

3.3
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::show → NO_COVERAGE

128

1.1
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::setLocation → NO_COVERAGE

3.3
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

131

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

134

1.1
Location : lambda$mousePressed$0
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/address/PanelTrailingAddress$3::lambda$mousePressed$0 → NO_COVERAGE

2.2
Location : mousePressed
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

135

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

2.2
Location : mousePressed
Killed by : none
changed conditional boundary → NO_COVERAGE

136

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/JMenuItem::updateUI → NO_COVERAGE

138

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::updateUI → NO_COVERAGE

139

1.1
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::show → NO_COVERAGE

3.3
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

140

1.1
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

3.3
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::setLocation → NO_COVERAGE

147

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

148

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

152

1.1
Location : endPreparation
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setToolTipText → NO_COVERAGE

153

1.1
Location : endPreparation
Killed by : none
removed call to com/jsql/view/swing/panel/address/ButtonStart::setInjectionReady → NO_COVERAGE

154

1.1
Location : endPreparation
Killed by : none
removed call to javax/swing/JProgressBar::setVisible → NO_COVERAGE

158

1.1
Location : reset
Killed by : none
removed call to javax/swing/JLabel::setText → NO_COVERAGE

159

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

160

1.1
Location : reset
Killed by : none
removed call to javax/swing/JLabel::setText → NO_COVERAGE

163

1.1
Location : reset
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

2.2
Location : lambda$reset$2
Killed by : none
removed call to java/awt/Component::setEnabled → NO_COVERAGE

164

1.1
Location : reset
Killed by : none
removed call to javax/swing/JMenu::removeAll → NO_COVERAGE

166

1.1
Location : reset
Killed by : none
removed call to javax/swing/ButtonGroup::clearSelection → NO_COVERAGE

167

1.1
Location : lambda$reset$3
Killed by : none
replaced return value with null for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$reset$3 → NO_COVERAGE

169

1.1
Location : lambda$reset$4
Killed by : none
replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$reset$4 → NO_COVERAGE

2.2
Location : lambda$reset$4
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$reset$4 → NO_COVERAGE

170

1.1
Location : reset
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

174

1.1
Location : setVendor
Killed by : none
removed call to javax/swing/JLabel::setText → NO_COVERAGE

175

1.1
Location : setVendor
Killed by : none
removed call to javax/swing/JMenu::removeAll → NO_COVERAGE

178

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

179

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

183

1.1
Location : setVendor
Killed by : none
removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE

184

1.1
Location : setVendor
Killed by : none
removed call to javax/swing/JMenuItem::setName → NO_COVERAGE

186

1.1
Location : setVendor
Killed by : none
removed call to javax/swing/ButtonGroup::add → NO_COVERAGE

188

1.1
Location : setVendor
Killed by : none
removed call to javax/swing/JMenuItem::addActionListener → NO_COVERAGE

189

1.1
Location : lambda$setVendor$5
Killed by : none
removed call to javax/swing/JLabel::setText → NO_COVERAGE

190

1.1
Location : lambda$setVendor$5
Killed by : none
removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE

191

1.1
Location : lambda$setVendor$5
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyError::setIndexErrorStrategy → NO_COVERAGE

193

1.1
Location : setVendor
Killed by : none
Changed increment from 1 to -1 → NO_COVERAGE

199

1.1
Location : markStrategy
Killed by : none
removed call to javax/swing/JLabel::setText → NO_COVERAGE

202

1.1
Location : lambda$markStrategy$6
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategy$6 → NO_COVERAGE

2.2
Location : lambda$markStrategy$6
Killed by : none
replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategy$6 → NO_COVERAGE

203

1.1
Location : lambda$markStrategy$7
Killed by : none
removed call to javax/swing/JMenuItem::setSelected → NO_COVERAGE

2.2
Location : markStrategy
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

209

1.1
Location : lambda$markStrategyInvulnerable$8
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategyInvulnerable$8 → NO_COVERAGE

2.2
Location : lambda$markStrategyInvulnerable$8
Killed by : none
replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategyInvulnerable$8 → NO_COVERAGE

210

1.1
Location : lambda$markStrategyInvulnerable$9
Killed by : none
removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE

2.2
Location : markStrategyInvulnerable
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

217

1.1
Location : lambda$markErrorInvulnerable$10
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$10 → NO_COVERAGE

2.2
Location : lambda$markErrorInvulnerable$10
Killed by : none
replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$10 → NO_COVERAGE

225

1.1
Location : lambda$markErrorInvulnerable$11
Killed by : none
negated conditional → NO_COVERAGE

228

1.1
Location : lambda$markErrorInvulnerable$11
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$11 → NO_COVERAGE

230

1.1
Location : lambda$markErrorInvulnerable$11
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$11 → NO_COVERAGE

2.2
Location : lambda$markErrorInvulnerable$11
Killed by : none
replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorInvulnerable$11 → NO_COVERAGE

232

1.1
Location : lambda$markErrorInvulnerable$12
Killed by : none
removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE

2.2
Location : markErrorInvulnerable
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

237

1.1
Location : markError
Killed by : none
removed call to javax/swing/JLabel::setText → NO_COVERAGE

243

1.1
Location : lambda$markError$13
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markError$13 → NO_COVERAGE

2.2
Location : lambda$markError$13
Killed by : none
replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markError$13 → NO_COVERAGE

244

1.1
Location : markError
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

245

1.1
Location : lambda$markError$14
Killed by : none
removed call to javax/swing/JRadioButtonMenuItem::setSelected → NO_COVERAGE

246

1.1
Location : lambda$markError$14
Killed by : none
removed call to javax/swing/JLabel::setText → NO_COVERAGE

252

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

254

1.1
Location : lambda$getMenuError$15
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$getMenuError$15 → NO_COVERAGE

2.2
Location : lambda$getMenuError$15
Killed by : none
replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$getMenuError$15 → NO_COVERAGE

265

1.1
Location : lambda$markErrorVulnerable$16
Killed by : none
replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorVulnerable$16 → NO_COVERAGE

2.2
Location : lambda$markErrorVulnerable$16
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorVulnerable$16 → NO_COVERAGE

267

1.1
Location : lambda$markErrorVulnerable$17
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : lambda$markErrorVulnerable$17
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markErrorVulnerable$17 → NO_COVERAGE

268

1.1
Location : markErrorVulnerable
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

269

1.1
Location : lambda$markErrorVulnerable$18
Killed by : none
removed call to javax/swing/JMenu::setEnabled → NO_COVERAGE

270

1.1
Location : lambda$markErrorVulnerable$18
Killed by : none
removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE

280

1.1
Location : lambda$markStrategyVulnerable$19
Killed by : none
replaced boolean return with false for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategyVulnerable$19 → NO_COVERAGE

2.2
Location : lambda$markStrategyVulnerable$19
Killed by : none
replaced boolean return with true for com/jsql/view/swing/panel/address/PanelTrailingAddress::lambda$markStrategyVulnerable$19 → NO_COVERAGE

281

1.1
Location : markStrategyVulnerable
Killed by : none
removed call to java/util/stream/Stream::forEach → NO_COVERAGE

2.2
Location : lambda$markStrategyVulnerable$20
Killed by : none
removed call to javax/swing/JMenuItem::setEnabled → NO_COVERAGE

288

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

292

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

Active mutators

Tests examined


Report generated by PIT 1.19.1