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

DataBiosphere / consent / #5491

12 Dec 2024 08:57PM UTC coverage: 79.101% (+0.09%) from 79.013%
#5491

push

web-flow
DT-982: Refactor support ticket models (#2437)

21 of 21 new or added lines in 6 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

10204 of 12900 relevant lines covered (79.1%)

0.79 hits per line

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

61.9
/src/main/java/org/broadinstitute/consent/http/models/support/SupportTicket.java
1
package org.broadinstitute.consent.http.models.support;
2

3
import com.google.gson.FieldNamingPolicy;
4
import com.google.gson.GsonBuilder;
5
import java.util.List;
6
import org.broadinstitute.consent.http.enumeration.SupportRequestType;
7

8
/**
9
 * Represents ticket to request support required by the Zendesk API
10
 * <a
11
 * href="https://developer.zendesk.com/api-reference/ticketing/tickets/ticket-requests/">Requests
12
 * API Reference</a>
13
 * <p>
14
 * This is the base object that we use to construct a SupportRequest object that is eventually
15
 * serialized and sent to Zendesk in json format.
16
 */
17
public class SupportTicket {
18

19
  private SupportRequest request;
20

21
  /**
22
   * Constructs a ticket with the proper structure to request support via Zendesk
23
   *
24
   * @param name        The name of the user requesting support
25
   * @param type        The type of request ("question", "incident", "problem", "task")
26
   * @param email       The email of the user requesting support
27
   * @param subject     Subject line of the request
28
   * @param description Description of the task or question
29
   * @param url         The origin url of this request
30
   * @param uploads     Optional list of attachment tokens
31
   */
32
  public SupportTicket(String name, SupportRequestType type, String email, String subject,
33
      String description, String url, List<String> uploads) {
1✔
34
    if (name == null || email == null) {
1✔
UNCOV
35
      throw new IllegalArgumentException("Name and email of user requesting support is required");
×
36
    }
37
    if (subject == null) {
1✔
38
      throw new IllegalArgumentException("Support ticket subject is required");
×
39
    }
40
    if (description == null) {
1✔
41
      throw new IllegalArgumentException("Support ticket description is required");
×
42
    }
43
    if (type == null) {
1✔
44
      throw new IllegalArgumentException("Support ticket type is required");
×
45
    }
46
    if (url == null) {
1✔
47
      throw new IllegalArgumentException("Support ticket url is required");
×
48
    }
49

50
    this.request = new SupportRequest(name, type, email, subject, description, url, uploads);
1✔
51
  }
1✔
52

53
  public SupportRequest getRequest() {
UNCOV
54
    return request;
×
55
  }
56

57
  public void setRequest(SupportRequest request) {
58
    this.request = request;
×
59
  }
×
60

61
  public String toString() {
62
    //Using GsonBuilder directly to convert ticket to json since GsonFactory does not allow custom FieldNamingPolicy
63
    return new GsonBuilder()
1✔
64
        .setPrettyPrinting()
1✔
65
        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
1✔
66
        .create()
1✔
67
        .toJson(this);
1✔
68
  }
69
}
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