PathDetails.java

1
package com.renomad.minum.web;
2
3
4
import java.util.HashMap;
5
import java.util.Map;
6
import java.util.Objects;
7
8
/**
9
 * Some essential characteristics of the path portion of the start line
10
 */
11
public final class PathDetails {
12
13
    public static final PathDetails empty = new PathDetails("", "", Map.of());
14
15
    private final String isolatedPath;
16
    private final String rawQueryString;
17
    private final Map<String, String> queryString;
18
19
    /**
20
     * Basic constructor
21
     * @param isolatedPath the isolated path is found after removing the query string
22
     * @param rawQueryString the raw query is the string after a question mark (if it exists - it's optional)
23
     *                       if there is no query string, then we leave rawQuery as a null value
24
     * @param queryString the query is a map of the keys -> values found in the query string
25
     */
26
    public PathDetails (
27
            String isolatedPath,
28
            String rawQueryString,
29
            Map<String, String> queryString
30
    ) {
31
        this.isolatedPath = isolatedPath;
32
        this.rawQueryString = rawQueryString;
33 1 1. <init> : negated conditional → KILLED
        this.queryString = new HashMap<>(queryString == null ? Map.of() : queryString);
34
    }
35
36
    /**
37
     * Provides the path by itself, without the query string.  For examples,
38
     * here are some request lines with their isolated paths:
39
     * <pre>
40
     * {@code
41
     * request line                                isolated path
42
     * -------------------                         -------------
43
     * POST / HTTP/1.1                             ""
44
     * GET /background.png HTTP/1.0                "background.png"
45
     * HEAD /test.html?query=alibaba HTTP/1.1      "test.html"
46
     * OPTIONS /anypage.html HTTP/1.0              "anypage.html"
47
     * }
48
     * </pre>
49
     */
50
    public String getIsolatedPath() {
51 1 1. getIsolatedPath : replaced return value with "" for com/renomad/minum/web/PathDetails::getIsolatedPath → KILLED
        return isolatedPath;
52
    }
53
54
    /**
55
     * Returns the raw query string.  For example, in "HEAD /test.html?query=alibaba HTTP/1.1",
56
     * the raw query string is "query=alibaba"
57
     */
58
    public String getRawQueryString() {
59 1 1. getRawQueryString : replaced return value with "" for com/renomad/minum/web/PathDetails::getRawQueryString → KILLED
        return rawQueryString;
60
    }
61
62
    /**
63
     * This returns the query string portion of the request line as a map, with
64
     * case-sensitive keys.
65
     */
66
    public Map<String, String> getQueryString() {
67 1 1. getQueryString : replaced return value with Collections.emptyMap for com/renomad/minum/web/PathDetails::getQueryString → KILLED
        return new HashMap<>(queryString);
68
    }
69
70
    @Override
71
    public boolean equals(Object o) {
72 2 1. equals : negated conditional → KILLED
2. equals : replaced boolean return with false for com/renomad/minum/web/PathDetails::equals → KILLED
        if (this == o) return true;
73 2 1. equals : negated conditional → KILLED
2. equals : replaced boolean return with true for com/renomad/minum/web/PathDetails::equals → KILLED
        if (!(o instanceof PathDetails that)) return false;
74 4 1. equals : negated conditional → KILLED
2. equals : replaced boolean return with true for com/renomad/minum/web/PathDetails::equals → KILLED
3. equals : negated conditional → KILLED
4. equals : negated conditional → KILLED
        return Objects.equals(isolatedPath, that.isolatedPath) && Objects.equals(rawQueryString, that.rawQueryString) && Objects.equals(queryString, that.queryString);
75
    }
76
77
    @Override
78
    public int hashCode() {
79 1 1. hashCode : replaced int return with 0 for com/renomad/minum/web/PathDetails::hashCode → KILLED
        return Objects.hash(isolatedPath, rawQueryString, queryString);
80
    }
81
82
    @Override
83
    public String toString() {
84 1 1. toString : replaced return value with "" for com/renomad/minum/web/PathDetails::toString → KILLED
        return "PathDetails{" +
85
                "isolatedPath='" + isolatedPath + '\'' +
86
                ", rawQueryString='" + rawQueryString + '\'' +
87
                ", queryString=" + queryString +
88
                '}';
89
    }
90
}

Mutations

33

1.1
Location : <init>
Killed by : com.renomad.minum.web.EndpointTests.test_Endpoint_HappyPath(com.renomad.minum.web.EndpointTests)
negated conditional → KILLED

51

1.1
Location : getIsolatedPath
Killed by : com.renomad.minum.web.WebTests
replaced return value with "" for com/renomad/minum/web/PathDetails::getIsolatedPath → KILLED

59

1.1
Location : getRawQueryString
Killed by : com.renomad.minum.web.PathDetailsTests.happyPath(com.renomad.minum.web.PathDetailsTests)
replaced return value with "" for com/renomad/minum/web/PathDetails::getRawQueryString → KILLED

67

1.1
Location : getQueryString
Killed by : com.renomad.minum.web.EndpointTests.test_Endpoint_HappyPath(com.renomad.minum.web.EndpointTests)
replaced return value with Collections.emptyMap for com/renomad/minum/web/PathDetails::getQueryString → KILLED

72

1.1
Location : equals
Killed by : com.renomad.minum.EqualsTests.equalsTest(com.renomad.minum.EqualsTests)
negated conditional → KILLED

2.2
Location : equals
Killed by : com.renomad.minum.EqualsTests.equalsTest(com.renomad.minum.EqualsTests)
replaced boolean return with false for com/renomad/minum/web/PathDetails::equals → KILLED

73

1.1
Location : equals
Killed by : com.renomad.minum.EqualsTests.equalsTest(com.renomad.minum.EqualsTests)
negated conditional → KILLED

2.2
Location : equals
Killed by : com.renomad.minum.EqualsTests.equalsTest(com.renomad.minum.EqualsTests)
replaced boolean return with true for com/renomad/minum/web/PathDetails::equals → KILLED

74

1.1
Location : equals
Killed by : com.renomad.minum.EqualsTests.equalsTest(com.renomad.minum.EqualsTests)
negated conditional → KILLED

2.2
Location : equals
Killed by : com.renomad.minum.EqualsTests.equalsTest(com.renomad.minum.EqualsTests)
replaced boolean return with true for com/renomad/minum/web/PathDetails::equals → KILLED

3.3
Location : equals
Killed by : com.renomad.minum.EqualsTests.equalsTest(com.renomad.minum.EqualsTests)
negated conditional → KILLED

4.4
Location : equals
Killed by : com.renomad.minum.EqualsTests.equalsTest(com.renomad.minum.EqualsTests)
negated conditional → KILLED

79

1.1
Location : hashCode
Killed by : com.renomad.minum.EqualsTests.equalsTest(com.renomad.minum.EqualsTests)
replaced int return with 0 for com/renomad/minum/web/PathDetails::hashCode → KILLED

84

1.1
Location : toString
Killed by : com.renomad.minum.web.RequestTests.test_Request_ToString(com.renomad.minum.web.RequestTests)
replaced return value with "" for com/renomad/minum/web/PathDetails::toString → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0