ActionStart.java

1
package com.jsql.view.swing.panel.address;
2
3
import com.jsql.util.I18nUtil;
4
import com.jsql.util.LogLevelUtil;
5
import com.jsql.view.swing.manager.util.StateButton;
6
import com.jsql.view.swing.panel.PanelAddressBar;
7
import com.jsql.view.swing.util.MediatorHelper;
8
import org.apache.commons.lang3.StringUtils;
9
import org.apache.logging.log4j.LogManager;
10
import org.apache.logging.log4j.Logger;
11
12
import javax.swing.*;
13
import java.awt.event.ActionEvent;
14
import java.awt.event.ActionListener;
15
16
public class ActionStart implements ActionListener {
17
    
18
    private static final Logger LOGGER = LogManager.getRootLogger();
19
    
20
    protected final PanelAddressBar panelAddressBar;
21
    
22
    public ActionStart(PanelAddressBar panelAddressBar) {
23
        this.panelAddressBar = panelAddressBar;
24
    }
25
26
    @Override
27
    public void actionPerformed(ActionEvent e) {
28
        // No injection running
29 1 1. actionPerformed : negated conditional → NO_COVERAGE
        if (this.panelAddressBar.getPanelTrailingAddress().getButtonStart().getState() == StateButton.STARTABLE) {
30 1 1. actionPerformed : removed call to com/jsql/view/swing/panel/address/ActionStart::startInjection → NO_COVERAGE
            this.startInjection();
31 1 1. actionPerformed : negated conditional → NO_COVERAGE
        } else if (this.panelAddressBar.getPanelTrailingAddress().getButtonStart().getState() == StateButton.STOPPABLE) {
32 1 1. actionPerformed : removed call to com/jsql/view/swing/panel/address/ActionStart::stopInjection → NO_COVERAGE
            this.stopInjection();  // Injection currently running, stop the process
33
        }
34
    }
35
    
36
    protected void startInjection() {
37 1 1. startInjection : negated conditional → NO_COVERAGE
        if (MediatorHelper.model().isScanning()) {
38
            LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Scan already ongoing, either wait or cancel the scan manually");
39
            return;
40
        }
41
        int option = JOptionPane.OK_OPTION;
42 1 1. startInjection : negated conditional → NO_COVERAGE
        if (MediatorHelper.model().shouldErasePreviousInjection()) {  // Ask the user confirmation if injection already built
43
            // Fix #93469: IllegalArgumentException on showConfirmDialog()
44
            // Fix #33930: ClassCastException on showConfirmDialog()
45
            // Implementation by sun.awt.image
46
            try {
47
                option = JOptionPane.showConfirmDialog(
48
                    MediatorHelper.frame(),
49
                    I18nUtil.valueByKey("DIALOG_NEW_INJECTION_TEXT"),
50
                    I18nUtil.valueByKey("DIALOG_NEW_INJECTION_TITLE"),
51
                    JOptionPane.OK_CANCEL_OPTION
52
                );
53
            } catch (IllegalArgumentException | ClassCastException e) {
54
                LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
55
            }
56
        }
57
58 1 1. startInjection : negated conditional → NO_COVERAGE
        if (option == JOptionPane.OK_OPTION) {  // Then start injection
59 1 1. startInjection : removed call to com/jsql/view/swing/panel/address/ButtonStart::setToolTipText → NO_COVERAGE
            this.panelAddressBar.getPanelTrailingAddress().getButtonStart().setToolTipText(I18nUtil.valueByKey("BUTTON_STOP_TOOLTIP"));
60 1 1. startInjection : removed call to com/jsql/view/swing/panel/address/ButtonStart::setInjectionRunning → NO_COVERAGE
            this.panelAddressBar.getPanelTrailingAddress().getButtonStart().setInjectionRunning();
61 1 1. startInjection : removed call to javax/swing/JComponent::setVisible → NO_COVERAGE
            this.panelAddressBar.getPanelTrailingAddress().getLoader().setVisible(true);
62
63 1 1. startInjection : removed call to com/jsql/view/swing/JFrameView::resetInterface → NO_COVERAGE
            MediatorHelper.frame().resetInterface();  // Erase everything in the view from a previous injection
64
            var selection = this.panelAddressBar.getPanelTrailingAddress().getGroupRadio().getSelection();
65
            String selectionCommand;
66 1 1. startInjection : negated conditional → NO_COVERAGE
            if (selection != null) {  // effectively final
67
                selectionCommand = selection.getActionCommand();
68
            } else {
69
                selectionCommand = StringUtils.EMPTY;
70
            }
71 1 1. startInjection : removed call to com/jsql/util/ParameterUtil::controlInput → NO_COVERAGE
            MediatorHelper.model().getMediatorUtils().parameterUtil().controlInput(
72
                selectionCommand,
73
                this.panelAddressBar.getTextFieldAddress().getText().trim(),
74
                this.panelAddressBar.getTextFieldRequest().getText().trim(),
75
                this.panelAddressBar.getTextFieldHeader().getText().trim(),
76
                this.panelAddressBar.getMethodInjection(),
77
                this.panelAddressBar.getTypeRequest(),
78
                false
79
            );
80
        }
81
    }
82
    
83
    private void stopInjection() {
84 1 1. stopInjection : removed call to javax/swing/JComponent::setVisible → NO_COVERAGE
        this.panelAddressBar.getPanelTrailingAddress().getLoader().setVisible(false);
85 1 1. stopInjection : removed call to com/jsql/view/swing/panel/address/ButtonStart::setInjectionStopping → NO_COVERAGE
        this.panelAddressBar.getPanelTrailingAddress().getButtonStart().setInjectionStopping();
86 1 1. stopInjection : removed call to com/jsql/model/InjectionModel::setIsStoppedByUser → NO_COVERAGE
        MediatorHelper.model().setIsStoppedByUser(true);
87
    }
88
}

Mutations

29

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

30

1.1
Location : actionPerformed
Killed by : none
removed call to com/jsql/view/swing/panel/address/ActionStart::startInjection → NO_COVERAGE

31

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

32

1.1
Location : actionPerformed
Killed by : none
removed call to com/jsql/view/swing/panel/address/ActionStart::stopInjection → NO_COVERAGE

37

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

42

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

58

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

59

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

60

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

61

1.1
Location : startInjection
Killed by : none
removed call to javax/swing/JComponent::setVisible → NO_COVERAGE

63

1.1
Location : startInjection
Killed by : none
removed call to com/jsql/view/swing/JFrameView::resetInterface → NO_COVERAGE

66

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

71

1.1
Location : startInjection
Killed by : none
removed call to com/jsql/util/ParameterUtil::controlInput → NO_COVERAGE

84

1.1
Location : stopInjection
Killed by : none
removed call to javax/swing/JComponent::setVisible → NO_COVERAGE

85

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

86

1.1
Location : stopInjection
Killed by : none
removed call to com/jsql/model/InjectionModel::setIsStoppedByUser → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.25.5 support