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

box / box-java-sdk-gen / #47

03 Apr 2025 02:42PM UTC coverage: 35.192%. First build
#47

Pull #264

github

web-flow
Merge ecd2f972a into 27c23da94
Pull Request #264: SDK-4659: Fix handling responses with invalid json in Java (box/box-codegen#693)

39 of 44 new or added lines in 4 files covered. (88.64%)

15240 of 43305 relevant lines covered (35.19%)

0.35 hits per line

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

81.01
/src/main/java/com/box/sdkgen/networking/network/NetworkSession.java
1
package com.box.sdkgen.networking.network;
2

3
import com.box.sdkgen.networking.baseurls.BaseUrls;
4
import com.box.sdkgen.networking.boxnetworkclient.BoxNetworkClient;
5
import com.box.sdkgen.networking.interceptors.Interceptor;
6
import com.box.sdkgen.networking.networkclient.NetworkClient;
7
import com.box.sdkgen.networking.retries.BoxRetryStrategy;
8
import com.box.sdkgen.networking.retries.RetryStrategy;
9
import java.util.ArrayList;
10
import java.util.HashMap;
11
import java.util.List;
12
import java.util.Map;
13
import java.util.stream.Collectors;
14
import java.util.stream.Stream;
15

16
public class NetworkSession {
17
  protected Map<String, String> additionalHeaders = new HashMap<>();
1✔
18

19
  protected BaseUrls baseUrls = new BaseUrls();
1✔
20

21
  protected List<Interceptor> interceptors = new ArrayList<>();
1✔
22

23
  protected NetworkClient networkClient;
24

25
  protected RetryStrategy retryStrategy;
26

27
  public NetworkSession() {
1✔
28
    networkClient = new BoxNetworkClient();
1✔
29
    retryStrategy = new BoxRetryStrategy();
1✔
30
  }
1✔
31

32
  protected NetworkSession(NetworkSessionBuilder builder) {
1✔
33
    this.additionalHeaders = builder.additionalHeaders;
1✔
34
    this.baseUrls = builder.baseUrls;
1✔
35
    this.networkClient = builder.networkClient;
1✔
36
    this.interceptors = builder.interceptors;
1✔
37
    this.retryStrategy = builder.retryStrategy;
1✔
38
  }
1✔
39

40
  public NetworkSession withAdditionalHeaders() {
41
    return withAdditionalHeaders(new HashMap<>());
×
42
  }
43

44
  public NetworkSession withAdditionalHeaders(Map<String, String> additionalHeaders) {
45
    Map<String, String> newHeaders = new HashMap<>();
1✔
46
    newHeaders.putAll(this.additionalHeaders);
1✔
47
    newHeaders.putAll(additionalHeaders);
1✔
48
    return new NetworkSessionBuilder()
1✔
49
        .baseUrls(this.baseUrls)
1✔
50
        .interceptors(this.interceptors)
1✔
51
        .retryStrategy(this.retryStrategy)
1✔
52
        .networkClient(this.networkClient)
1✔
53
        .additionalHeaders(newHeaders)
1✔
54
        .build();
1✔
55
  }
56

57
  public NetworkSession withCustomBaseUrls(BaseUrls baseUrls) {
58
    return new NetworkSessionBuilder()
1✔
59
        .baseUrls(baseUrls)
1✔
60
        .interceptors(this.interceptors)
1✔
61
        .retryStrategy(this.retryStrategy)
1✔
62
        .networkClient(this.networkClient)
1✔
63
        .additionalHeaders(this.additionalHeaders)
1✔
64
        .build();
1✔
65
  }
66

67
  public NetworkSession withInterceptors(List<Interceptor> interceptors) {
68
    List<Interceptor> newInterceptors =
1✔
69
        Stream.concat(this.interceptors.stream(), interceptors.stream())
1✔
70
            .collect(Collectors.toList());
1✔
71
    return new NetworkSessionBuilder()
1✔
72
        .baseUrls(this.baseUrls)
1✔
73
        .interceptors(interceptors)
1✔
74
        .retryStrategy(this.retryStrategy)
1✔
75
        .networkClient(this.networkClient)
1✔
76
        .additionalHeaders(this.additionalHeaders)
1✔
77
        .build();
1✔
78
  }
79

80
  public NetworkSession withNetworkClient(NetworkClient networkClient) {
81
    return new NetworkSessionBuilder()
×
82
        .baseUrls(this.baseUrls)
×
83
        .interceptors(this.interceptors)
×
84
        .retryStrategy(this.retryStrategy)
×
85
        .networkClient(networkClient)
×
NEW
86
        .additionalHeaders(this.additionalHeaders)
×
87
        .build();
×
88
  }
89

90
  public NetworkSession withRetryStrategy(RetryStrategy retryStrategy) {
91
    return new NetworkSessionBuilder()
×
92
        .baseUrls(this.baseUrls)
×
93
        .interceptors(this.interceptors)
×
94
        .retryStrategy(retryStrategy)
×
NEW
95
        .networkClient(this.networkClient)
×
NEW
96
        .additionalHeaders(this.additionalHeaders)
×
97
        .build();
×
98
  }
99

100
  public Map<String, String> getAdditionalHeaders() {
101
    return additionalHeaders;
1✔
102
  }
103

104
  public BaseUrls getBaseUrls() {
105
    return baseUrls;
1✔
106
  }
107

108
  public NetworkClient getNetworkClient() {
109
    return networkClient;
1✔
110
  }
111

112
  public List<Interceptor> getInterceptors() {
113
    return interceptors;
1✔
114
  }
115

116
  public RetryStrategy getRetryStrategy() {
117
    return retryStrategy;
1✔
118
  }
119

120
  public static class NetworkSessionBuilder {
121

122
    protected Map<String, String> additionalHeaders = new HashMap<>();
1✔
123

124
    protected BaseUrls baseUrls = new BaseUrls();
1✔
125

126
    protected NetworkClient networkClient;
127

128
    protected List<Interceptor> interceptors = new ArrayList<>();
1✔
129

130
    protected RetryStrategy retryStrategy;
131

132
    public NetworkSessionBuilder() {
1✔
133
      networkClient = new BoxNetworkClient();
1✔
134
      retryStrategy = new BoxRetryStrategy();
1✔
135
    }
1✔
136

137
    public NetworkSessionBuilder additionalHeaders(Map<String, String> additionalHeaders) {
138
      this.additionalHeaders = additionalHeaders;
1✔
139
      return this;
1✔
140
    }
141

142
    public NetworkSessionBuilder baseUrls(BaseUrls baseUrls) {
143
      this.baseUrls = baseUrls;
1✔
144
      return this;
1✔
145
    }
146

147
    public NetworkSessionBuilder networkClient(NetworkClient networkClient) {
148
      this.networkClient = networkClient;
1✔
149
      return this;
1✔
150
    }
151

152
    public NetworkSessionBuilder interceptors(List<Interceptor> interceptors) {
153
      this.interceptors = interceptors;
1✔
154
      return this;
1✔
155
    }
156

157
    public NetworkSessionBuilder retryStrategy(RetryStrategy retryStrategy) {
158
      this.retryStrategy = retryStrategy;
1✔
159
      return this;
1✔
160
    }
161

162
    public NetworkSession build() {
163
      return new NetworkSession(this);
1✔
164
    }
165
  }
166
}
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

© 2026 Coveralls, Inc