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

box / box-java-sdk-gen / #301

26 Jun 2025 03:33PM UTC coverage: 35.681% (-0.04%) from 35.723%
#301

push

github

web-flow
feat: Add webhook validation(box/box-codegen#745) (#347)

Co-authored-by: box-sdk-build <box-sdk-build@box.com>

68 of 82 new or added lines in 2 files covered. (82.93%)

11818 existing lines in 631 files now uncovered.

16948 of 47499 relevant lines covered (35.68%)

0.36 hits per line

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

23.08
/src/main/java/com/box/sdkgen/schemas/webhook/Webhook.java
1
package com.box.sdkgen.schemas.webhook;
2

3
import com.box.sdkgen.internal.utils.DateTimeUtils;
4
import com.box.sdkgen.schemas.usermini.UserMini;
5
import com.box.sdkgen.schemas.webhookmini.WebhookMini;
6
import com.box.sdkgen.schemas.webhookmini.WebhookMiniTargetField;
7
import com.box.sdkgen.schemas.webhookmini.WebhookMiniTypeField;
8
import com.box.sdkgen.serialization.json.EnumWrapper;
9
import com.box.sdkgen.serialization.json.Valuable;
10
import com.fasterxml.jackson.annotation.JsonFilter;
11
import com.fasterxml.jackson.annotation.JsonProperty;
12
import com.fasterxml.jackson.core.JsonGenerator;
13
import com.fasterxml.jackson.core.JsonParser;
14
import com.fasterxml.jackson.databind.DeserializationContext;
15
import com.fasterxml.jackson.databind.JsonDeserializer;
16
import com.fasterxml.jackson.databind.JsonNode;
17
import com.fasterxml.jackson.databind.JsonSerializer;
18
import com.fasterxml.jackson.databind.SerializerProvider;
19
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
20
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
21
import java.io.IOException;
22
import java.util.ArrayList;
23
import java.util.Date;
24
import java.util.List;
25
import java.util.Objects;
26

27
@JsonFilter("nullablePropertyFilter")
28
public class Webhook extends WebhookMini {
29

30
  @JsonProperty("created_by")
31
  protected UserMini createdBy;
32

33
  @JsonProperty("created_at")
34
  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
35
  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
36
  protected Date createdAt;
37

38
  protected String address;
39

40
  @JsonDeserialize(using = TriggersDeserializer.class)
41
  @JsonSerialize(using = TriggersSerializer.class)
42
  protected List<EnumWrapper<WebhookTriggersField>> triggers;
43

44
  public Webhook() {
45
    super();
1✔
46
  }
1✔
47

48
  protected Webhook(Builder builder) {
49
    super(builder);
×
50
    this.createdBy = builder.createdBy;
×
51
    this.createdAt = builder.createdAt;
×
52
    this.address = builder.address;
×
UNCOV
53
    this.triggers = builder.triggers;
×
UNCOV
54
    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
×
55
  }
×
56

57
  public UserMini getCreatedBy() {
UNCOV
58
    return createdBy;
×
59
  }
60

61
  public Date getCreatedAt() {
UNCOV
62
    return createdAt;
×
63
  }
64

65
  public String getAddress() {
66
    return address;
1✔
67
  }
68

69
  public List<EnumWrapper<WebhookTriggersField>> getTriggers() {
70
    return triggers;
1✔
71
  }
72

73
  @Override
74
  public boolean equals(Object o) {
75
    if (this == o) {
×
76
      return true;
×
77
    }
78
    if (o == null || getClass() != o.getClass()) {
×
79
      return false;
×
80
    }
81
    Webhook casted = (Webhook) o;
×
82
    return Objects.equals(id, casted.id)
×
83
        && Objects.equals(type, casted.type)
×
84
        && Objects.equals(target, casted.target)
×
85
        && Objects.equals(createdBy, casted.createdBy)
×
UNCOV
86
        && Objects.equals(createdAt, casted.createdAt)
×
UNCOV
87
        && Objects.equals(address, casted.address)
×
UNCOV
88
        && Objects.equals(triggers, casted.triggers);
×
89
  }
90

91
  @Override
92
  public int hashCode() {
UNCOV
93
    return Objects.hash(id, type, target, createdBy, createdAt, address, triggers);
×
94
  }
95

96
  @Override
97
  public String toString() {
UNCOV
98
    return "Webhook{"
×
99
        + "id='"
100
        + id
101
        + '\''
102
        + ", "
103
        + "type='"
104
        + type
105
        + '\''
106
        + ", "
107
        + "target='"
108
        + target
109
        + '\''
110
        + ", "
111
        + "createdBy='"
112
        + createdBy
113
        + '\''
114
        + ", "
115
        + "createdAt='"
116
        + createdAt
117
        + '\''
118
        + ", "
119
        + "address='"
120
        + address
121
        + '\''
122
        + ", "
123
        + "triggers='"
124
        + triggers
125
        + '\''
126
        + "}";
127
  }
128

UNCOV
129
  public static class Builder extends WebhookMini.Builder {
×
130

131
    protected UserMini createdBy;
132

133
    protected Date createdAt;
134

135
    protected String address;
136

137
    protected List<EnumWrapper<WebhookTriggersField>> triggers;
138

139
    public Builder createdBy(UserMini createdBy) {
UNCOV
140
      this.createdBy = createdBy;
×
UNCOV
141
      return this;
×
142
    }
143

144
    public Builder createdAt(Date createdAt) {
UNCOV
145
      this.createdAt = createdAt;
×
UNCOV
146
      return this;
×
147
    }
148

149
    public Builder address(String address) {
UNCOV
150
      this.address = address;
×
UNCOV
151
      return this;
×
152
    }
153

154
    public Builder triggers(List<? extends Valuable> triggers) {
UNCOV
155
      this.triggers = EnumWrapper.wrapValuableEnumList(triggers, WebhookTriggersField.class);
×
UNCOV
156
      return this;
×
157
    }
158

159
    @Override
160
    public Builder id(String id) {
UNCOV
161
      this.id = id;
×
UNCOV
162
      return this;
×
163
    }
164

165
    @Override
166
    public Builder type(WebhookMiniTypeField type) {
UNCOV
167
      this.type = new EnumWrapper<WebhookMiniTypeField>(type);
×
UNCOV
168
      return this;
×
169
    }
170

171
    @Override
172
    public Builder type(EnumWrapper<WebhookMiniTypeField> type) {
UNCOV
173
      this.type = type;
×
UNCOV
174
      return this;
×
175
    }
176

177
    @Override
178
    public Builder target(WebhookMiniTargetField target) {
UNCOV
179
      this.target = target;
×
UNCOV
180
      return this;
×
181
    }
182

183
    public Webhook build() {
UNCOV
184
      return new Webhook(this);
×
185
    }
186
  }
187

188
  public static class TriggersDeserializer
189
      extends JsonDeserializer<List<EnumWrapper<WebhookTriggersField>>> {
190

191
    public final JsonDeserializer<EnumWrapper<WebhookTriggersField>> elementDeserializer;
192

193
    public TriggersDeserializer() {
194
      super();
1✔
195
      this.elementDeserializer = new WebhookTriggersField.WebhookTriggersFieldDeserializer();
1✔
196
    }
1✔
197

198
    @Override
199
    public List<EnumWrapper<WebhookTriggersField>> deserialize(
200
        JsonParser p, DeserializationContext ctxt) throws IOException {
201
      JsonNode node = p.getCodec().readTree(p);
1✔
202
      List<EnumWrapper<WebhookTriggersField>> elements = new ArrayList<>();
1✔
203
      for (JsonNode item : node) {
1✔
204
        JsonParser pa = item.traverse(p.getCodec());
1✔
205
        pa.nextToken();
1✔
206
        elements.add(elementDeserializer.deserialize(pa, ctxt));
1✔
207
      }
1✔
208
      return elements;
1✔
209
    }
210
  }
211

212
  public static class TriggersSerializer
213
      extends JsonSerializer<List<EnumWrapper<WebhookTriggersField>>> {
214

215
    public final JsonSerializer<EnumWrapper<WebhookTriggersField>> elementSerializer;
216

217
    public TriggersSerializer() {
UNCOV
218
      super();
×
UNCOV
219
      this.elementSerializer = new WebhookTriggersField.WebhookTriggersFieldSerializer();
×
UNCOV
220
    }
×
221

222
    @Override
223
    public void serialize(
224
        List<EnumWrapper<WebhookTriggersField>> value,
225
        JsonGenerator gen,
226
        SerializerProvider serializers)
227
        throws IOException {
228
      gen.writeStartArray();
×
229
      for (EnumWrapper<WebhookTriggersField> item : value) {
×
230
        elementSerializer.serialize(item, gen, serializers);
×
UNCOV
231
      }
×
UNCOV
232
      gen.writeEndArray();
×
UNCOV
233
    }
×
234
  }
235
}
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