Skip to content

Commit 5be1de8

Browse files
fix: align ImpactReportResult with API schema, remove phantom resets_at
Review fixes: - ImpactReportResult: replaced query/action (wrong) with input_index/actions matching the server response shape - ImpactReportResponse: added policy_name field - SimulationDailyUsage: removed resets_at (not in API contract)
1 parent 003a7f1 commit 5be1de8

4 files changed

Lines changed: 28 additions & 25 deletions

File tree

src/main/java/com/getaxonflow/sdk/simulation/ImpactReportResponse.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public final class ImpactReportResponse {
2929
@JsonProperty("policy_id")
3030
private final String policyId;
3131

32+
@JsonProperty("policy_name")
33+
private final String policyName;
34+
3235
@JsonProperty("total_inputs")
3336
private final int totalInputs;
3437

@@ -58,6 +61,7 @@ public final class ImpactReportResponse {
5861

5962
public ImpactReportResponse(
6063
@JsonProperty("policy_id") String policyId,
64+
@JsonProperty("policy_name") String policyName,
6165
@JsonProperty("total_inputs") int totalInputs,
6266
@JsonProperty("matched") int matched,
6367
@JsonProperty("blocked") int blocked,
@@ -68,6 +72,7 @@ public ImpactReportResponse(
6872
@JsonProperty("generated_at") String generatedAt,
6973
@JsonProperty("tier") String tier) {
7074
this.policyId = policyId;
75+
this.policyName = policyName;
7176
this.totalInputs = totalInputs;
7277
this.matched = matched;
7378
this.blocked = blocked;
@@ -80,6 +85,7 @@ public ImpactReportResponse(
8085
}
8186

8287
public String getPolicyId() { return policyId; }
88+
public String getPolicyName() { return policyName; }
8389
public int getTotalInputs() { return totalInputs; }
8490
public int getMatched() { return matched; }
8591
public int getBlocked() { return blocked; }

src/main/java/com/getaxonflow/sdk/simulation/ImpactReportResult.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,39 @@
1818
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020

21+
import java.util.List;
22+
2123
/**
2224
* Result for a single input in an impact report.
2325
*/
2426
@JsonIgnoreProperties(ignoreUnknown = true)
2527
public final class ImpactReportResult {
2628

27-
@JsonProperty("query")
28-
private final String query;
29+
@JsonProperty("input_index")
30+
private final int inputIndex;
2931

3032
@JsonProperty("matched")
3133
private final boolean matched;
3234

3335
@JsonProperty("blocked")
3436
private final boolean blocked;
3537

36-
@JsonProperty("action")
37-
private final String action;
38+
@JsonProperty("actions")
39+
private final List<String> actions;
3840

3941
public ImpactReportResult(
40-
@JsonProperty("query") String query,
42+
@JsonProperty("input_index") int inputIndex,
4143
@JsonProperty("matched") boolean matched,
4244
@JsonProperty("blocked") boolean blocked,
43-
@JsonProperty("action") String action) {
44-
this.query = query;
45+
@JsonProperty("actions") List<String> actions) {
46+
this.inputIndex = inputIndex;
4547
this.matched = matched;
4648
this.blocked = blocked;
47-
this.action = action;
49+
this.actions = actions != null ? List.copyOf(actions) : List.of();
4850
}
4951

50-
public String getQuery() { return query; }
52+
public int getInputIndex() { return inputIndex; }
5153
public boolean isMatched() { return matched; }
5254
public boolean isBlocked() { return blocked; }
53-
public String getAction() { return action; }
55+
public List<String> getActions() { return actions; }
5456
}

src/main/java/com/getaxonflow/sdk/simulation/SimulationDailyUsage.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,13 @@ public final class SimulationDailyUsage {
3030
@JsonProperty("limit")
3131
private final int limit;
3232

33-
@JsonProperty("resets_at")
34-
private final String resetsAt;
35-
3633
public SimulationDailyUsage(
3734
@JsonProperty("used") int used,
38-
@JsonProperty("limit") int limit,
39-
@JsonProperty("resets_at") String resetsAt) {
35+
@JsonProperty("limit") int limit) {
4036
this.used = used;
4137
this.limit = limit;
42-
this.resetsAt = resetsAt;
4338
}
4439

4540
public int getUsed() { return used; }
4641
public int getLimit() { return limit; }
47-
public String getResetsAt() { return resetsAt; }
4842
}

src/test/java/com/getaxonflow/sdk/PolicySimulationTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void shouldSimulatePoliciesBlocked() {
5858
.willReturn(aResponse()
5959
.withStatus(200)
6060
.withHeader("Content-Type", "application/json")
61-
.withBody("{\"success\":true,\"data\":{\"allowed\":false,\"applied_policies\":[\"block-pii\",\"block-financial\"],\"risk_score\":0.85,\"required_actions\":[\"redact_pii\"],\"processing_time_ms\":12,\"total_policies\":5,\"dry_run\":true,\"simulated_at\":\"2026-03-24T10:00:00Z\",\"tier\":\"evaluation\",\"daily_usage\":{\"used\":3,\"limit\":100,\"resets_at\":\"2026-03-25T00:00:00Z\"}}}")));
61+
.withBody("{\"success\":true,\"data\":{\"allowed\":false,\"applied_policies\":[\"block-pii\",\"block-financial\"],\"risk_score\":0.85,\"required_actions\":[\"redact_pii\"],\"processing_time_ms\":12,\"total_policies\":5,\"dry_run\":true,\"simulated_at\":\"2026-03-24T10:00:00Z\",\"tier\":\"evaluation\",\"daily_usage\":{\"used\":3,\"limit\":100}}}")));
6262

6363
SimulatePoliciesResponse result = axonflow.simulatePolicies(
6464
SimulatePoliciesRequest.builder()
@@ -79,7 +79,6 @@ void shouldSimulatePoliciesBlocked() {
7979
assertThat(result.getDailyUsage()).isNotNull();
8080
assertThat(result.getDailyUsage().getUsed()).isEqualTo(3);
8181
assertThat(result.getDailyUsage().getLimit()).isEqualTo(100);
82-
assertThat(result.getDailyUsage().getResetsAt()).isEqualTo("2026-03-25T00:00:00Z");
8382

8483
verify(postRequestedFor(urlEqualTo("/api/v1/policies/simulate"))
8584
.withRequestBody(matchingJsonPath("$.query", equalTo("My SSN is 123-45-6789")))
@@ -93,7 +92,7 @@ void shouldSimulatePoliciesAllowed() {
9392
.willReturn(aResponse()
9493
.withStatus(200)
9594
.withHeader("Content-Type", "application/json")
96-
.withBody("{\"success\":true,\"data\":{\"allowed\":true,\"applied_policies\":[],\"risk_score\":0.1,\"required_actions\":[],\"processing_time_ms\":5,\"total_policies\":5,\"dry_run\":true,\"simulated_at\":\"2026-03-24T10:00:00Z\",\"tier\":\"evaluation\",\"daily_usage\":{\"used\":1,\"limit\":100,\"resets_at\":\"2026-03-25T00:00:00Z\"}}}")));
95+
.withBody("{\"success\":true,\"data\":{\"allowed\":true,\"applied_policies\":[],\"risk_score\":0.1,\"required_actions\":[],\"processing_time_ms\":5,\"total_policies\":5,\"dry_run\":true,\"simulated_at\":\"2026-03-24T10:00:00Z\",\"tier\":\"evaluation\",\"daily_usage\":{\"used\":1,\"limit\":100}}}")));
9796

9897
SimulatePoliciesResponse result = axonflow.simulatePolicies(
9998
SimulatePoliciesRequest.builder()
@@ -213,7 +212,7 @@ void shouldGetPolicyImpactReport() {
213212
.willReturn(aResponse()
214213
.withStatus(200)
215214
.withHeader("Content-Type", "application/json")
216-
.withBody("{\"success\":true,\"data\":{\"policy_id\":\"policy_block_pii\",\"total_inputs\":3,\"matched\":2,\"blocked\":2,\"match_rate\":0.667,\"block_rate\":0.667,\"results\":[{\"query\":\"My SSN is 123-45-6789\",\"matched\":true,\"blocked\":true,\"action\":\"block\"},{\"query\":\"What is the weather?\",\"matched\":false,\"blocked\":false,\"action\":\"allow\"},{\"query\":\"My email is test@example.com\",\"matched\":true,\"blocked\":true,\"action\":\"block\"}],\"processing_time_ms\":25,\"generated_at\":\"2026-03-24T10:00:00Z\",\"tier\":\"evaluation\"}}")));
215+
.withBody("{\"success\":true,\"data\":{\"policy_id\":\"policy_block_pii\",\"policy_name\":\"block-pii\",\"total_inputs\":3,\"matched\":2,\"blocked\":2,\"match_rate\":0.667,\"block_rate\":0.667,\"results\":[{\"input_index\":0,\"matched\":true,\"blocked\":true,\"actions\":[\"block\"]},{\"input_index\":1,\"matched\":false,\"blocked\":false,\"actions\":[\"allow\"]},{\"input_index\":2,\"matched\":true,\"blocked\":true,\"actions\":[\"block\"]}],\"processing_time_ms\":25,\"generated_at\":\"2026-03-24T10:00:00Z\",\"tier\":\"evaluation\"}}")));
217216

218217
ImpactReportResponse report = axonflow.getPolicyImpactReport(
219218
ImpactReportRequest.builder()
@@ -231,13 +230,15 @@ void shouldGetPolicyImpactReport() {
231230
assertThat(report.getBlocked()).isEqualTo(2);
232231
assertThat(report.getMatchRate()).isEqualTo(0.667);
233232
assertThat(report.getBlockRate()).isEqualTo(0.667);
233+
assertThat(report.getPolicyName()).isEqualTo("block-pii");
234234
assertThat(report.getResults()).hasSize(3);
235-
assertThat(report.getResults().get(0).getQuery()).isEqualTo("My SSN is 123-45-6789");
235+
assertThat(report.getResults().get(0).getInputIndex()).isEqualTo(0);
236236
assertThat(report.getResults().get(0).isMatched()).isTrue();
237237
assertThat(report.getResults().get(0).isBlocked()).isTrue();
238-
assertThat(report.getResults().get(0).getAction()).isEqualTo("block");
238+
assertThat(report.getResults().get(0).getActions()).containsExactly("block");
239+
assertThat(report.getResults().get(1).getInputIndex()).isEqualTo(1);
239240
assertThat(report.getResults().get(1).isMatched()).isFalse();
240-
assertThat(report.getResults().get(1).getAction()).isEqualTo("allow");
241+
assertThat(report.getResults().get(1).getActions()).containsExactly("allow");
241242
assertThat(report.getProcessingTimeMs()).isEqualTo(25);
242243
assertThat(report.getGeneratedAt()).isEqualTo("2026-03-24T10:00:00Z");
243244
assertThat(report.getTier()).isEqualTo("evaluation");
@@ -253,7 +254,7 @@ void shouldGetImpactReportNoMatches() {
253254
.willReturn(aResponse()
254255
.withStatus(200)
255256
.withHeader("Content-Type", "application/json")
256-
.withBody("{\"success\":true,\"data\":{\"policy_id\":\"policy_strict\",\"total_inputs\":1,\"matched\":0,\"blocked\":0,\"match_rate\":0.0,\"block_rate\":0.0,\"results\":[{\"query\":\"Hello world\",\"matched\":false,\"blocked\":false,\"action\":\"allow\"}],\"processing_time_ms\":3,\"generated_at\":\"2026-03-24T10:00:00Z\",\"tier\":\"enterprise\"}}")));
257+
.withBody("{\"success\":true,\"data\":{\"policy_id\":\"policy_strict\",\"total_inputs\":1,\"matched\":0,\"blocked\":0,\"match_rate\":0.0,\"block_rate\":0.0,\"results\":[{\"input_index\":0,\"matched\":false,\"blocked\":false,\"actions\":[\"allow\"]}],\"processing_time_ms\":3,\"generated_at\":\"2026-03-24T10:00:00Z\",\"tier\":\"enterprise\"}}")));
257258

258259
ImpactReportResponse report = axonflow.getPolicyImpactReport(
259260
ImpactReportRequest.builder()

0 commit comments

Comments
 (0)