Skip to content

Commit 5924ccb

Browse files
committed
Gemini code review
1 parent 4327a50 commit 5924ccb

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

reference-impl/src/test/java/io/a2a/server/apps/quarkus/A2ATestRoutes.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,13 @@ public void deleteTask(@Param String taskId, RoutingContext rc) {
8585
testUtilsBean.deleteTask(taskId);
8686
rc.response()
8787
.setStatusCode(200)
88-
.putHeader(CONTENT_TYPE, APPLICATION_JSON)
8988
.end();
9089
} catch (Throwable t) {
9190
errorResponse(t, rc);
9291
}
9392
}
9493

95-
@Route(path = "test/queue/ensure/:taskId", methods = {Route.HttpMethod.POST})
94+
@Route(path = "/test/queue/ensure/:taskId", methods = {Route.HttpMethod.POST})
9695
public void ensureTaskQueue(@Param String taskId, RoutingContext rc) {
9796
try {
9897
testUtilsBean.ensureQueue(taskId);
@@ -104,7 +103,7 @@ public void ensureTaskQueue(@Param String taskId, RoutingContext rc) {
104103
}
105104
}
106105

107-
@Route(path = "test/queue/enqueueTaskStatusUpdateEvent/:taskId", methods = {Route.HttpMethod.POST})
106+
@Route(path = "/test/queue/enqueueTaskStatusUpdateEvent/:taskId", methods = {Route.HttpMethod.POST})
108107
public void enqueueTaskStatusUpdateEvent(@Param String taskId, @Body String body, RoutingContext rc) {
109108

110109
try {
@@ -118,7 +117,7 @@ public void enqueueTaskStatusUpdateEvent(@Param String taskId, @Body String body
118117
}
119118
}
120119

121-
@Route(path = "test/queue/enqueueTaskArtifactUpdateEvent/:taskId", methods = {Route.HttpMethod.POST})
120+
@Route(path = "/test/queue/enqueueTaskArtifactUpdateEvent/:taskId", methods = {Route.HttpMethod.POST})
122121
public void enqueueTaskArtifactUpdateEvent(@Param String taskId, @Body String body, RoutingContext rc) {
123122

124123
try {
@@ -132,16 +131,17 @@ public void enqueueTaskArtifactUpdateEvent(@Param String taskId, @Body String bo
132131
}
133132
}
134133

135-
@Route(path = "test/streamingSubscribedCount", methods = {Route.HttpMethod.GET}, produces = {TEXT_PLAIN})
134+
@Route(path = "/test/streamingSubscribedCount", methods = {Route.HttpMethod.GET}, produces = {TEXT_PLAIN})
136135
public void getStreamingSubscribedCount(RoutingContext rc) {
137136
rc.response()
138137
.setStatusCode(200)
139138
.end(String.valueOf(streamingSubscribedCount.get()));
140139
}
141140

142141
private void errorResponse(Throwable t, RoutingContext rc) {
142+
t.printStackTrace();
143143
rc.response()
144-
.setStatusCode(200)
144+
.setStatusCode(500)
145145
.putHeader(CONTENT_TYPE, TEXT_PLAIN)
146146
.end();
147147
}

tests/server-common/src/test/java/io/a2a/server/apps/common/AbstractA2AServerTest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void testTaskStoreMethodsSanityTest() throws Exception {
122122
Task saved = getTaskFromTaskStore(task.getId());
123123
assertEquals(task.getId(), saved.getId());
124124
assertEquals(task.getContextId(), saved.getContextId());
125-
assertEquals(task.getStatus(), saved.getStatus());
125+
assertEquals(task.getStatus().state(), saved.getStatus().state());
126126

127127
deleteTaskInTaskStore(task.getId());
128128
Task saved2 = getTaskFromTaskStore(task.getId());
@@ -160,7 +160,6 @@ private void testGetTask(String mediaType) throws Exception {
160160
assertEquals("session-xyz", response.getResult().getContextId());
161161
assertEquals(TaskState.SUBMITTED, response.getResult().getStatus().state());
162162
assertNull(response.getError());
163-
} catch (Exception e) {
164163
} finally {
165164
deleteTaskInTaskStore(MINIMAL_TASK.getId());
166165
}
@@ -971,12 +970,13 @@ protected void enqueueEventOnServer(Event event) throws Exception {
971970
.build();
972971
HttpRequest request = HttpRequest.newBuilder()
973972
.uri(URI.create("http://localhost:" + serverPort + "/" + path))
973+
.header("Content-Type", APPLICATION_JSON)
974974
.POST(HttpRequest.BodyPublishers.ofString(Utils.OBJECT_MAPPER.writeValueAsString(event)))
975975
.build();
976976

977977
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
978978
if (response.statusCode() != 200) {
979-
throw new RuntimeException(response.statusCode() + ": Deleting task failed!" + response.body());
979+
throw new RuntimeException(response.statusCode() + ": Queueing event failed!" + response.body());
980980
}
981981
}
982982

@@ -986,15 +986,22 @@ private CompletableFuture<Void> awaitStreamingSubscription() {
986986

987987
return CompletableFuture.runAsync(() -> {
988988
try {
989-
while (true) {
989+
boolean done = false;
990+
long end = System.currentTimeMillis() + 15000;
991+
while (System.currentTimeMillis() < end) {
990992
int count = getStreamingSubscribedCount();
991993
if (count > initialCount.get()) {
994+
done = true;
992995
break;
993996
}
994997
Thread.sleep(500);
995998
}
999+
if (!done) {
1000+
throw new RuntimeException("Timed out waiting for subscription");
1001+
}
9961002
} catch (InterruptedException e) {
9971003
Thread.currentThread().interrupt();
1004+
throw new RuntimeException("Interrupted");
9981005
}
9991006
});
10001007
}
@@ -1010,8 +1017,7 @@ private int getStreamingSubscribedCount() {
10101017
try {
10111018
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8));
10121019
String body = response.body().trim();
1013-
System.out.println(body);
1014-
return Integer.valueOf(body);
1020+
return Integer.parseInt(body);
10151021
} catch (IOException | InterruptedException e) {
10161022
throw new RuntimeException(e);
10171023
}

0 commit comments

Comments
 (0)