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

box / box-java-sdk / #6243

10 Feb 2026 05:27PM UTC coverage: 18.192% (-17.5%) from 35.714%
#6243

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%)

2147 existing lines in 545 files now uncovered.

7388 of 40611 relevant lines covered (18.19%)

0.21 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/comments/CommentsManager.java
1
package com.box.sdkgen.managers.comments;
2

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

9
import com.box.sdkgen.networking.auth.Authentication;
10
import com.box.sdkgen.networking.fetchoptions.FetchOptions;
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.commentfull.CommentFull;
15
import com.box.sdkgen.schemas.comments.Comments;
16
import com.box.sdkgen.serialization.json.JsonManager;
17
import java.util.Map;
18

19
public class CommentsManager {
20

21
  public Authentication auth;
22

23
  public NetworkSession networkSession;
24

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

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

34
  /**
35
   * Retrieves a list of comments for a file.
36
   *
37
   * @param fileId The unique identifier that represents a file.
38
   *     <p>The ID for any file can be determined by visiting a file in the web application and
39
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
40
   *     `file_id` is `123`. Example: "12345"
41
   */
42
  public Comments getFileComments(String fileId) {
43
    return getFileComments(fileId, new GetFileCommentsQueryParams(), new GetFileCommentsHeaders());
×
44
  }
45

46
  /**
47
   * Retrieves a list of comments for a file.
48
   *
49
   * @param fileId The unique identifier that represents a file.
50
   *     <p>The ID for any file can be determined by visiting a file in the web application and
51
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
52
   *     `file_id` is `123`. Example: "12345"
53
   * @param queryParams Query parameters of getFileComments method
54
   */
55
  public Comments getFileComments(String fileId, GetFileCommentsQueryParams queryParams) {
56
    return getFileComments(fileId, queryParams, new GetFileCommentsHeaders());
×
57
  }
58

59
  /**
60
   * Retrieves a list of comments for a file.
61
   *
62
   * @param fileId The unique identifier that represents a file.
63
   *     <p>The ID for any file can be determined by visiting a file in the web application and
64
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
65
   *     `file_id` is `123`. Example: "12345"
66
   * @param headers Headers of getFileComments method
67
   */
68
  public Comments getFileComments(String fileId, GetFileCommentsHeaders headers) {
69
    return getFileComments(fileId, new GetFileCommentsQueryParams(), headers);
×
70
  }
71

72
  /**
73
   * Retrieves a list of comments for a file.
74
   *
75
   * @param fileId The unique identifier that represents a file.
76
   *     <p>The ID for any file can be determined by visiting a file in the web application and
77
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
78
   *     `file_id` is `123`. Example: "12345"
79
   * @param queryParams Query parameters of getFileComments method
80
   * @param headers Headers of getFileComments method
81
   */
82
  public Comments getFileComments(
83
      String fileId, GetFileCommentsQueryParams queryParams, GetFileCommentsHeaders headers) {
84
    Map<String, String> queryParamsMap =
×
85
        prepareParams(
×
86
            mapOf(
×
87
                entryOf("fields", convertToString(queryParams.getFields())),
×
88
                entryOf("limit", convertToString(queryParams.getLimit())),
×
89
                entryOf("offset", convertToString(queryParams.getOffset()))));
×
90
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
91
    FetchResponse response =
×
92
        this.networkSession
93
            .getNetworkClient()
×
94
            .fetch(
×
95
                new FetchOptions.Builder(
96
                        String.join(
×
97
                            "",
98
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
99
                            "/2.0/files/",
100
                            convertToString(fileId),
×
101
                            "/comments"),
102
                        "GET")
103
                    .params(queryParamsMap)
×
104
                    .headers(headersMap)
×
105
                    .responseFormat(ResponseFormat.JSON)
×
106
                    .auth(this.auth)
×
107
                    .networkSession(this.networkSession)
×
108
                    .build());
×
109
    return JsonManager.deserialize(response.getData(), Comments.class);
×
110
  }
111

112
  /**
113
   * Retrieves the message and metadata for a specific comment, as well as information on the user
114
   * who created the comment.
115
   *
116
   * @param commentId The ID of the comment. Example: "12345"
117
   */
118
  public CommentFull getCommentById(String commentId) {
119
    return getCommentById(commentId, new GetCommentByIdQueryParams(), new GetCommentByIdHeaders());
×
120
  }
121

122
  /**
123
   * Retrieves the message and metadata for a specific comment, as well as information on the user
124
   * who created the comment.
125
   *
126
   * @param commentId The ID of the comment. Example: "12345"
127
   * @param queryParams Query parameters of getCommentById method
128
   */
129
  public CommentFull getCommentById(String commentId, GetCommentByIdQueryParams queryParams) {
130
    return getCommentById(commentId, queryParams, new GetCommentByIdHeaders());
×
131
  }
132

133
  /**
134
   * Retrieves the message and metadata for a specific comment, as well as information on the user
135
   * who created the comment.
136
   *
137
   * @param commentId The ID of the comment. Example: "12345"
138
   * @param headers Headers of getCommentById method
139
   */
140
  public CommentFull getCommentById(String commentId, GetCommentByIdHeaders headers) {
141
    return getCommentById(commentId, new GetCommentByIdQueryParams(), headers);
×
142
  }
143

144
  /**
145
   * Retrieves the message and metadata for a specific comment, as well as information on the user
146
   * who created the comment.
147
   *
148
   * @param commentId The ID of the comment. Example: "12345"
149
   * @param queryParams Query parameters of getCommentById method
150
   * @param headers Headers of getCommentById method
151
   */
152
  public CommentFull getCommentById(
153
      String commentId, GetCommentByIdQueryParams queryParams, GetCommentByIdHeaders headers) {
154
    Map<String, String> queryParamsMap =
×
155
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
×
156
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
157
    FetchResponse response =
×
158
        this.networkSession
159
            .getNetworkClient()
×
160
            .fetch(
×
161
                new FetchOptions.Builder(
162
                        String.join(
×
163
                            "",
164
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
165
                            "/2.0/comments/",
166
                            convertToString(commentId)),
×
167
                        "GET")
168
                    .params(queryParamsMap)
×
169
                    .headers(headersMap)
×
170
                    .responseFormat(ResponseFormat.JSON)
×
171
                    .auth(this.auth)
×
172
                    .networkSession(this.networkSession)
×
173
                    .build());
×
174
    return JsonManager.deserialize(response.getData(), CommentFull.class);
×
175
  }
176

177
  /**
178
   * Update the message of a comment.
179
   *
180
   * @param commentId The ID of the comment. Example: "12345"
181
   */
182
  public CommentFull updateCommentById(String commentId) {
183
    return updateCommentById(
×
184
        commentId,
185
        new UpdateCommentByIdRequestBody(),
186
        new UpdateCommentByIdQueryParams(),
187
        new UpdateCommentByIdHeaders());
188
  }
189

190
  /**
191
   * Update the message of a comment.
192
   *
193
   * @param commentId The ID of the comment. Example: "12345"
194
   * @param requestBody Request body of updateCommentById method
195
   */
196
  public CommentFull updateCommentById(String commentId, UpdateCommentByIdRequestBody requestBody) {
197
    return updateCommentById(
×
198
        commentId, requestBody, new UpdateCommentByIdQueryParams(), new UpdateCommentByIdHeaders());
199
  }
200

201
  /**
202
   * Update the message of a comment.
203
   *
204
   * @param commentId The ID of the comment. Example: "12345"
205
   * @param queryParams Query parameters of updateCommentById method
206
   */
207
  public CommentFull updateCommentById(String commentId, UpdateCommentByIdQueryParams queryParams) {
208
    return updateCommentById(
×
209
        commentId, new UpdateCommentByIdRequestBody(), queryParams, new UpdateCommentByIdHeaders());
210
  }
211

212
  /**
213
   * Update the message of a comment.
214
   *
215
   * @param commentId The ID of the comment. Example: "12345"
216
   * @param requestBody Request body of updateCommentById method
217
   * @param queryParams Query parameters of updateCommentById method
218
   */
219
  public CommentFull updateCommentById(
220
      String commentId,
221
      UpdateCommentByIdRequestBody requestBody,
222
      UpdateCommentByIdQueryParams queryParams) {
223
    return updateCommentById(commentId, requestBody, queryParams, new UpdateCommentByIdHeaders());
×
224
  }
225

226
  /**
227
   * Update the message of a comment.
228
   *
229
   * @param commentId The ID of the comment. Example: "12345"
230
   * @param headers Headers of updateCommentById method
231
   */
232
  public CommentFull updateCommentById(String commentId, UpdateCommentByIdHeaders headers) {
233
    return updateCommentById(
×
234
        commentId, new UpdateCommentByIdRequestBody(), new UpdateCommentByIdQueryParams(), headers);
235
  }
236

237
  /**
238
   * Update the message of a comment.
239
   *
240
   * @param commentId The ID of the comment. Example: "12345"
241
   * @param requestBody Request body of updateCommentById method
242
   * @param headers Headers of updateCommentById method
243
   */
244
  public CommentFull updateCommentById(
245
      String commentId,
246
      UpdateCommentByIdRequestBody requestBody,
247
      UpdateCommentByIdHeaders headers) {
248
    return updateCommentById(commentId, requestBody, new UpdateCommentByIdQueryParams(), headers);
×
249
  }
250

251
  /**
252
   * Update the message of a comment.
253
   *
254
   * @param commentId The ID of the comment. Example: "12345"
255
   * @param queryParams Query parameters of updateCommentById method
256
   * @param headers Headers of updateCommentById method
257
   */
258
  public CommentFull updateCommentById(
259
      String commentId,
260
      UpdateCommentByIdQueryParams queryParams,
261
      UpdateCommentByIdHeaders headers) {
262
    return updateCommentById(commentId, new UpdateCommentByIdRequestBody(), queryParams, headers);
×
263
  }
264

265
  /**
266
   * Update the message of a comment.
267
   *
268
   * @param commentId The ID of the comment. Example: "12345"
269
   * @param requestBody Request body of updateCommentById method
270
   * @param queryParams Query parameters of updateCommentById method
271
   * @param headers Headers of updateCommentById method
272
   */
273
  public CommentFull updateCommentById(
274
      String commentId,
275
      UpdateCommentByIdRequestBody requestBody,
276
      UpdateCommentByIdQueryParams queryParams,
277
      UpdateCommentByIdHeaders headers) {
278
    Map<String, String> queryParamsMap =
×
279
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
×
280
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
281
    FetchResponse response =
×
282
        this.networkSession
283
            .getNetworkClient()
×
284
            .fetch(
×
285
                new FetchOptions.Builder(
286
                        String.join(
×
287
                            "",
288
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
289
                            "/2.0/comments/",
290
                            convertToString(commentId)),
×
291
                        "PUT")
292
                    .params(queryParamsMap)
×
293
                    .headers(headersMap)
×
294
                    .data(JsonManager.serialize(requestBody))
×
295
                    .contentType("application/json")
×
296
                    .responseFormat(ResponseFormat.JSON)
×
297
                    .auth(this.auth)
×
298
                    .networkSession(this.networkSession)
×
299
                    .build());
×
300
    return JsonManager.deserialize(response.getData(), CommentFull.class);
×
301
  }
302

303
  /**
304
   * Permanently deletes a comment.
305
   *
306
   * @param commentId The ID of the comment. Example: "12345"
307
   */
308
  public void deleteCommentById(String commentId) {
309
    deleteCommentById(commentId, new DeleteCommentByIdHeaders());
×
310
  }
×
311

312
  /**
313
   * Permanently deletes a comment.
314
   *
315
   * @param commentId The ID of the comment. Example: "12345"
316
   * @param headers Headers of deleteCommentById method
317
   */
318
  public void deleteCommentById(String commentId, DeleteCommentByIdHeaders headers) {
319
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
320
    FetchResponse response =
×
321
        this.networkSession
322
            .getNetworkClient()
×
323
            .fetch(
×
324
                new FetchOptions.Builder(
325
                        String.join(
×
326
                            "",
327
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
328
                            "/2.0/comments/",
329
                            convertToString(commentId)),
×
330
                        "DELETE")
331
                    .headers(headersMap)
×
332
                    .responseFormat(ResponseFormat.NO_CONTENT)
×
333
                    .auth(this.auth)
×
334
                    .networkSession(this.networkSession)
×
335
                    .build());
×
336
  }
×
337

338
  /**
339
   * Adds a comment by the user to a specific file, or as a reply to an other comment.
340
   *
341
   * @param requestBody Request body of createComment method
342
   */
343
  public CommentFull createComment(CreateCommentRequestBody requestBody) {
344
    return createComment(requestBody, new CreateCommentQueryParams(), new CreateCommentHeaders());
×
345
  }
346

347
  /**
348
   * Adds a comment by the user to a specific file, or as a reply to an other comment.
349
   *
350
   * @param requestBody Request body of createComment method
351
   * @param queryParams Query parameters of createComment method
352
   */
353
  public CommentFull createComment(
354
      CreateCommentRequestBody requestBody, CreateCommentQueryParams queryParams) {
355
    return createComment(requestBody, queryParams, new CreateCommentHeaders());
×
356
  }
357

358
  /**
359
   * Adds a comment by the user to a specific file, or as a reply to an other comment.
360
   *
361
   * @param requestBody Request body of createComment method
362
   * @param headers Headers of createComment method
363
   */
364
  public CommentFull createComment(
365
      CreateCommentRequestBody requestBody, CreateCommentHeaders headers) {
366
    return createComment(requestBody, new CreateCommentQueryParams(), headers);
×
367
  }
368

369
  /**
370
   * Adds a comment by the user to a specific file, or as a reply to an other comment.
371
   *
372
   * @param requestBody Request body of createComment method
373
   * @param queryParams Query parameters of createComment method
374
   * @param headers Headers of createComment method
375
   */
376
  public CommentFull createComment(
377
      CreateCommentRequestBody requestBody,
378
      CreateCommentQueryParams queryParams,
379
      CreateCommentHeaders headers) {
380
    Map<String, String> queryParamsMap =
×
381
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
×
382
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
383
    FetchResponse response =
×
384
        this.networkSession
385
            .getNetworkClient()
×
386
            .fetch(
×
387
                new FetchOptions.Builder(
388
                        String.join(
×
389
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/comments"),
×
390
                        "POST")
391
                    .params(queryParamsMap)
×
392
                    .headers(headersMap)
×
393
                    .data(JsonManager.serialize(requestBody))
×
394
                    .contentType("application/json")
×
395
                    .responseFormat(ResponseFormat.JSON)
×
396
                    .auth(this.auth)
×
397
                    .networkSession(this.networkSession)
×
398
                    .build());
×
399
    return JsonManager.deserialize(response.getData(), CommentFull.class);
×
400
  }
401

402
  public Authentication getAuth() {
403
    return auth;
×
404
  }
405

406
  public NetworkSession getNetworkSession() {
407
    return networkSession;
×
408
  }
409

410
  public static class Builder {
411

412
    protected Authentication auth;
413

414
    protected NetworkSession networkSession;
415

NEW
416
    public Builder() {}
×
417

418
    public Builder auth(Authentication auth) {
UNCOV
419
      this.auth = auth;
×
UNCOV
420
      return this;
×
421
    }
422

423
    public Builder networkSession(NetworkSession networkSession) {
UNCOV
424
      this.networkSession = networkSession;
×
UNCOV
425
      return this;
×
426
    }
427

428
    public CommentsManager build() {
NEW
429
      if (this.networkSession == null) {
×
NEW
430
        this.networkSession = new NetworkSession();
×
431
      }
432
      return new CommentsManager(this);
×
433
    }
434
  }
435
}
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