SuspendableGetVendor.java

1
package com.jsql.model.suspendable;
2
3
import com.jsql.model.InjectionModel;
4
import com.jsql.model.bean.util.Header;
5
import com.jsql.model.bean.util.Interaction;
6
import com.jsql.model.bean.util.Request;
7
import com.jsql.model.exception.JSqlException;
8
import com.jsql.model.exception.JSqlRuntimeException;
9
import com.jsql.model.exception.StoppedByUserSlidingException;
10
import com.jsql.model.injection.strategy.blind.AbstractInjectionBoolean;
11
import com.jsql.model.injection.strategy.blind.InjectionVendor;
12
import com.jsql.util.LogLevelUtil;
13
import org.apache.commons.lang3.StringUtils;
14
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.Logger;
16
17
import java.util.EnumMap;
18
import java.util.Map;
19
import java.util.concurrent.atomic.AtomicBoolean;
20
21
public class SuspendableGetVendor extends AbstractSuspendable {
22
23
    /**
24
     * Log4j logger sent to view.
25
     */
26
    private static final Logger LOGGER = LogManager.getRootLogger();
27
28
    public SuspendableGetVendor(InjectionModel injectionModel) {
29
        super(injectionModel);
30
    }
31
32
    @Override
33
    public String run(Object... args) throws JSqlException {
34
35
        LOGGER.log(LogLevelUtil.CONSOLE_DEFAULT, "Fingerprinting vendor with Boolean match...");
36
37
        AtomicBoolean isVendorFound = new AtomicBoolean(false);
38
        this.injectionModel.getMediatorVendor().getVendors()
39
        .stream()
40 2 1. lambda$run$0 : negated conditional → NO_COVERAGE
2. lambda$run$0 : replaced boolean return with true for com/jsql/model/suspendable/SuspendableGetVendor::lambda$run$0 → NO_COVERAGE
        .filter(vendor -> vendor != this.injectionModel.getMediatorVendor().getAuto())
41 2 1. lambda$run$1 : replaced boolean return with false for com/jsql/model/suspendable/SuspendableGetVendor::lambda$run$1 → NO_COVERAGE
2. lambda$run$1 : replaced boolean return with true for com/jsql/model/suspendable/SuspendableGetVendor::lambda$run$1 → NO_COVERAGE
        .filter(vendor -> StringUtils.isNotEmpty(vendor.instance().getModelYaml()
42
            .getStrategy()
43
            .getConfiguration()
44
            .getFingerprint()
45
            .getVendorSpecific()
46
        ))
47 1 1. run : removed call to java/util/stream/Stream::forEach → NO_COVERAGE
        .forEach(vendor -> {
48
49 1 1. lambda$run$2 : negated conditional → NO_COVERAGE
            if (isVendorFound.get()) {
50
                return;
51
            }
52
            String vendorSpecificWithMode = AbstractInjectionBoolean.BooleanMode.OR.name() + " " + vendor.instance().getModelYaml()
53
                .getStrategy()
54
                .getConfiguration()
55
                .getFingerprint()
56
                .getVendorSpecific();
57
            try {
58
                var injectionCharInsertion = new InjectionVendor(this.injectionModel, vendorSpecificWithMode, vendor);
59 1 1. lambda$run$2 : negated conditional → NO_COVERAGE
                if (injectionCharInsertion.isInjectable(vendorSpecificWithMode)) {
60
61 1 1. lambda$run$2 : negated conditional → NO_COVERAGE
                    if (this.isSuspended()) {
62
                        throw new StoppedByUserSlidingException();
63
                    }
64
65
                    LOGGER.log(LogLevelUtil.CONSOLE_SUCCESS, "Found vendor [{}] using Boolean match", vendor);
66 1 1. lambda$run$2 : removed call to com/jsql/model/injection/vendor/MediatorVendor::setVendor → NO_COVERAGE
                    this.injectionModel.getMediatorVendor().setVendor(vendor);
67 1 1. lambda$run$2 : removed call to java/util/concurrent/atomic/AtomicBoolean::set → NO_COVERAGE
                    isVendorFound.set(true);
68
69
                    var requestSetVendor = new Request();
70 1 1. lambda$run$2 : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE
                    requestSetVendor.setMessage(Interaction.SET_VENDOR);
71
                    Map<Header, Object> msgHeader = new EnumMap<>(Header.class);
72
                    msgHeader.put(Header.URL, this.injectionModel.getMediatorUtils().getConnectionUtil().getUrlByUser());
73
                    msgHeader.put(Header.VENDOR, this.injectionModel.getMediatorVendor().getVendor());
74 1 1. lambda$run$2 : removed call to com/jsql/model/bean/util/Request::setParameters → NO_COVERAGE
                    requestSetVendor.setParameters(msgHeader);
75 1 1. lambda$run$2 : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
                    this.injectionModel.sendToViews(requestSetVendor);
76
                }
77
            } catch (StoppedByUserSlidingException e) {
78
                throw new JSqlRuntimeException(e);
79
            }
80
        });
81 1 1. run : replaced return value with "" for com/jsql/model/suspendable/SuspendableGetVendor::run → NO_COVERAGE
        return null;
82
    }
83
}

Mutations

40

1.1
Location : lambda$run$0
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : lambda$run$0
Killed by : none
replaced boolean return with true for com/jsql/model/suspendable/SuspendableGetVendor::lambda$run$0 → NO_COVERAGE

41

1.1
Location : lambda$run$1
Killed by : none
replaced boolean return with false for com/jsql/model/suspendable/SuspendableGetVendor::lambda$run$1 → NO_COVERAGE

2.2
Location : lambda$run$1
Killed by : none
replaced boolean return with true for com/jsql/model/suspendable/SuspendableGetVendor::lambda$run$1 → NO_COVERAGE

47

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

49

1.1
Location : lambda$run$2
Killed by : none
negated conditional → NO_COVERAGE

59

1.1
Location : lambda$run$2
Killed by : none
negated conditional → NO_COVERAGE

61

1.1
Location : lambda$run$2
Killed by : none
negated conditional → NO_COVERAGE

66

1.1
Location : lambda$run$2
Killed by : none
removed call to com/jsql/model/injection/vendor/MediatorVendor::setVendor → NO_COVERAGE

67

1.1
Location : lambda$run$2
Killed by : none
removed call to java/util/concurrent/atomic/AtomicBoolean::set → NO_COVERAGE

70

1.1
Location : lambda$run$2
Killed by : none
removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE

74

1.1
Location : lambda$run$2
Killed by : none
removed call to com/jsql/model/bean/util/Request::setParameters → NO_COVERAGE

75

1.1
Location : lambda$run$2
Killed by : none
removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE

81

1.1
Location : run
Killed by : none
replaced return value with "" for com/jsql/model/suspendable/SuspendableGetVendor::run → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.16.1