• 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

92.06
/src/main/java/com/box/sdkgen/managers/emailaliases/EmailAliasesManager.java
1
package com.box.sdkgen.managers.emailaliases;
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.emailalias.EmailAlias;
14
import com.box.sdkgen.schemas.emailaliases.EmailAliases;
15
import com.box.sdkgen.serialization.json.JsonManager;
16
import java.util.Map;
17

18
public class EmailAliasesManager {
19

20
  public Authentication auth;
21

22
  public NetworkSession networkSession;
23

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

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

33
  /**
34
   * Retrieves all email aliases for a user. The collection does not include the primary login for
35
   * the user.
36
   *
37
   * @param userId The ID of the user. Example: "12345"
38
   */
39
  public EmailAliases getUserEmailAliases(String userId) {
40
    return getUserEmailAliases(userId, new GetUserEmailAliasesHeaders());
1✔
41
  }
42

43
  /**
44
   * Retrieves all email aliases for a user. The collection does not include the primary login for
45
   * the user.
46
   *
47
   * @param userId The ID of the user. Example: "12345"
48
   * @param headers Headers of getUserEmailAliases method
49
   */
50
  public EmailAliases getUserEmailAliases(String userId, GetUserEmailAliasesHeaders headers) {
51
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
52
    FetchResponse response =
1✔
53
        this.networkSession
54
            .getNetworkClient()
1✔
55
            .fetch(
1✔
56
                new FetchOptions.Builder(
57
                        String.join(
1✔
58
                            "",
59
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
60
                            "/2.0/users/",
61
                            convertToString(userId),
1✔
62
                            "/email_aliases"),
63
                        "GET")
64
                    .headers(headersMap)
1✔
65
                    .responseFormat(ResponseFormat.JSON)
1✔
66
                    .auth(this.auth)
1✔
67
                    .networkSession(this.networkSession)
1✔
68
                    .build());
1✔
69
    return JsonManager.deserialize(response.getData(), EmailAliases.class);
1✔
70
  }
71

72
  /**
73
   * Adds a new email alias to a user account..
74
   *
75
   * @param userId The ID of the user. Example: "12345"
76
   * @param requestBody Request body of createUserEmailAlias method
77
   */
78
  public EmailAlias createUserEmailAlias(
79
      String userId, CreateUserEmailAliasRequestBody requestBody) {
80
    return createUserEmailAlias(userId, requestBody, new CreateUserEmailAliasHeaders());
1✔
81
  }
82

83
  /**
84
   * Adds a new email alias to a user account..
85
   *
86
   * @param userId The ID of the user. Example: "12345"
87
   * @param requestBody Request body of createUserEmailAlias method
88
   * @param headers Headers of createUserEmailAlias method
89
   */
90
  public EmailAlias createUserEmailAlias(
91
      String userId,
92
      CreateUserEmailAliasRequestBody requestBody,
93
      CreateUserEmailAliasHeaders headers) {
94
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
95
    FetchResponse response =
1✔
96
        this.networkSession
97
            .getNetworkClient()
1✔
98
            .fetch(
1✔
99
                new FetchOptions.Builder(
100
                        String.join(
1✔
101
                            "",
102
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
103
                            "/2.0/users/",
104
                            convertToString(userId),
1✔
105
                            "/email_aliases"),
106
                        "POST")
107
                    .headers(headersMap)
1✔
108
                    .data(JsonManager.serialize(requestBody))
1✔
109
                    .contentType("application/json")
1✔
110
                    .responseFormat(ResponseFormat.JSON)
1✔
111
                    .auth(this.auth)
1✔
112
                    .networkSession(this.networkSession)
1✔
113
                    .build());
1✔
114
    return JsonManager.deserialize(response.getData(), EmailAlias.class);
1✔
115
  }
116

117
  /**
118
   * Removes an email alias from a user.
119
   *
120
   * @param userId The ID of the user. Example: "12345"
121
   * @param emailAliasId The ID of the email alias. Example: "23432"
122
   */
123
  public void deleteUserEmailAliasById(String userId, String emailAliasId) {
124
    deleteUserEmailAliasById(userId, emailAliasId, new DeleteUserEmailAliasByIdHeaders());
1✔
125
  }
1✔
126

127
  /**
128
   * Removes an email alias from a user.
129
   *
130
   * @param userId The ID of the user. Example: "12345"
131
   * @param emailAliasId The ID of the email alias. Example: "23432"
132
   * @param headers Headers of deleteUserEmailAliasById method
133
   */
134
  public void deleteUserEmailAliasById(
135
      String userId, String emailAliasId, DeleteUserEmailAliasByIdHeaders headers) {
136
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
137
    FetchResponse response =
1✔
138
        this.networkSession
139
            .getNetworkClient()
1✔
140
            .fetch(
1✔
141
                new FetchOptions.Builder(
142
                        String.join(
1✔
143
                            "",
144
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
145
                            "/2.0/users/",
146
                            convertToString(userId),
1✔
147
                            "/email_aliases/",
148
                            convertToString(emailAliasId)),
1✔
149
                        "DELETE")
150
                    .headers(headersMap)
1✔
151
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
152
                    .auth(this.auth)
1✔
153
                    .networkSession(this.networkSession)
1✔
154
                    .build());
1✔
155
  }
1✔
156

157
  public Authentication getAuth() {
158
    return auth;
×
159
  }
160

161
  public NetworkSession getNetworkSession() {
162
    return networkSession;
×
163
  }
164

165
  public static class Builder {
166

167
    protected Authentication auth;
168

169
    protected NetworkSession networkSession;
170

171
    public Builder() {
1✔
172
      this.networkSession = new NetworkSession();
1✔
173
    }
1✔
174

175
    public Builder auth(Authentication auth) {
176
      this.auth = auth;
1✔
177
      return this;
1✔
178
    }
179

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

185
    public EmailAliasesManager build() {
186
      return new EmailAliasesManager(this);
1✔
187
    }
188
  }
189
}
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