MessageHeader.java

1
/*******************************************************************************
2
 * Copyhacked (H) 2012-2025.
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 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.callable.AbstractCallableBit;
16
import com.jsql.util.LogLevelUtil;
17
import com.jsql.view.interaction.InteractionCommand;
18
import com.jsql.view.swing.panel.consoles.NetworkTable;
19
import com.jsql.view.swing.util.MediatorHelper;
20
import org.apache.commons.lang3.StringUtils;
21
import org.apache.logging.log4j.LogManager;
22
import org.apache.logging.log4j.Logger;
23
24
import javax.swing.table.DefaultTableModel;
25
import java.awt.*;
26
import java.util.Arrays;
27
import java.util.Collections;
28
import java.util.Map;
29
30
public class MessageHeader implements InteractionCommand {
31
    
32
    private static final Logger LOGGER = LogManager.getRootLogger();
33
    
34
    private final String url;
35
    private final String post;
36
    private final Map<String, String> header;
37
    private final Map<String, String> response;
38
    private final String source;
39
    private final String size;
40
    private final String metadataProcess;
41
    private final String metadataStrategy;
42
    private final AbstractCallableBit<?> metadataBoolean;
43
44
    @SuppressWarnings("unchecked")
45
    public MessageHeader(Object[] interactionParams) {
46
        Map<Header, Object> params = (Map<Header, Object>) interactionParams[0];
47
        this.url = (String) params.getOrDefault(Header.URL, StringUtils.EMPTY);
48
        this.post = (String) params.getOrDefault(Header.POST, StringUtils.EMPTY);
49
        this.header = (Map<String, String>) params.getOrDefault(Header.HEADER, Collections.emptyMap());
50
        this.response = (Map<String, String>) params.getOrDefault(Header.RESPONSE, Collections.emptyMap());
51
        this.source = (String) params.getOrDefault(Header.SOURCE, StringUtils.EMPTY);
52
        this.size = (String) params.getOrDefault(Header.PAGE_SIZE, StringUtils.EMPTY);
53
        this.metadataProcess = (String) params.getOrDefault(Header.METADATA_PROCESS, StringUtils.EMPTY);
54
        this.metadataStrategy = (String) params.getOrDefault(Header.METADATA_STRATEGY, StringUtils.EMPTY);
55
        this.metadataBoolean = (AbstractCallableBit<?>) params.getOrDefault(Header.METADATA_BOOLEAN, null);
56
    }
57
58
    @Override
59
    public void execute() {
60
        NetworkTable table = MediatorHelper.panelConsoles().getNetworkTable();
61 1 1. execute : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::addHeader → NO_COVERAGE
        table.addHeader(new HttpHeader(this.url, this.post, this.header, this.response, this.source));
62
        DefaultTableModel model = (DefaultTableModel) table.getModel();
63
        
64
        try {
65 1 1. execute : removed call to javax/swing/table/DefaultTableModel::addRow → NO_COVERAGE
            model.addRow(new Object[] {
66
                this.url,
67
                this.size,
68
                this.metadataStrategy,
69
                Arrays.asList(this.metadataProcess, this.metadataBoolean)
70
            });
71
            
72 1 1. execute : Replaced integer subtraction with addition → NO_COVERAGE
            Rectangle rect = table.getCellRect(table.getRowCount() - 1, 0, true);
73 1 1. execute : removed call to com/jsql/view/swing/panel/consoles/NetworkTable::scrollRectToVisible → NO_COVERAGE
            table.scrollRectToVisible(rect);
74
            
75 1 1. execute : removed call to com/jsql/view/swing/tab/TabbedPaneWheeled::setBold → NO_COVERAGE
            MediatorHelper.tabConsoles().setBold("Network");
76
        } catch(NullPointerException | IndexOutOfBoundsException e) {
77
            // Fix #4658, #2224, #1797 on model.addRow()
78
            LOGGER.log(LogLevelUtil.CONSOLE_JAVA, e, e);
79
        }
80
    }
81
}

Mutations

61

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

65

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

72

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

73

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

75

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

Active mutators

Tests examined


Report generated by PIT 1.19.1