From 97a6b2e010be8efd1f5aa647c7cb2010581d8792 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Tue, 21 Apr 2026 21:18:14 +0200 Subject: [PATCH] fix(test): align AgentCommandControllerIT with current spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two drifts corrected: - registerAgent helper missing required environmentId (spec: 400 if absent). - sendGroupCommand is now synchronous request-reply: returns 200 with an aggregated CommandGroupResponse {success,total,responded,responses,timedOut} — no longer 202 with {targetCount,commandIds}. Updated assertions and name. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../app/controller/AgentCommandControllerIT.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cameleer-server-app/src/test/java/com/cameleer/server/app/controller/AgentCommandControllerIT.java b/cameleer-server-app/src/test/java/com/cameleer/server/app/controller/AgentCommandControllerIT.java index 132e34ea..22fe45be 100644 --- a/cameleer-server-app/src/test/java/com/cameleer/server/app/controller/AgentCommandControllerIT.java +++ b/cameleer-server-app/src/test/java/com/cameleer/server/app/controller/AgentCommandControllerIT.java @@ -42,6 +42,7 @@ class AgentCommandControllerIT extends AbstractPostgresIT { { "instanceId": "%s", "applicationId": "%s", + "environmentId": "default", "version": "1.0.0", "routeIds": ["route-1"], "capabilities": {} @@ -77,7 +78,7 @@ class AgentCommandControllerIT extends AbstractPostgresIT { } @Test - void sendGroupCommand_returns202WithTargetCount() throws Exception { + void sendGroupCommand_returns200WithAggregateReplies() throws Exception { String group = "cmd-it-group-" + UUID.randomUUID().toString().substring(0, 8); registerAgent("agent-g1-" + group, "Group Agent 1", group); registerAgent("agent-g2-" + group, "Group Agent 2", group); @@ -86,17 +87,20 @@ class AgentCommandControllerIT extends AbstractPostgresIT { {"type": "deep-trace", "payload": {"correlationId": "group-trace-1"}} """; + // Group dispatch is synchronous request-reply with a 10s deadline; returns + // 200 with the aggregated reply set (total/responded/timedOut). Neither agent + // holds an SSE connection in this test, so both time out but are counted. ResponseEntity response = restTemplate.postForEntity( "/api/v1/agents/groups/" + group + "/commands", new HttpEntity<>(commandJson, securityHelper.authHeaders(operatorJwt)), String.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); JsonNode body = objectMapper.readTree(response.getBody()); - assertThat(body.get("targetCount").asInt()).isEqualTo(2); - assertThat(body.get("commandIds").isArray()).isTrue(); - assertThat(body.get("commandIds").size()).isEqualTo(2); + assertThat(body.get("total").asInt()).isEqualTo(2); + assertThat(body.get("timedOut").isArray()).isTrue(); + assertThat(body.get("timedOut").size()).isEqualTo(2); } @Test