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

box / box-java-sdk / #4386

18 Feb 2025 02:49PM UTC coverage: 71.881% (-0.02%) from 71.901%
#4386

Pull #1289

github

web-flow
Merge 5275138cf into 9119adcea
Pull Request #1289: fix: Fix AI dialogue history

40 of 48 new or added lines in 10 files covered. (83.33%)

3 existing lines in 1 file now uncovered.

8152 of 11341 relevant lines covered (71.88%)

0.72 hits per line

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

52.17
/src/main/java/com/box/sdk/BoxAIExtractStructuredResponse.java
1
package com.box.sdk;
2

3
import com.eclipsesource.json.Json;
4
import com.eclipsesource.json.JsonObject;
5
import com.eclipsesource.json.JsonValue;
6
import java.text.ParseException;
7
import java.util.Date;
8

9
/**
10
 * AI response to a user request.
11
 */
12
public class BoxAIExtractStructuredResponse extends BoxJSONObject {
1✔
13
    private final JsonObject sourceJson;
14
    private JsonObject answer;
15
    private String completionReason;
16
    private Date createdAt;
17

18
    /**
19
     * Constructs a BoxAIResponse object.
20
     */
21
    public BoxAIExtractStructuredResponse(String json) {
22
        super(json);
1✔
23
        this.sourceJson = Json.parse(json).asObject();
1✔
24
    }
1✔
25

26
    /**
27
     * Constructs an BoxAIResponse object using an already parsed JSON object.
28
     *
29
     * @param jsonObject the parsed JSON object.
30
     */
31
    BoxAIExtractStructuredResponse(JsonObject jsonObject) {
32
        super(jsonObject);
×
33
        this.sourceJson = jsonObject;
×
34
    }
×
35

36
    /**
37
     * Gets the source JSON of the AI response.
38
     *
39
     * @return the source JSON of the AI response.
40
     */
41
    public JsonObject getSourceJson() {
42
        return sourceJson;
1✔
43
    }
44

45
    /**
46
     * Gets the answer of the AI.
47
     *
48
     * @return the answer of the AI.
49
     */
50
    public JsonObject getAnswer() {
NEW
51
        return answer;
×
52
    }
53

54
    /**
55
     * Gets reason the response finishes.
56
     *
57
     * @return the reason the response finishes.
58
     */
59
    public String getCompletionReason() {
NEW
60
        return completionReason;
×
61
    }
62

63
    /**
64
     * Gets the ISO date formatted timestamp of when the answer to the prompt was created.
65
     *
66
     * @return The ISO date formatted timestamp of when the answer to the prompt was created.
67
     */
68
    public Date getCreatedAt() {
NEW
69
        return createdAt;
×
70
    }
71

72
    /**
73
     * {@inheritDoc}
74
     */
75
    @Override
76
    void parseJSONMember(JsonObject.Member member) {
77
        JsonValue value = member.getValue();
1✔
78
        String memberName = member.getName();
1✔
79
        try {
80
            if (memberName.equals("answer")) {
1✔
NEW
81
                this.answer = value.asObject();
×
82
            } else if (memberName.equals("completion_reason")) {
1✔
NEW
83
                this.completionReason = value.asString();
×
84
            } else if (memberName.equals("created_at")) {
1✔
NEW
85
                this.createdAt = BoxDateFormat.parse(value.asString());
×
86
            }
NEW
87
        } catch (ParseException e) {
×
NEW
88
            assert false : "A ParseException indicates a bug in the SDK.";
×
89
        }
1✔
90
    }
1✔
91

92
}
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

© 2025 Coveralls, Inc