• 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

91.25
/src/main/java/com/box/sdkgen/managers/fileclassifications/FileClassificationsManager.java
1
package com.box.sdkgen.managers.fileclassifications;
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.classification.Classification;
14
import com.box.sdkgen.serialization.json.JsonManager;
15
import java.util.List;
16
import java.util.Map;
17

18
public class FileClassificationsManager {
19

20
  public Authentication auth;
21

22
  public NetworkSession networkSession;
23

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

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

33
  /**
34
   * Retrieves the classification metadata instance that has been applied to a file.
35
   *
36
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
37
   * example `/files/:id//enterprise_12345/securityClassification-6VMVochwUWo`.
38
   *
39
   * @param fileId The unique identifier that represents a file.
40
   *     <p>The ID for any file can be determined by visiting a file in the web application and
41
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
42
   *     `file_id` is `123`. Example: "12345"
43
   */
44
  public Classification getClassificationOnFile(String fileId) {
45
    return getClassificationOnFile(fileId, new GetClassificationOnFileHeaders());
1✔
46
  }
47

48
  /**
49
   * Retrieves the classification metadata instance that has been applied to a file.
50
   *
51
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
52
   * example `/files/:id//enterprise_12345/securityClassification-6VMVochwUWo`.
53
   *
54
   * @param fileId The unique identifier that represents a file.
55
   *     <p>The ID for any file can be determined by visiting a file in the web application and
56
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
57
   *     `file_id` is `123`. Example: "12345"
58
   * @param headers Headers of getClassificationOnFile method
59
   */
60
  public Classification getClassificationOnFile(
61
      String fileId, GetClassificationOnFileHeaders headers) {
62
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
63
    FetchResponse response =
1✔
64
        this.networkSession
65
            .getNetworkClient()
1✔
66
            .fetch(
1✔
67
                new FetchOptions.Builder(
68
                        String.join(
1✔
69
                            "",
70
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
71
                            "/2.0/files/",
72
                            convertToString(fileId),
1✔
73
                            "/metadata/enterprise/securityClassification-6VMVochwUWo"),
74
                        "GET")
75
                    .headers(headersMap)
1✔
76
                    .responseFormat(ResponseFormat.JSON)
1✔
77
                    .auth(this.auth)
1✔
78
                    .networkSession(this.networkSession)
1✔
79
                    .build());
1✔
80
    return JsonManager.deserialize(response.getData(), Classification.class);
1✔
81
  }
82

83
  /**
84
   * Adds a classification to a file by specifying the label of the classification to add.
85
   *
86
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
87
   * example `/files/:id//enterprise_12345/securityClassification-6VMVochwUWo`.
88
   *
89
   * @param fileId The unique identifier that represents a file.
90
   *     <p>The ID for any file can be determined by visiting a file in the web application and
91
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
92
   *     `file_id` is `123`. Example: "12345"
93
   */
94
  public Classification addClassificationToFile(String fileId) {
95
    return addClassificationToFile(
×
96
        fileId, new AddClassificationToFileRequestBody(), new AddClassificationToFileHeaders());
97
  }
98

99
  /**
100
   * Adds a classification to a file by specifying the label of the classification to add.
101
   *
102
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
103
   * example `/files/:id//enterprise_12345/securityClassification-6VMVochwUWo`.
104
   *
105
   * @param fileId The unique identifier that represents a file.
106
   *     <p>The ID for any file can be determined by visiting a file in the web application and
107
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
108
   *     `file_id` is `123`. Example: "12345"
109
   * @param requestBody Request body of addClassificationToFile method
110
   */
111
  public Classification addClassificationToFile(
112
      String fileId, AddClassificationToFileRequestBody requestBody) {
113
    return addClassificationToFile(fileId, requestBody, new AddClassificationToFileHeaders());
1✔
114
  }
115

116
  /**
117
   * Adds a classification to a file by specifying the label of the classification to add.
118
   *
119
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
120
   * example `/files/:id//enterprise_12345/securityClassification-6VMVochwUWo`.
121
   *
122
   * @param fileId The unique identifier that represents a file.
123
   *     <p>The ID for any file can be determined by visiting a file in the web application and
124
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
125
   *     `file_id` is `123`. Example: "12345"
126
   * @param headers Headers of addClassificationToFile method
127
   */
128
  public Classification addClassificationToFile(
129
      String fileId, AddClassificationToFileHeaders headers) {
130
    return addClassificationToFile(fileId, new AddClassificationToFileRequestBody(), headers);
×
131
  }
132

133
  /**
134
   * Adds a classification to a file by specifying the label of the classification to add.
135
   *
136
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
137
   * example `/files/:id//enterprise_12345/securityClassification-6VMVochwUWo`.
138
   *
139
   * @param fileId The unique identifier that represents a file.
140
   *     <p>The ID for any file can be determined by visiting a file in the web application and
141
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
142
   *     `file_id` is `123`. Example: "12345"
143
   * @param requestBody Request body of addClassificationToFile method
144
   * @param headers Headers of addClassificationToFile method
145
   */
146
  public Classification addClassificationToFile(
147
      String fileId,
148
      AddClassificationToFileRequestBody requestBody,
149
      AddClassificationToFileHeaders headers) {
150
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
151
    FetchResponse response =
1✔
152
        this.networkSession
153
            .getNetworkClient()
1✔
154
            .fetch(
1✔
155
                new FetchOptions.Builder(
156
                        String.join(
1✔
157
                            "",
158
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
159
                            "/2.0/files/",
160
                            convertToString(fileId),
1✔
161
                            "/metadata/enterprise/securityClassification-6VMVochwUWo"),
162
                        "POST")
163
                    .headers(headersMap)
1✔
164
                    .data(JsonManager.serialize(requestBody))
1✔
165
                    .contentType("application/json")
1✔
166
                    .responseFormat(ResponseFormat.JSON)
1✔
167
                    .auth(this.auth)
1✔
168
                    .networkSession(this.networkSession)
1✔
169
                    .build());
1✔
170
    return JsonManager.deserialize(response.getData(), Classification.class);
1✔
171
  }
172

173
  /**
174
   * Updates a classification on a file.
175
   *
176
   * <p>The classification can only be updated if a classification has already been applied to the
177
   * file before. When editing classifications, only values are defined for the enterprise will be
178
   * accepted.
179
   *
180
   * @param fileId The unique identifier that represents a file.
181
   *     <p>The ID for any file can be determined by visiting a file in the web application and
182
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
183
   *     `file_id` is `123`. Example: "12345"
184
   * @param requestBody Request body of updateClassificationOnFile method
185
   */
186
  public Classification updateClassificationOnFile(
187
      String fileId, List<UpdateClassificationOnFileRequestBody> requestBody) {
188
    return updateClassificationOnFile(fileId, requestBody, new UpdateClassificationOnFileHeaders());
1✔
189
  }
190

191
  /**
192
   * Updates a classification on a file.
193
   *
194
   * <p>The classification can only be updated if a classification has already been applied to the
195
   * file before. When editing classifications, only values are defined for the enterprise will be
196
   * accepted.
197
   *
198
   * @param fileId The unique identifier that represents a file.
199
   *     <p>The ID for any file can be determined by visiting a file in the web application and
200
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
201
   *     `file_id` is `123`. Example: "12345"
202
   * @param requestBody Request body of updateClassificationOnFile method
203
   * @param headers Headers of updateClassificationOnFile method
204
   */
205
  public Classification updateClassificationOnFile(
206
      String fileId,
207
      List<UpdateClassificationOnFileRequestBody> requestBody,
208
      UpdateClassificationOnFileHeaders headers) {
209
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
210
    FetchResponse response =
1✔
211
        this.networkSession
212
            .getNetworkClient()
1✔
213
            .fetch(
1✔
214
                new FetchOptions.Builder(
215
                        String.join(
1✔
216
                            "",
217
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
218
                            "/2.0/files/",
219
                            convertToString(fileId),
1✔
220
                            "/metadata/enterprise/securityClassification-6VMVochwUWo"),
221
                        "PUT")
222
                    .headers(headersMap)
1✔
223
                    .data(JsonManager.serialize(requestBody))
1✔
224
                    .contentType("application/json-patch+json")
1✔
225
                    .responseFormat(ResponseFormat.JSON)
1✔
226
                    .auth(this.auth)
1✔
227
                    .networkSession(this.networkSession)
1✔
228
                    .build());
1✔
229
    return JsonManager.deserialize(response.getData(), Classification.class);
1✔
230
  }
231

232
  /**
233
   * Removes any classifications from a file.
234
   *
235
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
236
   * example `/files/:id//enterprise_12345/securityClassification-6VMVochwUWo`.
237
   *
238
   * @param fileId The unique identifier that represents a file.
239
   *     <p>The ID for any file can be determined by visiting a file in the web application and
240
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
241
   *     `file_id` is `123`. Example: "12345"
242
   */
243
  public void deleteClassificationFromFile(String fileId) {
244
    deleteClassificationFromFile(fileId, new DeleteClassificationFromFileHeaders());
1✔
245
  }
1✔
246

247
  /**
248
   * Removes any classifications from a file.
249
   *
250
   * <p>This API can also be called by including the enterprise ID in the URL explicitly, for
251
   * example `/files/:id//enterprise_12345/securityClassification-6VMVochwUWo`.
252
   *
253
   * @param fileId The unique identifier that represents a file.
254
   *     <p>The ID for any file can be determined by visiting a file in the web application and
255
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
256
   *     `file_id` is `123`. Example: "12345"
257
   * @param headers Headers of deleteClassificationFromFile method
258
   */
259
  public void deleteClassificationFromFile(
260
      String fileId, DeleteClassificationFromFileHeaders headers) {
261
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
262
    FetchResponse response =
1✔
263
        this.networkSession
264
            .getNetworkClient()
1✔
265
            .fetch(
1✔
266
                new FetchOptions.Builder(
267
                        String.join(
1✔
268
                            "",
269
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
270
                            "/2.0/files/",
271
                            convertToString(fileId),
1✔
272
                            "/metadata/enterprise/securityClassification-6VMVochwUWo"),
273
                        "DELETE")
274
                    .headers(headersMap)
1✔
275
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
276
                    .auth(this.auth)
1✔
277
                    .networkSession(this.networkSession)
1✔
278
                    .build());
1✔
279
  }
1✔
280

281
  public Authentication getAuth() {
282
    return auth;
×
283
  }
284

285
  public NetworkSession getNetworkSession() {
286
    return networkSession;
×
287
  }
288

289
  public static class Builder {
290

291
    protected Authentication auth;
292

293
    protected NetworkSession networkSession;
294

295
    public Builder() {
1✔
296
      this.networkSession = new NetworkSession();
1✔
297
    }
1✔
298

299
    public Builder auth(Authentication auth) {
300
      this.auth = auth;
1✔
301
      return this;
1✔
302
    }
303

304
    public Builder networkSession(NetworkSession networkSession) {
305
      this.networkSession = networkSession;
1✔
306
      return this;
1✔
307
    }
308

309
    public FileClassificationsManager build() {
310
      return new FileClassificationsManager(this);
1✔
311
    }
312
  }
313
}
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