Skip to content

Commit dab6633

Browse files
committed
test: cover empty and null push config ids
1 parent 5bd4916 commit dab6633

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎server-common/src/test/java/org/a2aproject/sdk/server/tasks/InMemoryPushNotificationConfigStoreTest.java‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ public void testSetInfoAppendsToExistingConfig() {
149149
}
150150

151151
@Test
152-
public void testSetInfoWithoutConfigId() {
152+
public void testSetInfoWithEmptyConfigId() {
153153
String taskId = "task1";
154154
TaskPushNotificationConfig initialConfig = TaskPushNotificationConfig.builder()
155+
.id("")
155156
.url("http://initial.url/callback")
156157
.taskId(taskId)
157158
.build();
@@ -164,6 +165,7 @@ public void testSetInfoWithoutConfigId() {
164165
assertEquals(taskId, configResult.configs().get(0).id());
165166

166167
TaskPushNotificationConfig updatedConfig = TaskPushNotificationConfig.builder()
168+
.id("")
167169
.url("http://initial.url/callback_new")
168170
.taskId(taskId)
169171
.build();
@@ -176,6 +178,19 @@ public void testSetInfoWithoutConfigId() {
176178
assertEquals(updatedConfig.url(), configResult.configs().get(0).url());
177179
}
178180

181+
@Test
182+
public void testSetInfoWithNullConfigId() {
183+
String taskId = "task_with_null_config_id";
184+
TaskPushNotificationConfig config = TaskPushNotificationConfig.builder()
185+
.url("http://initial.url/callback")
186+
.taskId(taskId)
187+
.build();
188+
189+
TaskPushNotificationConfig result = configStore.setInfo(config);
190+
191+
assertEquals(taskId, result.id(), "Config ID should default to taskId when null");
192+
}
193+
179194
@Test
180195
public void testGetInfoExistingConfig() {
181196
String taskId = "task_get_exist";

0 commit comments

Comments
 (0)