• 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.94
/src/main/java/com/box/sdkgen/managers/filewatermarks/FileWatermarksManager.java
1
package com.box.sdkgen.managers.filewatermarks;
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.watermark.Watermark;
14
import com.box.sdkgen.serialization.json.JsonManager;
15
import java.util.Map;
16

17
public class FileWatermarksManager {
18

19
  public Authentication auth;
20

21
  public NetworkSession networkSession;
22

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

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

32
  /**
33
   * Retrieve the watermark for a file.
34
   *
35
   * @param fileId The unique identifier that represents a file.
36
   *     <p>The ID for any file can be determined by visiting a file in the web application and
37
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
38
   *     `file_id` is `123`. Example: "12345"
39
   */
40
  public Watermark getFileWatermark(String fileId) {
41
    return getFileWatermark(fileId, new GetFileWatermarkHeaders());
1✔
42
  }
43

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

75
  /**
76
   * Applies or update a watermark on a file.
77
   *
78
   * @param fileId The unique identifier that represents a file.
79
   *     <p>The ID for any file can be determined by visiting a file in the web application and
80
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
81
   *     `file_id` is `123`. Example: "12345"
82
   * @param requestBody Request body of updateFileWatermark method
83
   */
84
  public Watermark updateFileWatermark(String fileId, UpdateFileWatermarkRequestBody requestBody) {
85
    return updateFileWatermark(fileId, requestBody, new UpdateFileWatermarkHeaders());
1✔
86
  }
87

88
  /**
89
   * Applies or update a watermark on a file.
90
   *
91
   * @param fileId The unique identifier that represents a file.
92
   *     <p>The ID for any file can be determined by visiting a file in the web application and
93
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
94
   *     `file_id` is `123`. Example: "12345"
95
   * @param requestBody Request body of updateFileWatermark method
96
   * @param headers Headers of updateFileWatermark method
97
   */
98
  public Watermark updateFileWatermark(
99
      String fileId,
100
      UpdateFileWatermarkRequestBody requestBody,
101
      UpdateFileWatermarkHeaders headers) {
102
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
103
    FetchResponse response =
1✔
104
        this.networkSession
105
            .getNetworkClient()
1✔
106
            .fetch(
1✔
107
                new FetchOptions.Builder(
108
                        String.join(
1✔
109
                            "",
110
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
111
                            "/2.0/files/",
112
                            convertToString(fileId),
1✔
113
                            "/watermark"),
114
                        "PUT")
115
                    .headers(headersMap)
1✔
116
                    .data(JsonManager.serialize(requestBody))
1✔
117
                    .contentType("application/json")
1✔
118
                    .responseFormat(ResponseFormat.JSON)
1✔
119
                    .auth(this.auth)
1✔
120
                    .networkSession(this.networkSession)
1✔
121
                    .build());
1✔
122
    return JsonManager.deserialize(response.getData(), Watermark.class);
1✔
123
  }
124

125
  /**
126
   * Removes the watermark from a file.
127
   *
128
   * @param fileId The unique identifier that represents a file.
129
   *     <p>The ID for any file can be determined by visiting a file in the web application and
130
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
131
   *     `file_id` is `123`. Example: "12345"
132
   */
133
  public void deleteFileWatermark(String fileId) {
134
    deleteFileWatermark(fileId, new DeleteFileWatermarkHeaders());
1✔
135
  }
1✔
136

137
  /**
138
   * Removes the watermark from a file.
139
   *
140
   * @param fileId The unique identifier that represents a file.
141
   *     <p>The ID for any file can be determined by visiting a file in the web application and
142
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
143
   *     `file_id` is `123`. Example: "12345"
144
   * @param headers Headers of deleteFileWatermark method
145
   */
146
  public void deleteFileWatermark(String fileId, DeleteFileWatermarkHeaders headers) {
147
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
148
    FetchResponse response =
1✔
149
        this.networkSession
150
            .getNetworkClient()
1✔
151
            .fetch(
1✔
152
                new FetchOptions.Builder(
153
                        String.join(
1✔
154
                            "",
155
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
156
                            "/2.0/files/",
157
                            convertToString(fileId),
1✔
158
                            "/watermark"),
159
                        "DELETE")
160
                    .headers(headersMap)
1✔
161
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
162
                    .auth(this.auth)
1✔
163
                    .networkSession(this.networkSession)
1✔
164
                    .build());
1✔
165
  }
1✔
166

167
  public Authentication getAuth() {
168
    return auth;
×
169
  }
170

171
  public NetworkSession getNetworkSession() {
172
    return networkSession;
×
173
  }
174

175
  public static class Builder {
176

177
    protected Authentication auth;
178

179
    protected NetworkSession networkSession;
180

181
    public Builder() {
1✔
182
      this.networkSession = new NetworkSession();
1✔
183
    }
1✔
184

185
    public Builder auth(Authentication auth) {
186
      this.auth = auth;
1✔
187
      return this;
1✔
188
    }
189

190
    public Builder networkSession(NetworkSession networkSession) {
191
      this.networkSession = networkSession;
1✔
192
      return this;
1✔
193
    }
194

195
    public FileWatermarksManager build() {
196
      return new FileWatermarksManager(this);
1✔
197
    }
198
  }
199
}
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