• 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

82.89
/src/main/java/com/box/sdkgen/managers/trashedfolders/TrashedFoldersManager.java
1
package com.box.sdkgen.managers.trashedfolders;
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.trashfolder.TrashFolder;
15
import com.box.sdkgen.schemas.trashfolderrestored.TrashFolderRestored;
16
import com.box.sdkgen.serialization.json.JsonManager;
17
import java.util.Map;
18

19
public class TrashedFoldersManager {
20

21
  public Authentication auth;
22

23
  public NetworkSession networkSession;
24

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

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

34
  /**
35
   * Restores a folder that has been moved to the trash.
36
   *
37
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
38
   * folder has been deleted.
39
   *
40
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
41
   * all of its descendants, as well as the destination folder.
42
   *
43
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
44
   * performed on any of the locked folders.
45
   *
46
   * @param folderId The unique identifier that represent a folder.
47
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
48
   *     and copying the ID from the URL. For example, for the URL
49
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
50
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
51
   */
52
  public TrashFolderRestored restoreFolderFromTrash(String folderId) {
53
    return restoreFolderFromTrash(
1✔
54
        folderId,
55
        new RestoreFolderFromTrashRequestBody(),
56
        new RestoreFolderFromTrashQueryParams(),
57
        new RestoreFolderFromTrashHeaders());
58
  }
59

60
  /**
61
   * Restores a folder that has been moved to the trash.
62
   *
63
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
64
   * folder has been deleted.
65
   *
66
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
67
   * all of its descendants, as well as the destination folder.
68
   *
69
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
70
   * performed on any of the locked folders.
71
   *
72
   * @param folderId The unique identifier that represent a folder.
73
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
74
   *     and copying the ID from the URL. For example, for the URL
75
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
76
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
77
   * @param requestBody Request body of restoreFolderFromTrash method
78
   */
79
  public TrashFolderRestored restoreFolderFromTrash(
80
      String folderId, RestoreFolderFromTrashRequestBody requestBody) {
81
    return restoreFolderFromTrash(
×
82
        folderId,
83
        requestBody,
84
        new RestoreFolderFromTrashQueryParams(),
85
        new RestoreFolderFromTrashHeaders());
86
  }
87

88
  /**
89
   * Restores a folder that has been moved to the trash.
90
   *
91
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
92
   * folder has been deleted.
93
   *
94
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
95
   * all of its descendants, as well as the destination folder.
96
   *
97
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
98
   * performed on any of the locked folders.
99
   *
100
   * @param folderId The unique identifier that represent a folder.
101
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
102
   *     and copying the ID from the URL. For example, for the URL
103
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
104
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
105
   * @param queryParams Query parameters of restoreFolderFromTrash method
106
   */
107
  public TrashFolderRestored restoreFolderFromTrash(
108
      String folderId, RestoreFolderFromTrashQueryParams queryParams) {
109
    return restoreFolderFromTrash(
×
110
        folderId,
111
        new RestoreFolderFromTrashRequestBody(),
112
        queryParams,
113
        new RestoreFolderFromTrashHeaders());
114
  }
115

116
  /**
117
   * Restores a folder that has been moved to the trash.
118
   *
119
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
120
   * folder has been deleted.
121
   *
122
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
123
   * all of its descendants, as well as the destination folder.
124
   *
125
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
126
   * performed on any of the locked folders.
127
   *
128
   * @param folderId The unique identifier that represent a folder.
129
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
130
   *     and copying the ID from the URL. For example, for the URL
131
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
132
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
133
   * @param requestBody Request body of restoreFolderFromTrash method
134
   * @param queryParams Query parameters of restoreFolderFromTrash method
135
   */
136
  public TrashFolderRestored restoreFolderFromTrash(
137
      String folderId,
138
      RestoreFolderFromTrashRequestBody requestBody,
139
      RestoreFolderFromTrashQueryParams queryParams) {
140
    return restoreFolderFromTrash(
×
141
        folderId, requestBody, queryParams, new RestoreFolderFromTrashHeaders());
142
  }
143

144
  /**
145
   * Restores a folder that has been moved to the trash.
146
   *
147
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
148
   * folder has been deleted.
149
   *
150
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
151
   * all of its descendants, as well as the destination folder.
152
   *
153
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
154
   * performed on any of the locked folders.
155
   *
156
   * @param folderId The unique identifier that represent a folder.
157
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
158
   *     and copying the ID from the URL. For example, for the URL
159
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
160
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
161
   * @param headers Headers of restoreFolderFromTrash method
162
   */
163
  public TrashFolderRestored restoreFolderFromTrash(
164
      String folderId, RestoreFolderFromTrashHeaders headers) {
165
    return restoreFolderFromTrash(
×
166
        folderId,
167
        new RestoreFolderFromTrashRequestBody(),
168
        new RestoreFolderFromTrashQueryParams(),
169
        headers);
170
  }
171

172
  /**
173
   * Restores a folder that has been moved to the trash.
174
   *
175
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
176
   * folder has been deleted.
177
   *
178
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
179
   * all of its descendants, as well as the destination folder.
180
   *
181
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
182
   * performed on any of the locked folders.
183
   *
184
   * @param folderId The unique identifier that represent a folder.
185
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
186
   *     and copying the ID from the URL. For example, for the URL
187
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
188
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
189
   * @param requestBody Request body of restoreFolderFromTrash method
190
   * @param headers Headers of restoreFolderFromTrash method
191
   */
192
  public TrashFolderRestored restoreFolderFromTrash(
193
      String folderId,
194
      RestoreFolderFromTrashRequestBody requestBody,
195
      RestoreFolderFromTrashHeaders headers) {
196
    return restoreFolderFromTrash(
×
197
        folderId, requestBody, new RestoreFolderFromTrashQueryParams(), headers);
198
  }
199

200
  /**
201
   * Restores a folder that has been moved to the trash.
202
   *
203
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
204
   * folder has been deleted.
205
   *
206
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
207
   * all of its descendants, as well as the destination folder.
208
   *
209
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
210
   * performed on any of the locked folders.
211
   *
212
   * @param folderId The unique identifier that represent a folder.
213
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
214
   *     and copying the ID from the URL. For example, for the URL
215
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
216
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
217
   * @param queryParams Query parameters of restoreFolderFromTrash method
218
   * @param headers Headers of restoreFolderFromTrash method
219
   */
220
  public TrashFolderRestored restoreFolderFromTrash(
221
      String folderId,
222
      RestoreFolderFromTrashQueryParams queryParams,
223
      RestoreFolderFromTrashHeaders headers) {
224
    return restoreFolderFromTrash(
×
225
        folderId, new RestoreFolderFromTrashRequestBody(), queryParams, headers);
226
  }
227

228
  /**
229
   * Restores a folder that has been moved to the trash.
230
   *
231
   * <p>An optional new parent ID can be provided to restore the folder to in case the original
232
   * folder has been deleted.
233
   *
234
   * <p>During this operation, part of the file tree will be locked, mainly the source folder and
235
   * all of its descendants, as well as the destination folder.
236
   *
237
   * <p>For the duration of the operation, no other move, copy, delete, or restore operation can
238
   * performed on any of the locked folders.
239
   *
240
   * @param folderId The unique identifier that represent a folder.
241
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
242
   *     and copying the ID from the URL. For example, for the URL
243
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
244
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
245
   * @param requestBody Request body of restoreFolderFromTrash method
246
   * @param queryParams Query parameters of restoreFolderFromTrash method
247
   * @param headers Headers of restoreFolderFromTrash method
248
   */
249
  public TrashFolderRestored restoreFolderFromTrash(
250
      String folderId,
251
      RestoreFolderFromTrashRequestBody requestBody,
252
      RestoreFolderFromTrashQueryParams queryParams,
253
      RestoreFolderFromTrashHeaders headers) {
254
    Map<String, String> queryParamsMap =
1✔
255
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
256
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
257
    FetchResponse response =
1✔
258
        this.networkSession
259
            .getNetworkClient()
1✔
260
            .fetch(
1✔
261
                new FetchOptions.Builder(
262
                        String.join(
1✔
263
                            "",
264
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
265
                            "/2.0/folders/",
266
                            convertToString(folderId)),
1✔
267
                        "POST")
268
                    .params(queryParamsMap)
1✔
269
                    .headers(headersMap)
1✔
270
                    .data(JsonManager.serialize(requestBody))
1✔
271
                    .contentType("application/json")
1✔
272
                    .responseFormat(ResponseFormat.JSON)
1✔
273
                    .auth(this.auth)
1✔
274
                    .networkSession(this.networkSession)
1✔
275
                    .build());
1✔
276
    return JsonManager.deserialize(response.getData(), TrashFolderRestored.class);
1✔
277
  }
278

279
  /**
280
   * Retrieves a folder that has been moved to the trash.
281
   *
282
   * <p>Please note that only if the folder itself has been moved to the trash can it be retrieved
283
   * with this API call. If instead one of its parent folders was moved to the trash, only that
284
   * folder can be inspected using the [`GET /folders/:id/trash`](e://get_folders_id_trash) API.
285
   *
286
   * <p>To list all items that have been moved to the trash, please use the [`GET
287
   * /folders/trash/items`](e://get-folders-trash-items/) API.
288
   *
289
   * @param folderId The unique identifier that represent a folder.
290
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
291
   *     and copying the ID from the URL. For example, for the URL
292
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
293
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
294
   */
295
  public TrashFolder getTrashedFolderById(String folderId) {
296
    return getTrashedFolderById(
1✔
297
        folderId, new GetTrashedFolderByIdQueryParams(), new GetTrashedFolderByIdHeaders());
298
  }
299

300
  /**
301
   * Retrieves a folder that has been moved to the trash.
302
   *
303
   * <p>Please note that only if the folder itself has been moved to the trash can it be retrieved
304
   * with this API call. If instead one of its parent folders was moved to the trash, only that
305
   * folder can be inspected using the [`GET /folders/:id/trash`](e://get_folders_id_trash) API.
306
   *
307
   * <p>To list all items that have been moved to the trash, please use the [`GET
308
   * /folders/trash/items`](e://get-folders-trash-items/) API.
309
   *
310
   * @param folderId The unique identifier that represent a folder.
311
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
312
   *     and copying the ID from the URL. For example, for the URL
313
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
314
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
315
   * @param queryParams Query parameters of getTrashedFolderById method
316
   */
317
  public TrashFolder getTrashedFolderById(
318
      String folderId, GetTrashedFolderByIdQueryParams queryParams) {
319
    return getTrashedFolderById(folderId, queryParams, new GetTrashedFolderByIdHeaders());
×
320
  }
321

322
  /**
323
   * Retrieves a folder that has been moved to the trash.
324
   *
325
   * <p>Please note that only if the folder itself has been moved to the trash can it be retrieved
326
   * with this API call. If instead one of its parent folders was moved to the trash, only that
327
   * folder can be inspected using the [`GET /folders/:id/trash`](e://get_folders_id_trash) API.
328
   *
329
   * <p>To list all items that have been moved to the trash, please use the [`GET
330
   * /folders/trash/items`](e://get-folders-trash-items/) API.
331
   *
332
   * @param folderId The unique identifier that represent a folder.
333
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
334
   *     and copying the ID from the URL. For example, for the URL
335
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
336
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
337
   * @param headers Headers of getTrashedFolderById method
338
   */
339
  public TrashFolder getTrashedFolderById(String folderId, GetTrashedFolderByIdHeaders headers) {
340
    return getTrashedFolderById(folderId, new GetTrashedFolderByIdQueryParams(), headers);
×
341
  }
342

343
  /**
344
   * Retrieves a folder that has been moved to the trash.
345
   *
346
   * <p>Please note that only if the folder itself has been moved to the trash can it be retrieved
347
   * with this API call. If instead one of its parent folders was moved to the trash, only that
348
   * folder can be inspected using the [`GET /folders/:id/trash`](e://get_folders_id_trash) API.
349
   *
350
   * <p>To list all items that have been moved to the trash, please use the [`GET
351
   * /folders/trash/items`](e://get-folders-trash-items/) API.
352
   *
353
   * @param folderId The unique identifier that represent a folder.
354
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
355
   *     and copying the ID from the URL. For example, for the URL
356
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
357
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
358
   * @param queryParams Query parameters of getTrashedFolderById method
359
   * @param headers Headers of getTrashedFolderById method
360
   */
361
  public TrashFolder getTrashedFolderById(
362
      String folderId,
363
      GetTrashedFolderByIdQueryParams queryParams,
364
      GetTrashedFolderByIdHeaders headers) {
365
    Map<String, String> queryParamsMap =
1✔
366
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
367
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
368
    FetchResponse response =
1✔
369
        this.networkSession
370
            .getNetworkClient()
1✔
371
            .fetch(
1✔
372
                new FetchOptions.Builder(
373
                        String.join(
1✔
374
                            "",
375
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
376
                            "/2.0/folders/",
377
                            convertToString(folderId),
1✔
378
                            "/trash"),
379
                        "GET")
380
                    .params(queryParamsMap)
1✔
381
                    .headers(headersMap)
1✔
382
                    .responseFormat(ResponseFormat.JSON)
1✔
383
                    .auth(this.auth)
1✔
384
                    .networkSession(this.networkSession)
1✔
385
                    .build());
1✔
386
    return JsonManager.deserialize(response.getData(), TrashFolder.class);
1✔
387
  }
388

389
  /**
390
   * Permanently deletes a folder that is in the trash. This action cannot be undone.
391
   *
392
   * @param folderId The unique identifier that represent a folder.
393
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
394
   *     and copying the ID from the URL. For example, for the URL
395
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
396
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
397
   */
398
  public void deleteTrashedFolderById(String folderId) {
399
    deleteTrashedFolderById(folderId, new DeleteTrashedFolderByIdHeaders());
1✔
400
  }
1✔
401

402
  /**
403
   * Permanently deletes a folder that is in the trash. This action cannot be undone.
404
   *
405
   * @param folderId The unique identifier that represent a folder.
406
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
407
   *     and copying the ID from the URL. For example, for the URL
408
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
409
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
410
   * @param headers Headers of deleteTrashedFolderById method
411
   */
412
  public void deleteTrashedFolderById(String folderId, DeleteTrashedFolderByIdHeaders headers) {
413
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
414
    FetchResponse response =
1✔
415
        this.networkSession
416
            .getNetworkClient()
1✔
417
            .fetch(
1✔
418
                new FetchOptions.Builder(
419
                        String.join(
1✔
420
                            "",
421
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
422
                            "/2.0/folders/",
423
                            convertToString(folderId),
1✔
424
                            "/trash"),
425
                        "DELETE")
426
                    .headers(headersMap)
1✔
427
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
428
                    .auth(this.auth)
1✔
429
                    .networkSession(this.networkSession)
1✔
430
                    .build());
1✔
431
  }
1✔
432

433
  public Authentication getAuth() {
434
    return auth;
×
435
  }
436

437
  public NetworkSession getNetworkSession() {
438
    return networkSession;
×
439
  }
440

441
  public static class Builder {
442

443
    protected Authentication auth;
444

445
    protected NetworkSession networkSession;
446

447
    public Builder() {
1✔
448
      this.networkSession = new NetworkSession();
1✔
449
    }
1✔
450

451
    public Builder auth(Authentication auth) {
452
      this.auth = auth;
1✔
453
      return this;
1✔
454
    }
455

456
    public Builder networkSession(NetworkSession networkSession) {
457
      this.networkSession = networkSession;
1✔
458
      return this;
1✔
459
    }
460

461
    public TrashedFoldersManager build() {
462
      return new TrashedFoldersManager(this);
1✔
463
    }
464
  }
465
}
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