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

box / box-java-sdk / #5076

07 Oct 2025 12:35PM UTC coverage: 37.132% (+0.007%) from 37.125%
#5076

push

github

web-flow
test: Change `Event.additionalDetails` field assertion in events test (box/box-codegen#858) (#1491)

18454 of 49699 relevant lines covered (37.13%)

0.37 hits per line

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

89.62
/src/main/java/com/box/sdkgen/managers/listcollaborations/ListCollaborationsManager.java
1
package com.box.sdkgen.managers.listcollaborations;
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.collaborations.Collaborations;
15
import com.box.sdkgen.schemas.collaborationsoffsetpaginated.CollaborationsOffsetPaginated;
16
import com.box.sdkgen.serialization.json.JsonManager;
17
import java.util.Map;
18

19
public class ListCollaborationsManager {
20

21
  public Authentication auth;
22

23
  public NetworkSession networkSession;
24

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

29
  protected ListCollaborationsManager(Builder builder) {
1✔
30
    this.auth = builder.auth;
1✔
31
    this.networkSession = builder.networkSession;
1✔
32
  }
1✔
33

34
  /**
35
   * Retrieves a list of pending and active collaborations for a file. This returns all the users
36
   * that have access to the file or have been invited to the file.
37
   *
38
   * @param fileId The unique identifier that represents a file.
39
   *     <p>The ID for any file can be determined by visiting a file in the web application and
40
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
41
   *     `file_id` is `123`. Example: "12345"
42
   */
43
  public Collaborations getFileCollaborations(String fileId) {
44
    return getFileCollaborations(
1✔
45
        fileId, new GetFileCollaborationsQueryParams(), new GetFileCollaborationsHeaders());
46
  }
47

48
  /**
49
   * Retrieves a list of pending and active collaborations for a file. This returns all the users
50
   * that have access to the file or have been invited to the file.
51
   *
52
   * @param fileId The unique identifier that represents a file.
53
   *     <p>The ID for any file can be determined by visiting a file in the web application and
54
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
55
   *     `file_id` is `123`. Example: "12345"
56
   * @param queryParams Query parameters of getFileCollaborations method
57
   */
58
  public Collaborations getFileCollaborations(
59
      String fileId, GetFileCollaborationsQueryParams queryParams) {
60
    return getFileCollaborations(fileId, queryParams, new GetFileCollaborationsHeaders());
×
61
  }
62

63
  /**
64
   * Retrieves a list of pending and active collaborations for a file. This returns all the users
65
   * that have access to the file or have been invited to the file.
66
   *
67
   * @param fileId The unique identifier that represents a file.
68
   *     <p>The ID for any file can be determined by visiting a file in the web application and
69
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
70
   *     `file_id` is `123`. Example: "12345"
71
   * @param headers Headers of getFileCollaborations method
72
   */
73
  public Collaborations getFileCollaborations(String fileId, GetFileCollaborationsHeaders headers) {
74
    return getFileCollaborations(fileId, new GetFileCollaborationsQueryParams(), headers);
×
75
  }
76

77
  /**
78
   * Retrieves a list of pending and active collaborations for a file. This returns all the users
79
   * that have access to the file or have been invited to the file.
80
   *
81
   * @param fileId The unique identifier that represents a file.
82
   *     <p>The ID for any file can be determined by visiting a file in the web application and
83
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
84
   *     `file_id` is `123`. Example: "12345"
85
   * @param queryParams Query parameters of getFileCollaborations method
86
   * @param headers Headers of getFileCollaborations method
87
   */
88
  public Collaborations getFileCollaborations(
89
      String fileId,
90
      GetFileCollaborationsQueryParams queryParams,
91
      GetFileCollaborationsHeaders headers) {
92
    Map<String, String> queryParamsMap =
1✔
93
        prepareParams(
1✔
94
            mapOf(
1✔
95
                entryOf("fields", convertToString(queryParams.getFields())),
1✔
96
                entryOf("limit", convertToString(queryParams.getLimit())),
1✔
97
                entryOf("marker", convertToString(queryParams.getMarker()))));
1✔
98
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
99
    FetchResponse response =
1✔
100
        this.networkSession
101
            .getNetworkClient()
1✔
102
            .fetch(
1✔
103
                new FetchOptions.Builder(
104
                        String.join(
1✔
105
                            "",
106
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
107
                            "/2.0/files/",
108
                            convertToString(fileId),
1✔
109
                            "/collaborations"),
110
                        "GET")
111
                    .params(queryParamsMap)
1✔
112
                    .headers(headersMap)
1✔
113
                    .responseFormat(ResponseFormat.JSON)
1✔
114
                    .auth(this.auth)
1✔
115
                    .networkSession(this.networkSession)
1✔
116
                    .build());
1✔
117
    return JsonManager.deserialize(response.getData(), Collaborations.class);
1✔
118
  }
119

120
  /**
121
   * Retrieves a list of pending and active collaborations for a folder. This returns all the users
122
   * that have access to the folder or have been invited to the folder.
123
   *
124
   * @param folderId The unique identifier that represent a folder.
125
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
126
   *     and copying the ID from the URL. For example, for the URL
127
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`. Example: "12345"
128
   */
129
  public Collaborations getFolderCollaborations(String folderId) {
130
    return getFolderCollaborations(
1✔
131
        folderId, new GetFolderCollaborationsQueryParams(), new GetFolderCollaborationsHeaders());
132
  }
133

134
  /**
135
   * Retrieves a list of pending and active collaborations for a folder. This returns all the users
136
   * that have access to the folder or have been invited to the folder.
137
   *
138
   * @param folderId The unique identifier that represent a folder.
139
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
140
   *     and copying the ID from the URL. For example, for the URL
141
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`. Example: "12345"
142
   * @param queryParams Query parameters of getFolderCollaborations method
143
   */
144
  public Collaborations getFolderCollaborations(
145
      String folderId, GetFolderCollaborationsQueryParams queryParams) {
146
    return getFolderCollaborations(folderId, queryParams, new GetFolderCollaborationsHeaders());
×
147
  }
148

149
  /**
150
   * Retrieves a list of pending and active collaborations for a folder. This returns all the users
151
   * that have access to the folder or have been invited to the folder.
152
   *
153
   * @param folderId The unique identifier that represent a folder.
154
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
155
   *     and copying the ID from the URL. For example, for the URL
156
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`. Example: "12345"
157
   * @param headers Headers of getFolderCollaborations method
158
   */
159
  public Collaborations getFolderCollaborations(
160
      String folderId, GetFolderCollaborationsHeaders headers) {
161
    return getFolderCollaborations(folderId, new GetFolderCollaborationsQueryParams(), headers);
×
162
  }
163

164
  /**
165
   * Retrieves a list of pending and active collaborations for a folder. This returns all the users
166
   * that have access to the folder or have been invited to the folder.
167
   *
168
   * @param folderId The unique identifier that represent a folder.
169
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
170
   *     and copying the ID from the URL. For example, for the URL
171
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`. Example: "12345"
172
   * @param queryParams Query parameters of getFolderCollaborations method
173
   * @param headers Headers of getFolderCollaborations method
174
   */
175
  public Collaborations getFolderCollaborations(
176
      String folderId,
177
      GetFolderCollaborationsQueryParams queryParams,
178
      GetFolderCollaborationsHeaders headers) {
179
    Map<String, String> queryParamsMap =
1✔
180
        prepareParams(
1✔
181
            mapOf(
1✔
182
                entryOf("fields", convertToString(queryParams.getFields())),
1✔
183
                entryOf("limit", convertToString(queryParams.getLimit())),
1✔
184
                entryOf("marker", convertToString(queryParams.getMarker()))));
1✔
185
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
186
    FetchResponse response =
1✔
187
        this.networkSession
188
            .getNetworkClient()
1✔
189
            .fetch(
1✔
190
                new FetchOptions.Builder(
191
                        String.join(
1✔
192
                            "",
193
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
194
                            "/2.0/folders/",
195
                            convertToString(folderId),
1✔
196
                            "/collaborations"),
197
                        "GET")
198
                    .params(queryParamsMap)
1✔
199
                    .headers(headersMap)
1✔
200
                    .responseFormat(ResponseFormat.JSON)
1✔
201
                    .auth(this.auth)
1✔
202
                    .networkSession(this.networkSession)
1✔
203
                    .build());
1✔
204
    return JsonManager.deserialize(response.getData(), Collaborations.class);
1✔
205
  }
206

207
  /**
208
   * Retrieves all pending collaboration invites for this user.
209
   *
210
   * @param queryParams Query parameters of getCollaborations method
211
   */
212
  public CollaborationsOffsetPaginated getCollaborations(GetCollaborationsQueryParams queryParams) {
213
    return getCollaborations(queryParams, new GetCollaborationsHeaders());
1✔
214
  }
215

216
  /**
217
   * Retrieves all pending collaboration invites for this user.
218
   *
219
   * @param queryParams Query parameters of getCollaborations method
220
   * @param headers Headers of getCollaborations method
221
   */
222
  public CollaborationsOffsetPaginated getCollaborations(
223
      GetCollaborationsQueryParams queryParams, GetCollaborationsHeaders headers) {
224
    Map<String, String> queryParamsMap =
1✔
225
        prepareParams(
1✔
226
            mapOf(
1✔
227
                entryOf("status", convertToString(queryParams.getStatus())),
1✔
228
                entryOf("fields", convertToString(queryParams.getFields())),
1✔
229
                entryOf("offset", convertToString(queryParams.getOffset())),
1✔
230
                entryOf("limit", convertToString(queryParams.getLimit()))));
1✔
231
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
232
    FetchResponse response =
1✔
233
        this.networkSession
234
            .getNetworkClient()
1✔
235
            .fetch(
1✔
236
                new FetchOptions.Builder(
237
                        String.join(
1✔
238
                            "",
239
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
240
                            "/2.0/collaborations"),
241
                        "GET")
242
                    .params(queryParamsMap)
1✔
243
                    .headers(headersMap)
1✔
244
                    .responseFormat(ResponseFormat.JSON)
1✔
245
                    .auth(this.auth)
1✔
246
                    .networkSession(this.networkSession)
1✔
247
                    .build());
1✔
248
    return JsonManager.deserialize(response.getData(), CollaborationsOffsetPaginated.class);
1✔
249
  }
250

251
  /**
252
   * Retrieves all the collaborations for a group. The user must have admin permissions to inspect
253
   * enterprise's groups.
254
   *
255
   * <p>Each collaboration object has details on which files or folders the group has access to and
256
   * with what role.
257
   *
258
   * @param groupId The ID of the group. Example: "57645"
259
   */
260
  public CollaborationsOffsetPaginated getGroupCollaborations(String groupId) {
261
    return getGroupCollaborations(
1✔
262
        groupId, new GetGroupCollaborationsQueryParams(), new GetGroupCollaborationsHeaders());
263
  }
264

265
  /**
266
   * Retrieves all the collaborations for a group. The user must have admin permissions to inspect
267
   * enterprise's groups.
268
   *
269
   * <p>Each collaboration object has details on which files or folders the group has access to and
270
   * with what role.
271
   *
272
   * @param groupId The ID of the group. Example: "57645"
273
   * @param queryParams Query parameters of getGroupCollaborations method
274
   */
275
  public CollaborationsOffsetPaginated getGroupCollaborations(
276
      String groupId, GetGroupCollaborationsQueryParams queryParams) {
277
    return getGroupCollaborations(groupId, queryParams, new GetGroupCollaborationsHeaders());
×
278
  }
279

280
  /**
281
   * Retrieves all the collaborations for a group. The user must have admin permissions to inspect
282
   * enterprise's groups.
283
   *
284
   * <p>Each collaboration object has details on which files or folders the group has access to and
285
   * with what role.
286
   *
287
   * @param groupId The ID of the group. Example: "57645"
288
   * @param headers Headers of getGroupCollaborations method
289
   */
290
  public CollaborationsOffsetPaginated getGroupCollaborations(
291
      String groupId, GetGroupCollaborationsHeaders headers) {
292
    return getGroupCollaborations(groupId, new GetGroupCollaborationsQueryParams(), headers);
×
293
  }
294

295
  /**
296
   * Retrieves all the collaborations for a group. The user must have admin permissions to inspect
297
   * enterprise's groups.
298
   *
299
   * <p>Each collaboration object has details on which files or folders the group has access to and
300
   * with what role.
301
   *
302
   * @param groupId The ID of the group. Example: "57645"
303
   * @param queryParams Query parameters of getGroupCollaborations method
304
   * @param headers Headers of getGroupCollaborations method
305
   */
306
  public CollaborationsOffsetPaginated getGroupCollaborations(
307
      String groupId,
308
      GetGroupCollaborationsQueryParams queryParams,
309
      GetGroupCollaborationsHeaders headers) {
310
    Map<String, String> queryParamsMap =
1✔
311
        prepareParams(
1✔
312
            mapOf(
1✔
313
                entryOf("limit", convertToString(queryParams.getLimit())),
1✔
314
                entryOf("offset", convertToString(queryParams.getOffset()))));
1✔
315
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
316
    FetchResponse response =
1✔
317
        this.networkSession
318
            .getNetworkClient()
1✔
319
            .fetch(
1✔
320
                new FetchOptions.Builder(
321
                        String.join(
1✔
322
                            "",
323
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
324
                            "/2.0/groups/",
325
                            convertToString(groupId),
1✔
326
                            "/collaborations"),
327
                        "GET")
328
                    .params(queryParamsMap)
1✔
329
                    .headers(headersMap)
1✔
330
                    .responseFormat(ResponseFormat.JSON)
1✔
331
                    .auth(this.auth)
1✔
332
                    .networkSession(this.networkSession)
1✔
333
                    .build());
1✔
334
    return JsonManager.deserialize(response.getData(), CollaborationsOffsetPaginated.class);
1✔
335
  }
336

337
  public Authentication getAuth() {
338
    return auth;
×
339
  }
340

341
  public NetworkSession getNetworkSession() {
342
    return networkSession;
×
343
  }
344

345
  public static class Builder {
346

347
    protected Authentication auth;
348

349
    protected NetworkSession networkSession;
350

351
    public Builder() {
1✔
352
      this.networkSession = new NetworkSession();
1✔
353
    }
1✔
354

355
    public Builder auth(Authentication auth) {
356
      this.auth = auth;
1✔
357
      return this;
1✔
358
    }
359

360
    public Builder networkSession(NetworkSession networkSession) {
361
      this.networkSession = networkSession;
1✔
362
      return this;
1✔
363
    }
364

365
    public ListCollaborationsManager build() {
366
      return new ListCollaborationsManager(this);
1✔
367
    }
368
  }
369
}
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