• 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

15.79
/src/main/java/com/box/sdkgen/managers/collections/CollectionsManager.java
1
package com.box.sdkgen.managers.collections;
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.collection.Collection;
15
import com.box.sdkgen.schemas.collections.Collections;
16
import com.box.sdkgen.schemas.itemsoffsetpaginated.ItemsOffsetPaginated;
17
import com.box.sdkgen.serialization.json.JsonManager;
18
import java.util.Map;
19

20
public class CollectionsManager {
21

22
  public Authentication auth;
23

24
  public NetworkSession networkSession;
25

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

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

35
  /**
36
   * Retrieves all collections for a given user.
37
   *
38
   * <p>Currently, only the `favorites` collection is supported.
39
   */
40
  public Collections getCollections() {
41
    return getCollections(new GetCollectionsQueryParams(), new GetCollectionsHeaders());
×
42
  }
43

44
  /**
45
   * Retrieves all collections for a given user.
46
   *
47
   * <p>Currently, only the `favorites` collection is supported.
48
   *
49
   * @param queryParams Query parameters of getCollections method
50
   */
51
  public Collections getCollections(GetCollectionsQueryParams queryParams) {
52
    return getCollections(queryParams, new GetCollectionsHeaders());
×
53
  }
54

55
  /**
56
   * Retrieves all collections for a given user.
57
   *
58
   * <p>Currently, only the `favorites` collection is supported.
59
   *
60
   * @param headers Headers of getCollections method
61
   */
62
  public Collections getCollections(GetCollectionsHeaders headers) {
63
    return getCollections(new GetCollectionsQueryParams(), headers);
×
64
  }
65

66
  /**
67
   * Retrieves all collections for a given user.
68
   *
69
   * <p>Currently, only the `favorites` collection is supported.
70
   *
71
   * @param queryParams Query parameters of getCollections method
72
   * @param headers Headers of getCollections method
73
   */
74
  public Collections getCollections(
75
      GetCollectionsQueryParams queryParams, GetCollectionsHeaders headers) {
76
    Map<String, String> queryParamsMap =
×
77
        prepareParams(
×
78
            mapOf(
×
79
                entryOf("fields", convertToString(queryParams.getFields())),
×
80
                entryOf("offset", convertToString(queryParams.getOffset())),
×
81
                entryOf("limit", convertToString(queryParams.getLimit()))));
×
82
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
83
    FetchResponse response =
×
84
        this.networkSession
85
            .getNetworkClient()
×
86
            .fetch(
×
87
                new FetchOptions.Builder(
88
                        String.join(
×
89
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/collections"),
×
90
                        "GET")
91
                    .params(queryParamsMap)
×
92
                    .headers(headersMap)
×
93
                    .responseFormat(ResponseFormat.JSON)
×
94
                    .auth(this.auth)
×
95
                    .networkSession(this.networkSession)
×
96
                    .build());
×
97
    return JsonManager.deserialize(response.getData(), Collections.class);
×
98
  }
99

100
  /**
101
   * Retrieves the files and/or folders contained within this collection.
102
   *
103
   * @param collectionId The ID of the collection. Example: "926489"
104
   */
105
  public ItemsOffsetPaginated getCollectionItems(String collectionId) {
106
    return getCollectionItems(
×
107
        collectionId, new GetCollectionItemsQueryParams(), new GetCollectionItemsHeaders());
108
  }
109

110
  /**
111
   * Retrieves the files and/or folders contained within this collection.
112
   *
113
   * @param collectionId The ID of the collection. Example: "926489"
114
   * @param queryParams Query parameters of getCollectionItems method
115
   */
116
  public ItemsOffsetPaginated getCollectionItems(
117
      String collectionId, GetCollectionItemsQueryParams queryParams) {
118
    return getCollectionItems(collectionId, queryParams, new GetCollectionItemsHeaders());
×
119
  }
120

121
  /**
122
   * Retrieves the files and/or folders contained within this collection.
123
   *
124
   * @param collectionId The ID of the collection. Example: "926489"
125
   * @param headers Headers of getCollectionItems method
126
   */
127
  public ItemsOffsetPaginated getCollectionItems(
128
      String collectionId, GetCollectionItemsHeaders headers) {
129
    return getCollectionItems(collectionId, new GetCollectionItemsQueryParams(), headers);
×
130
  }
131

132
  /**
133
   * Retrieves the files and/or folders contained within this collection.
134
   *
135
   * @param collectionId The ID of the collection. Example: "926489"
136
   * @param queryParams Query parameters of getCollectionItems method
137
   * @param headers Headers of getCollectionItems method
138
   */
139
  public ItemsOffsetPaginated getCollectionItems(
140
      String collectionId,
141
      GetCollectionItemsQueryParams queryParams,
142
      GetCollectionItemsHeaders headers) {
143
    Map<String, String> queryParamsMap =
×
144
        prepareParams(
×
145
            mapOf(
×
146
                entryOf("fields", convertToString(queryParams.getFields())),
×
147
                entryOf("offset", convertToString(queryParams.getOffset())),
×
148
                entryOf("limit", convertToString(queryParams.getLimit()))));
×
149
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
150
    FetchResponse response =
×
151
        this.networkSession
152
            .getNetworkClient()
×
153
            .fetch(
×
154
                new FetchOptions.Builder(
155
                        String.join(
×
156
                            "",
157
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
158
                            "/2.0/collections/",
159
                            convertToString(collectionId),
×
160
                            "/items"),
161
                        "GET")
162
                    .params(queryParamsMap)
×
163
                    .headers(headersMap)
×
164
                    .responseFormat(ResponseFormat.JSON)
×
165
                    .auth(this.auth)
×
166
                    .networkSession(this.networkSession)
×
167
                    .build());
×
168
    return JsonManager.deserialize(response.getData(), ItemsOffsetPaginated.class);
×
169
  }
170

171
  /**
172
   * Retrieves a collection by its ID.
173
   *
174
   * @param collectionId The ID of the collection. Example: "926489"
175
   */
176
  public Collection getCollectionById(String collectionId) {
177
    return getCollectionById(collectionId, new GetCollectionByIdHeaders());
×
178
  }
179

180
  /**
181
   * Retrieves a collection by its ID.
182
   *
183
   * @param collectionId The ID of the collection. Example: "926489"
184
   * @param headers Headers of getCollectionById method
185
   */
186
  public Collection getCollectionById(String collectionId, GetCollectionByIdHeaders headers) {
187
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
188
    FetchResponse response =
×
189
        this.networkSession
190
            .getNetworkClient()
×
191
            .fetch(
×
192
                new FetchOptions.Builder(
193
                        String.join(
×
194
                            "",
195
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
196
                            "/2.0/collections/",
197
                            convertToString(collectionId)),
×
198
                        "GET")
199
                    .headers(headersMap)
×
200
                    .responseFormat(ResponseFormat.JSON)
×
201
                    .auth(this.auth)
×
202
                    .networkSession(this.networkSession)
×
203
                    .build());
×
204
    return JsonManager.deserialize(response.getData(), Collection.class);
×
205
  }
206

207
  public Authentication getAuth() {
208
    return auth;
×
209
  }
210

211
  public NetworkSession getNetworkSession() {
212
    return networkSession;
×
213
  }
214

215
  public static class Builder {
216

217
    protected Authentication auth;
218

219
    protected NetworkSession networkSession;
220

221
    public Builder() {
1✔
222
      this.networkSession = new NetworkSession();
1✔
223
    }
1✔
224

225
    public Builder auth(Authentication auth) {
226
      this.auth = auth;
1✔
227
      return this;
1✔
228
    }
229

230
    public Builder networkSession(NetworkSession networkSession) {
231
      this.networkSession = networkSession;
1✔
232
      return this;
1✔
233
    }
234

235
    public CollectionsManager build() {
236
      return new CollectionsManager(this);
1✔
237
    }
238
  }
239
}
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