• 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

85.71
/src/main/java/com/box/sdkgen/managers/groups/GroupsManager.java
1
package com.box.sdkgen.managers.groups;
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.groupfull.GroupFull;
15
import com.box.sdkgen.schemas.groups.Groups;
16
import com.box.sdkgen.serialization.json.JsonManager;
17
import java.util.Map;
18

19
public class GroupsManager {
20

21
  public Authentication auth;
22

23
  public NetworkSession networkSession;
24

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

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

34
  /**
35
   * Retrieves all of the groups for a given enterprise. The user must have admin permissions to
36
   * inspect enterprise's groups.
37
   */
38
  public Groups getGroups() {
39
    return getGroups(new GetGroupsQueryParams(), new GetGroupsHeaders());
1✔
40
  }
41

42
  /**
43
   * Retrieves all of the groups for a given enterprise. The user must have admin permissions to
44
   * inspect enterprise's groups.
45
   *
46
   * @param queryParams Query parameters of getGroups method
47
   */
48
  public Groups getGroups(GetGroupsQueryParams queryParams) {
49
    return getGroups(queryParams, new GetGroupsHeaders());
×
50
  }
51

52
  /**
53
   * Retrieves all of the groups for a given enterprise. The user must have admin permissions to
54
   * inspect enterprise's groups.
55
   *
56
   * @param headers Headers of getGroups method
57
   */
58
  public Groups getGroups(GetGroupsHeaders headers) {
59
    return getGroups(new GetGroupsQueryParams(), headers);
×
60
  }
61

62
  /**
63
   * Retrieves all of the groups for a given enterprise. The user must have admin permissions to
64
   * inspect enterprise's groups.
65
   *
66
   * @param queryParams Query parameters of getGroups method
67
   * @param headers Headers of getGroups method
68
   */
69
  public Groups getGroups(GetGroupsQueryParams queryParams, GetGroupsHeaders headers) {
70
    Map<String, String> queryParamsMap =
1✔
71
        prepareParams(
1✔
72
            mapOf(
1✔
73
                entryOf("filter_term", convertToString(queryParams.getFilterTerm())),
1✔
74
                entryOf("fields", convertToString(queryParams.getFields())),
1✔
75
                entryOf("limit", convertToString(queryParams.getLimit())),
1✔
76
                entryOf("offset", convertToString(queryParams.getOffset()))));
1✔
77
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
78
    FetchResponse response =
1✔
79
        this.networkSession
80
            .getNetworkClient()
1✔
81
            .fetch(
1✔
82
                new FetchOptions.Builder(
83
                        String.join(
1✔
84
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/groups"),
1✔
85
                        "GET")
86
                    .params(queryParamsMap)
1✔
87
                    .headers(headersMap)
1✔
88
                    .responseFormat(ResponseFormat.JSON)
1✔
89
                    .auth(this.auth)
1✔
90
                    .networkSession(this.networkSession)
1✔
91
                    .build());
1✔
92
    return JsonManager.deserialize(response.getData(), Groups.class);
1✔
93
  }
94

95
  /**
96
   * Creates a new group of users in an enterprise. Only users with admin permissions can create new
97
   * groups.
98
   *
99
   * @param requestBody Request body of createGroup method
100
   */
101
  public GroupFull createGroup(CreateGroupRequestBody requestBody) {
102
    return createGroup(requestBody, new CreateGroupQueryParams(), new CreateGroupHeaders());
1✔
103
  }
104

105
  /**
106
   * Creates a new group of users in an enterprise. Only users with admin permissions can create new
107
   * groups.
108
   *
109
   * @param requestBody Request body of createGroup method
110
   * @param queryParams Query parameters of createGroup method
111
   */
112
  public GroupFull createGroup(
113
      CreateGroupRequestBody requestBody, CreateGroupQueryParams queryParams) {
114
    return createGroup(requestBody, queryParams, new CreateGroupHeaders());
×
115
  }
116

117
  /**
118
   * Creates a new group of users in an enterprise. Only users with admin permissions can create new
119
   * groups.
120
   *
121
   * @param requestBody Request body of createGroup method
122
   * @param headers Headers of createGroup method
123
   */
124
  public GroupFull createGroup(CreateGroupRequestBody requestBody, CreateGroupHeaders headers) {
125
    return createGroup(requestBody, new CreateGroupQueryParams(), headers);
×
126
  }
127

128
  /**
129
   * Creates a new group of users in an enterprise. Only users with admin permissions can create new
130
   * groups.
131
   *
132
   * @param requestBody Request body of createGroup method
133
   * @param queryParams Query parameters of createGroup method
134
   * @param headers Headers of createGroup method
135
   */
136
  public GroupFull createGroup(
137
      CreateGroupRequestBody requestBody,
138
      CreateGroupQueryParams queryParams,
139
      CreateGroupHeaders headers) {
140
    Map<String, String> queryParamsMap =
1✔
141
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
142
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
143
    FetchResponse response =
1✔
144
        this.networkSession
145
            .getNetworkClient()
1✔
146
            .fetch(
1✔
147
                new FetchOptions.Builder(
148
                        String.join(
1✔
149
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/groups"),
1✔
150
                        "POST")
151
                    .params(queryParamsMap)
1✔
152
                    .headers(headersMap)
1✔
153
                    .data(JsonManager.serialize(requestBody))
1✔
154
                    .contentType("application/json")
1✔
155
                    .responseFormat(ResponseFormat.JSON)
1✔
156
                    .auth(this.auth)
1✔
157
                    .networkSession(this.networkSession)
1✔
158
                    .build());
1✔
159
    return JsonManager.deserialize(response.getData(), GroupFull.class);
1✔
160
  }
161

162
  /**
163
   * Retrieves information about a group. Only members of this group or users with admin-level
164
   * permissions will be able to use this API.
165
   *
166
   * @param groupId The ID of the group. Example: "57645"
167
   */
168
  public GroupFull getGroupById(String groupId) {
169
    return getGroupById(groupId, new GetGroupByIdQueryParams(), new GetGroupByIdHeaders());
×
170
  }
171

172
  /**
173
   * Retrieves information about a group. Only members of this group or users with admin-level
174
   * permissions will be able to use this API.
175
   *
176
   * @param groupId The ID of the group. Example: "57645"
177
   * @param queryParams Query parameters of getGroupById method
178
   */
179
  public GroupFull getGroupById(String groupId, GetGroupByIdQueryParams queryParams) {
180
    return getGroupById(groupId, queryParams, new GetGroupByIdHeaders());
1✔
181
  }
182

183
  /**
184
   * Retrieves information about a group. Only members of this group or users with admin-level
185
   * permissions will be able to use this API.
186
   *
187
   * @param groupId The ID of the group. Example: "57645"
188
   * @param headers Headers of getGroupById method
189
   */
190
  public GroupFull getGroupById(String groupId, GetGroupByIdHeaders headers) {
191
    return getGroupById(groupId, new GetGroupByIdQueryParams(), headers);
×
192
  }
193

194
  /**
195
   * Retrieves information about a group. Only members of this group or users with admin-level
196
   * permissions will be able to use this API.
197
   *
198
   * @param groupId The ID of the group. Example: "57645"
199
   * @param queryParams Query parameters of getGroupById method
200
   * @param headers Headers of getGroupById method
201
   */
202
  public GroupFull getGroupById(
203
      String groupId, GetGroupByIdQueryParams queryParams, GetGroupByIdHeaders headers) {
204
    Map<String, String> queryParamsMap =
1✔
205
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
206
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
207
    FetchResponse response =
1✔
208
        this.networkSession
209
            .getNetworkClient()
1✔
210
            .fetch(
1✔
211
                new FetchOptions.Builder(
212
                        String.join(
1✔
213
                            "",
214
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
215
                            "/2.0/groups/",
216
                            convertToString(groupId)),
1✔
217
                        "GET")
218
                    .params(queryParamsMap)
1✔
219
                    .headers(headersMap)
1✔
220
                    .responseFormat(ResponseFormat.JSON)
1✔
221
                    .auth(this.auth)
1✔
222
                    .networkSession(this.networkSession)
1✔
223
                    .build());
1✔
224
    return JsonManager.deserialize(response.getData(), GroupFull.class);
1✔
225
  }
226

227
  /**
228
   * Updates a specific group. Only admins of this group or users with admin-level permissions will
229
   * be able to use this API.
230
   *
231
   * @param groupId The ID of the group. Example: "57645"
232
   */
233
  public GroupFull updateGroupById(String groupId) {
234
    return updateGroupById(
×
235
        groupId,
236
        new UpdateGroupByIdRequestBody(),
237
        new UpdateGroupByIdQueryParams(),
238
        new UpdateGroupByIdHeaders());
239
  }
240

241
  /**
242
   * Updates a specific group. Only admins of this group or users with admin-level permissions will
243
   * be able to use this API.
244
   *
245
   * @param groupId The ID of the group. Example: "57645"
246
   * @param requestBody Request body of updateGroupById method
247
   */
248
  public GroupFull updateGroupById(String groupId, UpdateGroupByIdRequestBody requestBody) {
249
    return updateGroupById(
1✔
250
        groupId, requestBody, new UpdateGroupByIdQueryParams(), new UpdateGroupByIdHeaders());
251
  }
252

253
  /**
254
   * Updates a specific group. Only admins of this group or users with admin-level permissions will
255
   * be able to use this API.
256
   *
257
   * @param groupId The ID of the group. Example: "57645"
258
   * @param queryParams Query parameters of updateGroupById method
259
   */
260
  public GroupFull updateGroupById(String groupId, UpdateGroupByIdQueryParams queryParams) {
261
    return updateGroupById(
×
262
        groupId, new UpdateGroupByIdRequestBody(), queryParams, new UpdateGroupByIdHeaders());
263
  }
264

265
  /**
266
   * Updates a specific group. Only admins of this group or users with admin-level permissions will
267
   * be able to use this API.
268
   *
269
   * @param groupId The ID of the group. Example: "57645"
270
   * @param requestBody Request body of updateGroupById method
271
   * @param queryParams Query parameters of updateGroupById method
272
   */
273
  public GroupFull updateGroupById(
274
      String groupId,
275
      UpdateGroupByIdRequestBody requestBody,
276
      UpdateGroupByIdQueryParams queryParams) {
277
    return updateGroupById(groupId, requestBody, queryParams, new UpdateGroupByIdHeaders());
×
278
  }
279

280
  /**
281
   * Updates a specific group. Only admins of this group or users with admin-level permissions will
282
   * be able to use this API.
283
   *
284
   * @param groupId The ID of the group. Example: "57645"
285
   * @param headers Headers of updateGroupById method
286
   */
287
  public GroupFull updateGroupById(String groupId, UpdateGroupByIdHeaders headers) {
288
    return updateGroupById(
×
289
        groupId, new UpdateGroupByIdRequestBody(), new UpdateGroupByIdQueryParams(), headers);
290
  }
291

292
  /**
293
   * Updates a specific group. Only admins of this group or users with admin-level permissions will
294
   * be able to use this API.
295
   *
296
   * @param groupId The ID of the group. Example: "57645"
297
   * @param requestBody Request body of updateGroupById method
298
   * @param headers Headers of updateGroupById method
299
   */
300
  public GroupFull updateGroupById(
301
      String groupId, UpdateGroupByIdRequestBody requestBody, UpdateGroupByIdHeaders headers) {
302
    return updateGroupById(groupId, requestBody, new UpdateGroupByIdQueryParams(), headers);
×
303
  }
304

305
  /**
306
   * Updates a specific group. Only admins of this group or users with admin-level permissions will
307
   * be able to use this API.
308
   *
309
   * @param groupId The ID of the group. Example: "57645"
310
   * @param queryParams Query parameters of updateGroupById method
311
   * @param headers Headers of updateGroupById method
312
   */
313
  public GroupFull updateGroupById(
314
      String groupId, UpdateGroupByIdQueryParams queryParams, UpdateGroupByIdHeaders headers) {
315
    return updateGroupById(groupId, new UpdateGroupByIdRequestBody(), queryParams, headers);
×
316
  }
317

318
  /**
319
   * Updates a specific group. Only admins of this group or users with admin-level permissions will
320
   * be able to use this API.
321
   *
322
   * @param groupId The ID of the group. Example: "57645"
323
   * @param requestBody Request body of updateGroupById method
324
   * @param queryParams Query parameters of updateGroupById method
325
   * @param headers Headers of updateGroupById method
326
   */
327
  public GroupFull updateGroupById(
328
      String groupId,
329
      UpdateGroupByIdRequestBody requestBody,
330
      UpdateGroupByIdQueryParams queryParams,
331
      UpdateGroupByIdHeaders headers) {
332
    Map<String, String> queryParamsMap =
1✔
333
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
334
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
335
    FetchResponse response =
1✔
336
        this.networkSession
337
            .getNetworkClient()
1✔
338
            .fetch(
1✔
339
                new FetchOptions.Builder(
340
                        String.join(
1✔
341
                            "",
342
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
343
                            "/2.0/groups/",
344
                            convertToString(groupId)),
1✔
345
                        "PUT")
346
                    .params(queryParamsMap)
1✔
347
                    .headers(headersMap)
1✔
348
                    .data(JsonManager.serialize(requestBody))
1✔
349
                    .contentType("application/json")
1✔
350
                    .responseFormat(ResponseFormat.JSON)
1✔
351
                    .auth(this.auth)
1✔
352
                    .networkSession(this.networkSession)
1✔
353
                    .build());
1✔
354
    return JsonManager.deserialize(response.getData(), GroupFull.class);
1✔
355
  }
356

357
  /**
358
   * Permanently deletes a group. Only users with admin-level permissions will be able to use this
359
   * API.
360
   *
361
   * @param groupId The ID of the group. Example: "57645"
362
   */
363
  public void deleteGroupById(String groupId) {
364
    deleteGroupById(groupId, new DeleteGroupByIdHeaders());
1✔
365
  }
1✔
366

367
  /**
368
   * Permanently deletes a group. Only users with admin-level permissions will be able to use this
369
   * API.
370
   *
371
   * @param groupId The ID of the group. Example: "57645"
372
   * @param headers Headers of deleteGroupById method
373
   */
374
  public void deleteGroupById(String groupId, DeleteGroupByIdHeaders headers) {
375
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
376
    FetchResponse response =
1✔
377
        this.networkSession
378
            .getNetworkClient()
1✔
379
            .fetch(
1✔
380
                new FetchOptions.Builder(
381
                        String.join(
1✔
382
                            "",
383
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
384
                            "/2.0/groups/",
385
                            convertToString(groupId)),
1✔
386
                        "DELETE")
387
                    .headers(headersMap)
1✔
388
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
389
                    .auth(this.auth)
1✔
390
                    .networkSession(this.networkSession)
1✔
391
                    .build());
1✔
392
  }
1✔
393

394
  public Authentication getAuth() {
395
    return auth;
×
396
  }
397

398
  public NetworkSession getNetworkSession() {
399
    return networkSession;
×
400
  }
401

402
  public static class Builder {
403

404
    protected Authentication auth;
405

406
    protected NetworkSession networkSession;
407

408
    public Builder() {
1✔
409
      this.networkSession = new NetworkSession();
1✔
410
    }
1✔
411

412
    public Builder auth(Authentication auth) {
413
      this.auth = auth;
1✔
414
      return this;
1✔
415
    }
416

417
    public Builder networkSession(NetworkSession networkSession) {
418
      this.networkSession = networkSession;
1✔
419
      return this;
1✔
420
    }
421

422
    public GroupsManager build() {
423
      return new GroupsManager(this);
1✔
424
    }
425
  }
426
}
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