• 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

92.47
/src/main/java/com/box/sdkgen/managers/tasks/TasksManager.java
1
package com.box.sdkgen.managers.tasks;
2

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

8
import com.box.sdkgen.networking.auth.Authentication;
9
import com.box.sdkgen.networking.fetchoptions.FetchOptions;
10
import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
11
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
12
import com.box.sdkgen.networking.network.NetworkSession;
13
import com.box.sdkgen.schemas.task.Task;
14
import com.box.sdkgen.schemas.tasks.Tasks;
15
import com.box.sdkgen.serialization.json.JsonManager;
16
import java.util.Map;
17

18
public class TasksManager {
19

20
  public Authentication auth;
21

22
  public NetworkSession networkSession;
23

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

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

33
  /**
34
   * Retrieves a list of all the tasks for a file. This endpoint does not support pagination.
35
   *
36
   * @param fileId The unique identifier that represents a file.
37
   *     <p>The ID for any file can be determined by visiting a file in the web application and
38
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
39
   *     `file_id` is `123`. Example: "12345"
40
   */
41
  public Tasks getFileTasks(String fileId) {
42
    return getFileTasks(fileId, new GetFileTasksHeaders());
1✔
43
  }
44

45
  /**
46
   * Retrieves a list of all the tasks for a file. This endpoint does not support pagination.
47
   *
48
   * @param fileId The unique identifier that represents a file.
49
   *     <p>The ID for any file can be determined by visiting a file in the web application and
50
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
51
   *     `file_id` is `123`. Example: "12345"
52
   * @param headers Headers of getFileTasks method
53
   */
54
  public Tasks getFileTasks(String fileId, GetFileTasksHeaders headers) {
55
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
56
    FetchResponse response =
1✔
57
        this.networkSession
58
            .getNetworkClient()
1✔
59
            .fetch(
1✔
60
                new FetchOptions.Builder(
61
                        String.join(
1✔
62
                            "",
63
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
64
                            "/2.0/files/",
65
                            convertToString(fileId),
1✔
66
                            "/tasks"),
67
                        "GET")
68
                    .headers(headersMap)
1✔
69
                    .responseFormat(ResponseFormat.JSON)
1✔
70
                    .auth(this.auth)
1✔
71
                    .networkSession(this.networkSession)
1✔
72
                    .build());
1✔
73
    return JsonManager.deserialize(response.getData(), Tasks.class);
1✔
74
  }
75

76
  /**
77
   * Creates a single task on a file. This task is not assigned to any user and will need to be
78
   * assigned separately.
79
   *
80
   * @param requestBody Request body of createTask method
81
   */
82
  public Task createTask(CreateTaskRequestBody requestBody) {
83
    return createTask(requestBody, new CreateTaskHeaders());
1✔
84
  }
85

86
  /**
87
   * Creates a single task on a file. This task is not assigned to any user and will need to be
88
   * assigned separately.
89
   *
90
   * @param requestBody Request body of createTask method
91
   * @param headers Headers of createTask method
92
   */
93
  public Task createTask(CreateTaskRequestBody requestBody, CreateTaskHeaders headers) {
94
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
95
    FetchResponse response =
1✔
96
        this.networkSession
97
            .getNetworkClient()
1✔
98
            .fetch(
1✔
99
                new FetchOptions.Builder(
100
                        String.join(
1✔
101
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/tasks"),
1✔
102
                        "POST")
103
                    .headers(headersMap)
1✔
104
                    .data(JsonManager.serialize(requestBody))
1✔
105
                    .contentType("application/json")
1✔
106
                    .responseFormat(ResponseFormat.JSON)
1✔
107
                    .auth(this.auth)
1✔
108
                    .networkSession(this.networkSession)
1✔
109
                    .build());
1✔
110
    return JsonManager.deserialize(response.getData(), Task.class);
1✔
111
  }
112

113
  /**
114
   * Retrieves information about a specific task.
115
   *
116
   * @param taskId The ID of the task. Example: "12345"
117
   */
118
  public Task getTaskById(String taskId) {
119
    return getTaskById(taskId, new GetTaskByIdHeaders());
1✔
120
  }
121

122
  /**
123
   * Retrieves information about a specific task.
124
   *
125
   * @param taskId The ID of the task. Example: "12345"
126
   * @param headers Headers of getTaskById method
127
   */
128
  public Task getTaskById(String taskId, GetTaskByIdHeaders headers) {
129
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
130
    FetchResponse response =
1✔
131
        this.networkSession
132
            .getNetworkClient()
1✔
133
            .fetch(
1✔
134
                new FetchOptions.Builder(
135
                        String.join(
1✔
136
                            "",
137
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
138
                            "/2.0/tasks/",
139
                            convertToString(taskId)),
1✔
140
                        "GET")
141
                    .headers(headersMap)
1✔
142
                    .responseFormat(ResponseFormat.JSON)
1✔
143
                    .auth(this.auth)
1✔
144
                    .networkSession(this.networkSession)
1✔
145
                    .build());
1✔
146
    return JsonManager.deserialize(response.getData(), Task.class);
1✔
147
  }
148

149
  /**
150
   * Updates a task. This can be used to update a task's configuration, or to update its completion
151
   * state.
152
   *
153
   * @param taskId The ID of the task. Example: "12345"
154
   */
155
  public Task updateTaskById(String taskId) {
156
    return updateTaskById(taskId, new UpdateTaskByIdRequestBody(), new UpdateTaskByIdHeaders());
×
157
  }
158

159
  /**
160
   * Updates a task. This can be used to update a task's configuration, or to update its completion
161
   * state.
162
   *
163
   * @param taskId The ID of the task. Example: "12345"
164
   * @param requestBody Request body of updateTaskById method
165
   */
166
  public Task updateTaskById(String taskId, UpdateTaskByIdRequestBody requestBody) {
167
    return updateTaskById(taskId, requestBody, new UpdateTaskByIdHeaders());
1✔
168
  }
169

170
  /**
171
   * Updates a task. This can be used to update a task's configuration, or to update its completion
172
   * state.
173
   *
174
   * @param taskId The ID of the task. Example: "12345"
175
   * @param headers Headers of updateTaskById method
176
   */
177
  public Task updateTaskById(String taskId, UpdateTaskByIdHeaders headers) {
178
    return updateTaskById(taskId, new UpdateTaskByIdRequestBody(), headers);
×
179
  }
180

181
  /**
182
   * Updates a task. This can be used to update a task's configuration, or to update its completion
183
   * state.
184
   *
185
   * @param taskId The ID of the task. Example: "12345"
186
   * @param requestBody Request body of updateTaskById method
187
   * @param headers Headers of updateTaskById method
188
   */
189
  public Task updateTaskById(
190
      String taskId, UpdateTaskByIdRequestBody requestBody, UpdateTaskByIdHeaders headers) {
191
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
192
    FetchResponse response =
1✔
193
        this.networkSession
194
            .getNetworkClient()
1✔
195
            .fetch(
1✔
196
                new FetchOptions.Builder(
197
                        String.join(
1✔
198
                            "",
199
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
200
                            "/2.0/tasks/",
201
                            convertToString(taskId)),
1✔
202
                        "PUT")
203
                    .headers(headersMap)
1✔
204
                    .data(JsonManager.serialize(requestBody))
1✔
205
                    .contentType("application/json")
1✔
206
                    .responseFormat(ResponseFormat.JSON)
1✔
207
                    .auth(this.auth)
1✔
208
                    .networkSession(this.networkSession)
1✔
209
                    .build());
1✔
210
    return JsonManager.deserialize(response.getData(), Task.class);
1✔
211
  }
212

213
  /**
214
   * Removes a task from a file.
215
   *
216
   * @param taskId The ID of the task. Example: "12345"
217
   */
218
  public void deleteTaskById(String taskId) {
219
    deleteTaskById(taskId, new DeleteTaskByIdHeaders());
1✔
220
  }
1✔
221

222
  /**
223
   * Removes a task from a file.
224
   *
225
   * @param taskId The ID of the task. Example: "12345"
226
   * @param headers Headers of deleteTaskById method
227
   */
228
  public void deleteTaskById(String taskId, DeleteTaskByIdHeaders headers) {
229
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
230
    FetchResponse response =
1✔
231
        this.networkSession
232
            .getNetworkClient()
1✔
233
            .fetch(
1✔
234
                new FetchOptions.Builder(
235
                        String.join(
1✔
236
                            "",
237
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
238
                            "/2.0/tasks/",
239
                            convertToString(taskId)),
1✔
240
                        "DELETE")
241
                    .headers(headersMap)
1✔
242
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
243
                    .auth(this.auth)
1✔
244
                    .networkSession(this.networkSession)
1✔
245
                    .build());
1✔
246
  }
1✔
247

248
  public Authentication getAuth() {
249
    return auth;
×
250
  }
251

252
  public NetworkSession getNetworkSession() {
253
    return networkSession;
×
254
  }
255

256
  public static class Builder {
257

258
    protected Authentication auth;
259

260
    protected NetworkSession networkSession;
261

262
    public Builder() {
1✔
263
      this.networkSession = new NetworkSession();
1✔
264
    }
1✔
265

266
    public Builder auth(Authentication auth) {
267
      this.auth = auth;
1✔
268
      return this;
1✔
269
    }
270

271
    public Builder networkSession(NetworkSession networkSession) {
272
      this.networkSession = networkSession;
1✔
273
      return this;
1✔
274
    }
275

276
    public TasksManager build() {
277
      return new TasksManager(this);
1✔
278
    }
279
  }
280
}
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