• 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

29.27
/src/main/java/com/box/sdkgen/managers/transfer/TransferManager.java
1
package com.box.sdkgen.managers.transfer;
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.folderfull.FolderFull;
15
import com.box.sdkgen.serialization.json.JsonManager;
16
import java.util.Map;
17

18
public class TransferManager {
19

20
  public Authentication auth;
21

22
  public NetworkSession networkSession;
23

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

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

33
  /**
34
   * Move all of the items (files, folders and workflows) owned by a user into another user's
35
   * account
36
   *
37
   * <p>Only the root folder (`0`) can be transferred.
38
   *
39
   * <p>Folders can only be moved across users by users with administrative permissions.
40
   *
41
   * <p>All existing shared links and folder-level collaborations are transferred during the
42
   * operation. Please note that while collaborations at the individual file-level are transferred
43
   * during the operation, the collaborations are deleted when the original user is deleted.
44
   *
45
   * <p>If the user has a large number of items across all folders, the call will be run
46
   * asynchronously. If the operation is not completed within 10 minutes, the user will receive a
47
   * 200 OK response, and the operation will continue running.
48
   *
49
   * <p>If the destination path has a metadata cascade policy attached to any of the parent folders,
50
   * a metadata cascade operation will be kicked off asynchronously.
51
   *
52
   * <p>There is currently no way to check for when this operation is finished.
53
   *
54
   * <p>The destination folder's name will be in the format `{User}'s Files and Folders`, where
55
   * `{User}` is the display name of the user.
56
   *
57
   * <p>To make this API call your application will need to have the "Read and write all files and
58
   * folders stored in Box" scope enabled.
59
   *
60
   * <p>Please make sure the destination user has access to `Relay` or `Relay Lite`, and has access
61
   * to the files and folders involved in the workflows being transferred.
62
   *
63
   * <p>Admins will receive an email when the operation is completed.
64
   *
65
   * @param userId The ID of the user. Example: "12345"
66
   * @param requestBody Request body of transferOwnedFolder method
67
   */
68
  public FolderFull transferOwnedFolder(String userId, TransferOwnedFolderRequestBody requestBody) {
69
    return transferOwnedFolder(
×
70
        userId,
71
        requestBody,
72
        new TransferOwnedFolderQueryParams(),
73
        new TransferOwnedFolderHeaders());
74
  }
75

76
  /**
77
   * Move all of the items (files, folders and workflows) owned by a user into another user's
78
   * account
79
   *
80
   * <p>Only the root folder (`0`) can be transferred.
81
   *
82
   * <p>Folders can only be moved across users by users with administrative permissions.
83
   *
84
   * <p>All existing shared links and folder-level collaborations are transferred during the
85
   * operation. Please note that while collaborations at the individual file-level are transferred
86
   * during the operation, the collaborations are deleted when the original user is deleted.
87
   *
88
   * <p>If the user has a large number of items across all folders, the call will be run
89
   * asynchronously. If the operation is not completed within 10 minutes, the user will receive a
90
   * 200 OK response, and the operation will continue running.
91
   *
92
   * <p>If the destination path has a metadata cascade policy attached to any of the parent folders,
93
   * a metadata cascade operation will be kicked off asynchronously.
94
   *
95
   * <p>There is currently no way to check for when this operation is finished.
96
   *
97
   * <p>The destination folder's name will be in the format `{User}'s Files and Folders`, where
98
   * `{User}` is the display name of the user.
99
   *
100
   * <p>To make this API call your application will need to have the "Read and write all files and
101
   * folders stored in Box" scope enabled.
102
   *
103
   * <p>Please make sure the destination user has access to `Relay` or `Relay Lite`, and has access
104
   * to the files and folders involved in the workflows being transferred.
105
   *
106
   * <p>Admins will receive an email when the operation is completed.
107
   *
108
   * @param userId The ID of the user. Example: "12345"
109
   * @param requestBody Request body of transferOwnedFolder method
110
   * @param queryParams Query parameters of transferOwnedFolder method
111
   */
112
  public FolderFull transferOwnedFolder(
113
      String userId,
114
      TransferOwnedFolderRequestBody requestBody,
115
      TransferOwnedFolderQueryParams queryParams) {
116
    return transferOwnedFolder(userId, requestBody, queryParams, new TransferOwnedFolderHeaders());
×
117
  }
118

119
  /**
120
   * Move all of the items (files, folders and workflows) owned by a user into another user's
121
   * account
122
   *
123
   * <p>Only the root folder (`0`) can be transferred.
124
   *
125
   * <p>Folders can only be moved across users by users with administrative permissions.
126
   *
127
   * <p>All existing shared links and folder-level collaborations are transferred during the
128
   * operation. Please note that while collaborations at the individual file-level are transferred
129
   * during the operation, the collaborations are deleted when the original user is deleted.
130
   *
131
   * <p>If the user has a large number of items across all folders, the call will be run
132
   * asynchronously. If the operation is not completed within 10 minutes, the user will receive a
133
   * 200 OK response, and the operation will continue running.
134
   *
135
   * <p>If the destination path has a metadata cascade policy attached to any of the parent folders,
136
   * a metadata cascade operation will be kicked off asynchronously.
137
   *
138
   * <p>There is currently no way to check for when this operation is finished.
139
   *
140
   * <p>The destination folder's name will be in the format `{User}'s Files and Folders`, where
141
   * `{User}` is the display name of the user.
142
   *
143
   * <p>To make this API call your application will need to have the "Read and write all files and
144
   * folders stored in Box" scope enabled.
145
   *
146
   * <p>Please make sure the destination user has access to `Relay` or `Relay Lite`, and has access
147
   * to the files and folders involved in the workflows being transferred.
148
   *
149
   * <p>Admins will receive an email when the operation is completed.
150
   *
151
   * @param userId The ID of the user. Example: "12345"
152
   * @param requestBody Request body of transferOwnedFolder method
153
   * @param headers Headers of transferOwnedFolder method
154
   */
155
  public FolderFull transferOwnedFolder(
156
      String userId,
157
      TransferOwnedFolderRequestBody requestBody,
158
      TransferOwnedFolderHeaders headers) {
159
    return transferOwnedFolder(userId, requestBody, new TransferOwnedFolderQueryParams(), headers);
×
160
  }
161

162
  /**
163
   * Move all of the items (files, folders and workflows) owned by a user into another user's
164
   * account
165
   *
166
   * <p>Only the root folder (`0`) can be transferred.
167
   *
168
   * <p>Folders can only be moved across users by users with administrative permissions.
169
   *
170
   * <p>All existing shared links and folder-level collaborations are transferred during the
171
   * operation. Please note that while collaborations at the individual file-level are transferred
172
   * during the operation, the collaborations are deleted when the original user is deleted.
173
   *
174
   * <p>If the user has a large number of items across all folders, the call will be run
175
   * asynchronously. If the operation is not completed within 10 minutes, the user will receive a
176
   * 200 OK response, and the operation will continue running.
177
   *
178
   * <p>If the destination path has a metadata cascade policy attached to any of the parent folders,
179
   * a metadata cascade operation will be kicked off asynchronously.
180
   *
181
   * <p>There is currently no way to check for when this operation is finished.
182
   *
183
   * <p>The destination folder's name will be in the format `{User}'s Files and Folders`, where
184
   * `{User}` is the display name of the user.
185
   *
186
   * <p>To make this API call your application will need to have the "Read and write all files and
187
   * folders stored in Box" scope enabled.
188
   *
189
   * <p>Please make sure the destination user has access to `Relay` or `Relay Lite`, and has access
190
   * to the files and folders involved in the workflows being transferred.
191
   *
192
   * <p>Admins will receive an email when the operation is completed.
193
   *
194
   * @param userId The ID of the user. Example: "12345"
195
   * @param requestBody Request body of transferOwnedFolder method
196
   * @param queryParams Query parameters of transferOwnedFolder method
197
   * @param headers Headers of transferOwnedFolder method
198
   */
199
  public FolderFull transferOwnedFolder(
200
      String userId,
201
      TransferOwnedFolderRequestBody requestBody,
202
      TransferOwnedFolderQueryParams queryParams,
203
      TransferOwnedFolderHeaders headers) {
204
    Map<String, String> queryParamsMap =
×
205
        prepareParams(
×
206
            mapOf(
×
207
                entryOf("fields", convertToString(queryParams.getFields())),
×
208
                entryOf("notify", convertToString(queryParams.getNotify()))));
×
209
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
210
    FetchResponse response =
×
211
        this.networkSession
212
            .getNetworkClient()
×
213
            .fetch(
×
214
                new FetchOptions.Builder(
215
                        String.join(
×
216
                            "",
217
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
218
                            "/2.0/users/",
219
                            convertToString(userId),
×
220
                            "/folders/0"),
221
                        "PUT")
222
                    .params(queryParamsMap)
×
223
                    .headers(headersMap)
×
224
                    .data(JsonManager.serialize(requestBody))
×
225
                    .contentType("application/json")
×
226
                    .responseFormat(ResponseFormat.JSON)
×
227
                    .auth(this.auth)
×
228
                    .networkSession(this.networkSession)
×
229
                    .build());
×
230
    return JsonManager.deserialize(response.getData(), FolderFull.class);
×
231
  }
232

233
  public Authentication getAuth() {
234
    return auth;
×
235
  }
236

237
  public NetworkSession getNetworkSession() {
238
    return networkSession;
×
239
  }
240

241
  public static class Builder {
242

243
    protected Authentication auth;
244

245
    protected NetworkSession networkSession;
246

247
    public Builder() {
1✔
248
      this.networkSession = new NetworkSession();
1✔
249
    }
1✔
250

251
    public Builder auth(Authentication auth) {
252
      this.auth = auth;
1✔
253
      return this;
1✔
254
    }
255

256
    public Builder networkSession(NetworkSession networkSession) {
257
      this.networkSession = networkSession;
1✔
258
      return this;
1✔
259
    }
260

261
    public TransferManager build() {
262
      return new TransferManager(this);
1✔
263
    }
264
  }
265
}
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