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

box / box-java-sdk / #6244

10 Feb 2026 05:27PM UTC coverage: 40.749% (+22.6%) from 18.192%
#6244

push

github

web-flow
fix(boxsdkgen): Move assigning default values from builder constructor to `build()` method (box/box-codegen#922) (#1712)

0 of 1677 new or added lines in 569 files covered. (0.0%)

2146 existing lines in 544 files now uncovered.

7382 of 18116 relevant lines covered (40.75%)

0.46 hits per line

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

0.0
/src/main/java/com/box/sdkgen/managers/avatars/AvatarsManager.java
1
package com.box.sdkgen.managers.avatars;
2

3
import static com.box.sdkgen.internal.utils.UtilsManager.convertToString;
4
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
5
import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps;
6
import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams;
7

8
import com.box.sdkgen.networking.auth.Authentication;
9
import com.box.sdkgen.networking.fetchoptions.FetchOptions;
10
import com.box.sdkgen.networking.fetchoptions.MultipartItem;
11
import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
12
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
13
import com.box.sdkgen.networking.network.NetworkSession;
14
import com.box.sdkgen.schemas.useravatar.UserAvatar;
15
import com.box.sdkgen.serialization.json.JsonManager;
16
import java.io.InputStream;
17
import java.util.Arrays;
18
import java.util.Map;
19

20
public class AvatarsManager {
21

22
  public Authentication auth;
23

24
  public NetworkSession networkSession;
25

26
  public AvatarsManager() {
×
27
    this.networkSession = new NetworkSession();
×
28
  }
×
29

30
  protected AvatarsManager(Builder builder) {
×
31
    this.auth = builder.auth;
×
32
    this.networkSession = builder.networkSession;
×
33
  }
×
34

35
  /**
36
   * Retrieves an image of a the user's avatar.
37
   *
38
   * @param userId The ID of the user. Example: "12345"
39
   */
40
  public InputStream getUserAvatar(String userId) {
41
    return getUserAvatar(userId, new GetUserAvatarHeaders());
×
42
  }
43

44
  /**
45
   * Retrieves an image of a the user's avatar.
46
   *
47
   * @param userId The ID of the user. Example: "12345"
48
   * @param headers Headers of getUserAvatar method
49
   */
50
  public InputStream getUserAvatar(String userId, GetUserAvatarHeaders headers) {
51
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
52
    FetchResponse response =
×
53
        this.networkSession
54
            .getNetworkClient()
×
55
            .fetch(
×
56
                new FetchOptions.Builder(
57
                        String.join(
×
58
                            "",
59
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
60
                            "/2.0/users/",
61
                            convertToString(userId),
×
62
                            "/avatar"),
63
                        "GET")
64
                    .headers(headersMap)
×
65
                    .responseFormat(ResponseFormat.BINARY)
×
66
                    .auth(this.auth)
×
67
                    .networkSession(this.networkSession)
×
68
                    .build());
×
69
    return response.getContent();
×
70
  }
71

72
  /**
73
   * Adds or updates a user avatar.
74
   *
75
   * @param userId The ID of the user. Example: "12345"
76
   * @param requestBody Request body of createUserAvatar method
77
   */
78
  public UserAvatar createUserAvatar(String userId, CreateUserAvatarRequestBody requestBody) {
79
    return createUserAvatar(userId, requestBody, new CreateUserAvatarHeaders());
×
80
  }
81

82
  /**
83
   * Adds or updates a user avatar.
84
   *
85
   * @param userId The ID of the user. Example: "12345"
86
   * @param requestBody Request body of createUserAvatar method
87
   * @param headers Headers of createUserAvatar method
88
   */
89
  public UserAvatar createUserAvatar(
90
      String userId, CreateUserAvatarRequestBody requestBody, CreateUserAvatarHeaders headers) {
91
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
92
    FetchResponse response =
×
93
        this.networkSession
94
            .getNetworkClient()
×
95
            .fetch(
×
96
                new FetchOptions.Builder(
97
                        String.join(
×
98
                            "",
99
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
100
                            "/2.0/users/",
101
                            convertToString(userId),
×
102
                            "/avatar"),
103
                        "POST")
104
                    .headers(headersMap)
×
105
                    .multipartData(
×
106
                        Arrays.asList(
×
107
                            new MultipartItem.Builder("pic")
108
                                .fileStream(requestBody.getPic())
×
109
                                .fileName(requestBody.getPicFileName())
×
110
                                .contentType(requestBody.getPicContentType())
×
111
                                .build()))
×
112
                    .contentType("multipart/form-data")
×
113
                    .responseFormat(ResponseFormat.JSON)
×
114
                    .auth(this.auth)
×
115
                    .networkSession(this.networkSession)
×
116
                    .build());
×
117
    return JsonManager.deserialize(response.getData(), UserAvatar.class);
×
118
  }
119

120
  /**
121
   * Removes an existing user avatar. You cannot reverse this operation.
122
   *
123
   * @param userId The ID of the user. Example: "12345"
124
   */
125
  public void deleteUserAvatar(String userId) {
126
    deleteUserAvatar(userId, new DeleteUserAvatarHeaders());
×
127
  }
×
128

129
  /**
130
   * Removes an existing user avatar. You cannot reverse this operation.
131
   *
132
   * @param userId The ID of the user. Example: "12345"
133
   * @param headers Headers of deleteUserAvatar method
134
   */
135
  public void deleteUserAvatar(String userId, DeleteUserAvatarHeaders headers) {
136
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
137
    FetchResponse response =
×
138
        this.networkSession
139
            .getNetworkClient()
×
140
            .fetch(
×
141
                new FetchOptions.Builder(
142
                        String.join(
×
143
                            "",
144
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
145
                            "/2.0/users/",
146
                            convertToString(userId),
×
147
                            "/avatar"),
148
                        "DELETE")
149
                    .headers(headersMap)
×
150
                    .responseFormat(ResponseFormat.NO_CONTENT)
×
151
                    .auth(this.auth)
×
152
                    .networkSession(this.networkSession)
×
153
                    .build());
×
154
  }
×
155

156
  public Authentication getAuth() {
157
    return auth;
×
158
  }
159

160
  public NetworkSession getNetworkSession() {
161
    return networkSession;
×
162
  }
163

164
  public static class Builder {
165

166
    protected Authentication auth;
167

168
    protected NetworkSession networkSession;
169

NEW
170
    public Builder() {}
×
171

172
    public Builder auth(Authentication auth) {
UNCOV
173
      this.auth = auth;
×
UNCOV
174
      return this;
×
175
    }
176

177
    public Builder networkSession(NetworkSession networkSession) {
UNCOV
178
      this.networkSession = networkSession;
×
UNCOV
179
      return this;
×
180
    }
181

182
    public AvatarsManager build() {
NEW
183
      if (this.networkSession == null) {
×
NEW
184
        this.networkSession = new NetworkSession();
×
185
      }
186
      return new AvatarsManager(this);
×
187
    }
188
  }
189
}
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