-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestRunStatsExample.java
More file actions
57 lines (51 loc) · 2.13 KB
/
Copy pathTestRunStatsExample.java
File metadata and controls
57 lines (51 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package ai.rhesis.sdk.examples;
import ai.rhesis.sdk.RhesisClient;
import ai.rhesis.sdk.entities.InsightsQuery;
import ai.rhesis.sdk.entities.InsightsResponse;
import java.util.List;
import java.util.Map;
public class TestRunStatsExample {
public static void main(String[] args) {
RhesisClient client = RhesisClient.builder().apiKey(System.getenv("RHESIS_API_KEY")).build();
// --- Test run count ---
System.out.println("=== Test Run Count ===");
InsightsResponse runCount =
client.insights().get("test_run", List.of(), List.of("count"), null);
System.out.println("Dimensions: " + runCount.dimensions());
System.out.println("Measures: " + runCount.measures());
for (Map<String, Object> row : runCount.rows()) {
System.out.println(" " + row);
}
// --- Test runs grouped by status ---
System.out.println("\n=== Test Runs by Status ===");
InsightsResponse byStatus =
client.insights().get("test_run", List.of("status"), List.of("count"), null);
for (Map<String, Object> row : byStatus.rows()) {
System.out.printf(" %-15s count=%s%n", row.get("status"), row.get("count"));
}
// --- Test runs from the last 3 months ---
System.out.println("\n=== Test Runs (last 3 months) ===");
InsightsQuery recentQuery =
InsightsQuery.builder("test_run")
.groupBy(List.of("status"))
.measures(List.of("count"))
.months(3)
.build();
InsightsResponse recent = client.insights().get(recentQuery);
for (Map<String, Object> row : recent.rows()) {
System.out.printf(" %-15s count=%s%n", row.get("status"), row.get("count"));
}
// --- Test runs with date range ---
System.out.println("\n=== Test Runs (custom date range) ===");
InsightsQuery dateRangeQuery =
InsightsQuery.builder("test_run")
.measures(List.of("count"))
.startDate("2025-01-01")
.endDate("2025-12-31")
.build();
InsightsResponse dateRange = client.insights().get(dateRangeQuery);
for (Map<String, Object> row : dateRange.rows()) {
System.out.println(" " + row);
}
}
}