MessageHeader.java

1
/*******************************************************************************
2
 * Copyhacked (H) 2012-2020.
3
 * This program and the accompanying materials
4
 * are made available under no term at all, use it like
5
 * you want, but share and discuss about it
6
 * every time possible with every body.
7
 * 
8
 * Contributors:
9
 *      ron190 at ymail dot com - initial implementation
10
 ******************************************************************************/
11
package com.jsql.view.swing.interaction;
12
13
import com.jsql.model.bean.util.Header;
14
import com.jsql.model.bean.util.HttpHeader;
15
import com.jsql.model.injection.strategy.blind.AbstractCallableBoolean;
16
import com.jsql.util.LogLevelUtil;
17
import com.jsql.view.interaction.InteractionCommand;
18
import com.jsql.view.swing.scrollpane.JScrollIndicator;
19
import com.jsql.view.swing.util.MediatorHelper;
20
import org.apache.logging.log4j.LogManager;
21
import org.apache.logging.log4j.Logger;
22
23
import javax.swing.*;
24
import javax.swing.table.DefaultTableModel;
25
import java.awt.*;
26
import java.util.Arrays;
27
import java.util.Map;
28
29
public class MessageHeader implements InteractionCommand {
30
    
31
    private static final Logger LOGGER = LogManager.getRootLogger();
32
    
33
    private final String url;
34
    private final String post;
35
    private final Map<String, String> header;
36
    private final Map<String, String> response;
37
    private final String source;
38
    private final String size;
39
    private final String metadataProcess;
40
    private final String metadataStrategy;
41
    private final AbstractCallableBoolean<?> metadataBoolean;
42
43
    @SuppressWarnings("unchecked")
44
    public MessageHeader(Object[] interactionParams) {
45
        
46
        Map<Header, Object> params = (Map<Header, Object>) interactionParams[0];
47
        
48
        this.url = (String) params.get(Header.URL);
49
        this.post = (String) params.get(Header.POST);
50
        this.header = (Map<String, String>) params.get(Header.HEADER);
51
        this.response = (Map<String, String>) params.get(Header.RESPONSE);
52
        this.source = (String) params.get(Header.SOURCE);
53
        this.size = (String) params.get(Header.PAGE_SIZE);
54
        this.metadataProcess = (String) params.get(Header.METADATA_PROCESS);
55
        this.metadataStrategy = (String) params.get(Header.METADATA_STRATEGY);
56
        this.metadataBoolean = (AbstractCallableBoolean<?>) params.get(Header.METADATA_BOOLEAN);
57
    }
58
59
    @Override
60
    public void execute() {
61
        
62 1 1. execute : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::addHeader → NO_COVERAGE
        MediatorHelper.panelConsoles().getNetworkTable().addHeader(new HttpHeader(this.url, this.post, this.header, this.response, this.source));
63
        
64
        JViewport viewport = ((JScrollIndicator) MediatorHelper.panelConsoles().getNetworkSplitPane().getLeftComponent()).getScrollPane().getViewport();
65
        JTable table = (JTable) viewport.getView();
66
        
67
        DefaultTableModel model = (DefaultTableModel) table.getModel();
68
        
69
        try {
70 1 1. execute : removed call to javax/swing/table/DefaultTableModel::addRow → NO_COVERAGE
            model.addRow(new Object[] {
71
                this.url,
72
                this.size,
73
                this.metadataStrategy,
74
                Arrays.asList(this.metadataProcess, this.metadataBoolean)
75
            });
76
            
77 1 1. execute : Replaced integer subtraction with addition → NO_COVERAGE
            Rectangle rect = table.getCellRect(table.getRowCount() - 1, 0, true);
78
            Point pt = viewport.getViewPosition();
79 3 1. execute : removed negation → NO_COVERAGE
2. execute : removed negation → NO_COVERAGE
3. execute : removed call to java/awt/Rectangle::translate → NO_COVERAGE
            rect.translate(-pt.x, -pt.y);
80 1 1. execute : removed call to javax/swing/JViewport::scrollRectToVisible → NO_COVERAGE
            viewport.scrollRectToVisible(rect);
81
            
82 1 1. execute : removed call to com/jsql/view/swing/tab/TabConsoles::highlightTab → NO_COVERAGE
            MediatorHelper.tabConsoles().highlightTab("Network");
83
            
84
        } catch(NullPointerException | IndexOutOfBoundsException e) {
85
            // Fix #4658, #2224, #1797 on model.addRow()
86
            LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
87
        }
88
    }
89
}

Mutations

62

1.1
Location : execute
Killed by : none
removed call to com/jsql/view/swing/panel/consoles/NetworkTable::addHeader → NO_COVERAGE

70

1.1
Location : execute
Killed by : none
removed call to javax/swing/table/DefaultTableModel::addRow → NO_COVERAGE

77

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

79

1.1
Location : execute
Killed by : none
removed negation → NO_COVERAGE

2.2
Location : execute
Killed by : none
removed negation → NO_COVERAGE

3.3
Location : execute
Killed by : none
removed call to java/awt/Rectangle::translate → NO_COVERAGE

80

1.1
Location : execute
Killed by : none
removed call to javax/swing/JViewport::scrollRectToVisible → NO_COVERAGE

82

1.1
Location : execute
Killed by : none
removed call to com/jsql/view/swing/tab/TabConsoles::highlightTab → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1