• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #5027

03 Oct 2025 09:45AM UTC coverage: 13.656% (-0.008%) from 13.664%
#5027

Pull #1478

github

web-flow
Merge 7e3e09ba8 into ac7d3d5fe
Pull Request #1478: fix: Make `role` parameter of update collaboration optional (box/box-openapi#557)

0 of 4 new or added lines in 2 files covered. (0.0%)

15 existing lines in 9 files now uncovered.

8368 of 61275 relevant lines covered (13.66%)

0.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/box/sdkgen/box/errors/RequestInfo.java
1
package com.box.sdkgen.box.errors;
2

3
import com.box.sdkgen.internal.logging.DataSanitizer;
4
import java.util.Map;
5
import java.util.stream.Collectors;
6
import okhttp3.Request;
7
import okhttp3.RequestBody;
8
import okio.Buffer;
9

10
public class RequestInfo {
11

12
  public final String method;
13

14
  public final String url;
15

16
  public final Map<String, String> queryParams;
17

18
  public final Map<String, String> headers;
19

20
  public String body;
21

22
  public RequestInfo(
23
      String method, String url, Map<String, String> queryParams, Map<String, String> headers) {
×
24
    this.method = method;
×
25
    this.url = url;
×
26
    this.queryParams = queryParams;
×
27
    this.headers = headers;
×
28
  }
×
29

30
  protected RequestInfo(Builder builder) {
×
31
    this.method = builder.method;
×
32
    this.url = builder.url;
×
33
    this.queryParams = builder.queryParams;
×
34
    this.headers = builder.headers;
×
35
    this.body = builder.body;
×
36
  }
×
37

38
  public String getMethod() {
39
    return method;
×
40
  }
41

42
  public String getUrl() {
43
    return url;
×
44
  }
45

46
  public Map<String, String> getQueryParams() {
47
    return queryParams;
×
48
  }
49

50
  public Map<String, String> getHeaders() {
51
    return headers;
×
52
  }
53

54
  public String getBody() {
55
    return body;
×
56
  }
57

58
  public static class Builder {
59

60
    protected final String method;
61

62
    protected final String url;
63

64
    protected final Map<String, String> queryParams;
65

66
    protected final Map<String, String> headers;
67

68
    protected String body;
69

70
    public Builder(
71
        String method, String url, Map<String, String> queryParams, Map<String, String> headers) {
×
72
      this.method = method;
×
73
      this.url = url;
×
74
      this.queryParams = queryParams;
×
75
      this.headers = headers;
×
76
    }
×
77

78
    public Builder body(String body) {
79
      this.body = body;
×
80
      return this;
×
81
    }
82

83
    public RequestInfo build() {
84
      return new RequestInfo(this);
×
85
    }
86
  }
87

88
  public static RequestInfo fromRequest(Request request) {
89
    Builder requestInfoBuilder =
×
90
        new Builder(
91
                request.method(),
×
92
                request.url().toString(),
×
93
                request.url().queryParameterNames().stream()
×
94
                    .collect(
×
95
                        Collectors.toMap(name -> name, name -> request.url().queryParameter(name))),
×
96
                request.headers().toMultimap().entrySet().stream()
×
97
                    .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().get(0))))
×
98
            .body(getRequestBodyAsString(request.body()));
×
99

100
    return new RequestInfo(requestInfoBuilder);
×
101
  }
102

103
  private static String getRequestBodyAsString(RequestBody requestBody) {
104
    try {
105
      if (requestBody != null) {
×
106
        Buffer buffer = new Buffer();
×
107
        requestBody.writeTo(buffer);
×
108
        return buffer.readUtf8();
×
109
      }
110
    } catch (Exception e) {
×
111
      return null;
×
112
    }
×
113
    return null;
×
114
  }
115

116
  String print(DataSanitizer dataSanitizer) {
UNCOV
117
    Map<String, String> sanitizedHeaders =
×
118
        dataSanitizer == null ? headers : dataSanitizer.sanitizeHeaders(headers);
×
119
    return "RequestInfo{"
×
120
        + "\n\tmethod='"
121
        + method
122
        + '\''
123
        + ", \n\turl='"
124
        + url
125
        + '\''
126
        + ", \n\tqueryParams="
127
        + queryParams
128
        + ", \n\theaders="
129
        + sanitizedHeaders
130
        + ", \n\tbody='"
131
        + body
132
        + '\''
133
        + '}';
134
  }
135
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc