• 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

90.54
/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) {
1✔
31
    this.auth = builder.auth;
1✔
32
    this.networkSession = builder.networkSession;
1✔
33
  }
1✔
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());
1✔
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()));
1✔
61
    FetchResponse response =
1✔
62
        this.networkSession
63
            .getNetworkClient()
1✔
64
            .fetch(
1✔
65
                new FetchOptions.Builder(
66
                        String.join(
1✔
67
                            "",
68
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
69
                            "/2.0/metadata_queries/execute_read"),
70
                        "POST")
71
                    .headers(headersMap)
1✔
72
                    .data(JsonManager.serialize(requestBody))
1✔
73
                    .contentType("application/json")
1✔
74
                    .responseFormat(ResponseFormat.JSON)
1✔
75
                    .auth(this.auth)
1✔
76
                    .networkSession(this.networkSession)
1✔
77
                    .build());
1✔
78
    return JsonManager.deserialize(response.getData(), MetadataQueryResults.class);
1✔
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());
1✔
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 =
1✔
119
        prepareParams(
1✔
120
            mapOf(
1✔
121
                entryOf("query", convertToString(queryParams.getQuery())),
1✔
122
                entryOf("scope", convertToString(queryParams.getScope())),
1✔
123
                entryOf("file_extensions", convertToString(queryParams.getFileExtensions())),
1✔
124
                entryOf("created_at_range", convertToString(queryParams.getCreatedAtRange())),
1✔
125
                entryOf("updated_at_range", convertToString(queryParams.getUpdatedAtRange())),
1✔
126
                entryOf("size_range", convertToString(queryParams.getSizeRange())),
1✔
127
                entryOf("owner_user_ids", convertToString(queryParams.getOwnerUserIds())),
1✔
128
                entryOf(
1✔
129
                    "recent_updater_user_ids",
130
                    convertToString(queryParams.getRecentUpdaterUserIds())),
1✔
131
                entryOf("ancestor_folder_ids", convertToString(queryParams.getAncestorFolderIds())),
1✔
132
                entryOf("content_types", convertToString(queryParams.getContentTypes())),
1✔
133
                entryOf("type", convertToString(queryParams.getType())),
1✔
134
                entryOf("trash_content", convertToString(queryParams.getTrashContent())),
1✔
135
                entryOf("mdfilters", convertToString(queryParams.getMdfilters())),
1✔
136
                entryOf("sort", convertToString(queryParams.getSort())),
1✔
137
                entryOf("direction", convertToString(queryParams.getDirection())),
1✔
138
                entryOf("limit", convertToString(queryParams.getLimit())),
1✔
139
                entryOf(
1✔
140
                    "include_recent_shared_links",
141
                    convertToString(queryParams.getIncludeRecentSharedLinks())),
1✔
142
                entryOf("fields", convertToString(queryParams.getFields())),
1✔
143
                entryOf("offset", convertToString(queryParams.getOffset())),
1✔
144
                entryOf("deleted_user_ids", convertToString(queryParams.getDeletedUserIds())),
1✔
145
                entryOf("deleted_at_range", convertToString(queryParams.getDeletedAtRange()))));
1✔
146
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
147
    FetchResponse response =
1✔
148
        this.networkSession
149
            .getNetworkClient()
1✔
150
            .fetch(
1✔
151
                new FetchOptions.Builder(
152
                        String.join(
1✔
153
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/search"),
1✔
154
                        "GET")
155
                    .params(queryParamsMap)
1✔
156
                    .headers(headersMap)
1✔
157
                    .responseFormat(ResponseFormat.JSON)
1✔
158
                    .auth(this.auth)
1✔
159
                    .networkSession(this.networkSession)
1✔
160
                    .build());
1✔
161
    return JsonManager.deserialize(response.getData(), SearchResultsResponse.class);
1✔
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

178
    public Builder() {
1✔
179
      this.networkSession = new NetworkSession();
1✔
180
    }
1✔
181

182
    public Builder auth(Authentication auth) {
183
      this.auth = auth;
1✔
184
      return this;
1✔
185
    }
186

187
    public Builder networkSession(NetworkSession networkSession) {
188
      this.networkSession = networkSession;
1✔
189
      return this;
1✔
190
    }
191

192
    public SearchManager build() {
193
      return new SearchManager(this);
1✔
194
    }
195
  }
196
}
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