• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #6243

10 Feb 2026 05:27PM UTC coverage: 18.192% (-17.5%) from 35.714%
#6243

push

github

web-flow
fix(boxsdkgen): Move assigning default values from builder constructor to `build()` method (box/box-codegen#922) (#1712)

0 of 1677 new or added lines in 569 files covered. (0.0%)

2147 existing lines in 545 files now uncovered.

7388 of 40611 relevant lines covered (18.19%)

0.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/box/sdkgen/managers/search/SearchManager.java
1
package com.box.sdkgen.managers.search;
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.metadataquery.MetadataQuery;
15
import com.box.sdkgen.schemas.metadataqueryresults.MetadataQueryResults;
16
import com.box.sdkgen.schemas.searchresultsresponse.SearchResultsResponse;
17
import com.box.sdkgen.serialization.json.JsonManager;
18
import java.util.Map;
19

20
public class SearchManager {
21

22
  public Authentication auth;
23

24
  public NetworkSession networkSession;
25

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

30
  protected SearchManager(Builder builder) {
×
31
    this.auth = builder.auth;
×
32
    this.networkSession = builder.networkSession;
×
33
  }
×
34

35
  /**
36
   * Create a search using SQL-like syntax to return items that match specific metadata.
37
   *
38
   * <p>By default, this endpoint returns only the most basic info about the items for which the
39
   * query matches. To get additional fields for each item, including any of the metadata, use the
40
   * `fields` attribute in the query.
41
   *
42
   * @param requestBody Request body of searchByMetadataQuery method
43
   */
44
  public MetadataQueryResults searchByMetadataQuery(MetadataQuery requestBody) {
45
    return searchByMetadataQuery(requestBody, new SearchByMetadataQueryHeaders());
×
46
  }
47

48
  /**
49
   * Create a search using SQL-like syntax to return items that match specific metadata.
50
   *
51
   * <p>By default, this endpoint returns only the most basic info about the items for which the
52
   * query matches. To get additional fields for each item, including any of the metadata, use the
53
   * `fields` attribute in the query.
54
   *
55
   * @param requestBody Request body of searchByMetadataQuery method
56
   * @param headers Headers of searchByMetadataQuery method
57
   */
58
  public MetadataQueryResults searchByMetadataQuery(
59
      MetadataQuery requestBody, SearchByMetadataQueryHeaders headers) {
60
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
61
    FetchResponse response =
×
62
        this.networkSession
63
            .getNetworkClient()
×
64
            .fetch(
×
65
                new FetchOptions.Builder(
66
                        String.join(
×
67
                            "",
68
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
69
                            "/2.0/metadata_queries/execute_read"),
70
                        "POST")
71
                    .headers(headersMap)
×
72
                    .data(JsonManager.serialize(requestBody))
×
73
                    .contentType("application/json")
×
74
                    .responseFormat(ResponseFormat.JSON)
×
75
                    .auth(this.auth)
×
76
                    .networkSession(this.networkSession)
×
77
                    .build());
×
78
    return JsonManager.deserialize(response.getData(), MetadataQueryResults.class);
×
79
  }
80

81
  /**
82
   * Searches for files, folders, web links, and shared files across the users content or across the
83
   * entire enterprise.
84
   */
85
  public SearchResultsResponse searchForContent() {
86
    return searchForContent(new SearchForContentQueryParams(), new SearchForContentHeaders());
×
87
  }
88

89
  /**
90
   * Searches for files, folders, web links, and shared files across the users content or across the
91
   * entire enterprise.
92
   *
93
   * @param queryParams Query parameters of searchForContent method
94
   */
95
  public SearchResultsResponse searchForContent(SearchForContentQueryParams queryParams) {
96
    return searchForContent(queryParams, new SearchForContentHeaders());
×
97
  }
98

99
  /**
100
   * Searches for files, folders, web links, and shared files across the users content or across the
101
   * entire enterprise.
102
   *
103
   * @param headers Headers of searchForContent method
104
   */
105
  public SearchResultsResponse searchForContent(SearchForContentHeaders headers) {
106
    return searchForContent(new SearchForContentQueryParams(), headers);
×
107
  }
108

109
  /**
110
   * Searches for files, folders, web links, and shared files across the users content or across the
111
   * entire enterprise.
112
   *
113
   * @param queryParams Query parameters of searchForContent method
114
   * @param headers Headers of searchForContent method
115
   */
116
  public SearchResultsResponse searchForContent(
117
      SearchForContentQueryParams queryParams, SearchForContentHeaders headers) {
118
    Map<String, String> queryParamsMap =
×
119
        prepareParams(
×
120
            mapOf(
×
121
                entryOf("query", convertToString(queryParams.getQuery())),
×
122
                entryOf("scope", convertToString(queryParams.getScope())),
×
123
                entryOf("file_extensions", convertToString(queryParams.getFileExtensions())),
×
124
                entryOf("created_at_range", convertToString(queryParams.getCreatedAtRange())),
×
125
                entryOf("updated_at_range", convertToString(queryParams.getUpdatedAtRange())),
×
126
                entryOf("size_range", convertToString(queryParams.getSizeRange())),
×
127
                entryOf("owner_user_ids", convertToString(queryParams.getOwnerUserIds())),
×
128
                entryOf(
×
129
                    "recent_updater_user_ids",
130
                    convertToString(queryParams.getRecentUpdaterUserIds())),
×
131
                entryOf("ancestor_folder_ids", convertToString(queryParams.getAncestorFolderIds())),
×
132
                entryOf("content_types", convertToString(queryParams.getContentTypes())),
×
133
                entryOf("type", convertToString(queryParams.getType())),
×
134
                entryOf("trash_content", convertToString(queryParams.getTrashContent())),
×
135
                entryOf("mdfilters", convertToString(queryParams.getMdfilters())),
×
136
                entryOf("sort", convertToString(queryParams.getSort())),
×
137
                entryOf("direction", convertToString(queryParams.getDirection())),
×
138
                entryOf("limit", convertToString(queryParams.getLimit())),
×
139
                entryOf(
×
140
                    "include_recent_shared_links",
141
                    convertToString(queryParams.getIncludeRecentSharedLinks())),
×
142
                entryOf("fields", convertToString(queryParams.getFields())),
×
143
                entryOf("offset", convertToString(queryParams.getOffset())),
×
144
                entryOf("deleted_user_ids", convertToString(queryParams.getDeletedUserIds())),
×
145
                entryOf("deleted_at_range", convertToString(queryParams.getDeletedAtRange()))));
×
146
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
147
    FetchResponse response =
×
148
        this.networkSession
149
            .getNetworkClient()
×
150
            .fetch(
×
151
                new FetchOptions.Builder(
152
                        String.join(
×
153
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/search"),
×
154
                        "GET")
155
                    .params(queryParamsMap)
×
156
                    .headers(headersMap)
×
157
                    .responseFormat(ResponseFormat.JSON)
×
158
                    .auth(this.auth)
×
159
                    .networkSession(this.networkSession)
×
160
                    .build());
×
161
    return JsonManager.deserialize(response.getData(), SearchResultsResponse.class);
×
162
  }
163

164
  public Authentication getAuth() {
165
    return auth;
×
166
  }
167

168
  public NetworkSession getNetworkSession() {
169
    return networkSession;
×
170
  }
171

172
  public static class Builder {
173

174
    protected Authentication auth;
175

176
    protected NetworkSession networkSession;
177

NEW
178
    public Builder() {}
×
179

180
    public Builder auth(Authentication auth) {
UNCOV
181
      this.auth = auth;
×
UNCOV
182
      return this;
×
183
    }
184

185
    public Builder networkSession(NetworkSession networkSession) {
UNCOV
186
      this.networkSession = networkSession;
×
UNCOV
187
      return this;
×
188
    }
189

190
    public SearchManager build() {
NEW
191
      if (this.networkSession == null) {
×
NEW
192
        this.networkSession = new NetworkSession();
×
193
      }
194
      return new SearchManager(this);
×
195
    }
196
  }
197
}
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